Re: Do path: searches handle spaces correctly?
[notmuch-archives.git] / 9b / 68a2e20503562396ece69c22f38576fbdf38bf
1 Return-Path: <amdragon@mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 11A86431FD5\r
6         for <notmuch@notmuchmail.org>; Thu, 30 May 2013 16:28:31 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id kZ1Q8rkpxN42 for <notmuch@notmuchmail.org>;\r
16         Thu, 30 May 2013 16:28:25 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 5DB58431FC3\r
20         for <notmuch@notmuchmail.org>; Thu, 30 May 2013 16:28:25 -0700 (PDT)\r
21 X-AuditID: 1209190e-b7f4f6d000005142-07-51a7e0964e45\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 38.F7.20802.690E7A15; Thu, 30 May 2013 19:28:22 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r4UNSLk6011926; \r
27         Thu, 30 May 2013 19:28:22 -0400\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
29         (authenticated bits=0)\r
30         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
31         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4UNSJbA030419\r
32         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
33         Thu, 30 May 2013 19:28:20 -0400\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
35         (envelope-from <amdragon@mit.edu>)\r
36         id 1UiCGZ-0006Bb-07; Thu, 30 May 2013 19:28:19 -0400\r
37 From: Austin Clements <aclements@csail.mit.edu>\r
38 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
39 Subject: Re: [PATCH v2 3/3] emacs: show: implement lazy hidden part handling\r
40 In-Reply-To: <1369555061-21361-4-git-send-email-markwalters1009@gmail.com>\r
41 References: <1369555061-21361-1-git-send-email-markwalters1009@gmail.com>\r
42         <1369555061-21361-4-git-send-email-markwalters1009@gmail.com>\r
43 User-Agent: Notmuch/0.15.2+83~g8bee3c4 (http://notmuchmail.org) Emacs/23.4.1\r
44         (i486-pc-linux-gnu)\r
45 Date: Thu, 30 May 2013 19:28:18 -0400\r
46 Message-ID: <877gig2gkt.fsf@awakening.csail.mit.edu>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=us-ascii\r
49 X-Brightmail-Tracker:\r
50  H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsUixG6nrjvtwfJAg8Xn5SxWz+WxuH5zJrMD\r
51         k8fOWXfZPZ6tusUcwBTFZZOSmpNZllqkb5fAlbGvu42x4L1Kxbo3k1gbGKfJdjFyckgImEj8\r
52         W/6NFcIWk7hwbz1bFyMXh5DAPkaJgy8fMkM4Gxklnpz/zwrhnGaS2Ln6PRtIi5DAEkaJz+sz\r
53         QWw2AX2JFWsngY0SEXCVePrtMzOILSzgIzF72mawOKeAl8ST1ScYIQa1M0qcudLFCJIQFUiQ\r
54         WHn3BJjNIqAq8eHCbbBmXqD7Hl55ywphC0qcnPmEBcRmFtCSuPHvJdMERoFZSFKzkKQWMDKt\r
55         YpRNya3SzU3MzClOTdYtTk7My0st0jXWy80s0UtNKd3ECApJTkm+HYxfDyodYhTgYFTi4c1I\r
56         Wh4oxJpYVlyZe4hRkoNJSZT3zT2gEF9SfkplRmJxRnxRaU5q8SFGCQ5mJRHeznNAOd6UxMqq\r
57         1KJ8mJQ0B4uSOO+VlJv+QgLpiSWp2ampBalFMFkZDg4lCd7m+0CNgkWp6akVaZk5JQhpJg5O\r
58         kOE8QMNXgtTwFhck5hZnpkPkTzEqSonzzgBJCIAkMkrz4HphKeMVozjQK8K8tSBVPMB0A9f9\r
59         CmgwE9DgJ9Zgg0sSEVJSDYwy1Sw7ohdfDlUPT7pzr/XCLWvVdeGc7vo6M1dJR18KLzs1q6Wu\r
60         uUPD7fZn/gbmnh1fui63eATUijv2Hd1sL3Z1to3f+S2TTiXn8b5LPGazbqsNQ9v+dV3vPu6M\r
61         MfN7VzU3pMNAV7M27/rvCTVd4qaxGx9vyS6a21Jm+/jiJaGEjzvf/r/dWqDEUpyRaKjFXFSc\r
62         CAAohjxI9AIAAA==\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\r
66 List-Id: "Use and development of the notmuch mail system."\r
67         <notmuch.notmuchmail.org>\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
71 List-Post: <mailto:notmuch@notmuchmail.org>\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
75 X-List-Received-Date: Thu, 30 May 2013 23:28:31 -0000\r
76 \r
77 On Sun, 26 May 2013, Mark Walters <markwalters1009@gmail.com> wrote:\r
78 > This adds the actual code to do the lazy insertion of hidden parts.\r
79 >\r
80 > We use a memory inefficient but simple method: when we come to insert\r
81 > the part if it is hidden we just store all of the arguments to the\r
82 > part insertion function as a button property. This means when we want\r
83 > to show the part we can just resume where we left off.\r
84 >\r
85 > The only slight subtlety/hack is that to simplify the handling of the\r
86 > invisibility overlay (for the hiding unhiding later) we do insert some\r
87 > dummy text which we remove when we show the part.\r
88 > ---\r
89 >  emacs/notmuch-show.el |   32 ++++++++++++++++++++++++++++++--\r
90 >  1 files changed, 30 insertions(+), 2 deletions(-)\r
91 >\r
92 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
93 > index 591ad56..94faa9b 100644\r
94 > --- a/emacs/notmuch-show.el\r
95 > +++ b/emacs/notmuch-show.el\r
96 > @@ -560,6 +560,7 @@ message at DEPTH in the current thread."\r
97 >        (overlay (button-get button 'overlay)))\r
98 >      (when overlay\r
99 >        (let* ((show (overlay-get overlay 'invisible))\r
100 > +          (lazy-part (button-get button :notmuch-lazy-part))\r
101 >            (new-start (button-start button))\r
102 >            (button-label (button-get button :base-label))\r
103 >            (old-point (point))\r
104 > @@ -570,7 +571,11 @@ message at DEPTH in the current thread."\r
105 >       (let ((old-end (button-end button)))\r
106 >         (move-overlay button new-start (point))\r
107 >         (delete-region (point) old-end))\r
108 > -     (goto-char (min old-point (1- (button-end button))))))))\r
109 > +     (goto-char (min old-point (1- (button-end button))))\r
110 > +     (when (and show lazy-part)\r
111 > +       (save-excursion\r
112 > +         (button-put button :notmuch-lazy-part nil)\r
113 > +         (notmuch-show-lazy-part lazy-part button)))))))\r
114 >  \r
115 >  (defun notmuch-show-multipart/*-to-list (part)\r
116 >    (mapcar (lambda (inner-part) (plist-get inner-part :content-type))\r
117 > @@ -854,6 +859,24 @@ message at DEPTH in the current thread."\r
118 >        (setq handlers (cdr handlers))))\r
119 >    t)\r
120 >  \r
121 > +(defun notmuch-show-lazy-part (part-args button)\r
122 > +  (interactive)\r
123 > +  ;; We have to save the depth as we can't find the depth when narrowed\r
124 > +  (let ((inhibit-read-only t)\r
125 > +     (overlay (button-get button 'overlay))\r
126 > +     (depth (notmuch-show-get-depth)))\r
127 > +    (save-restriction\r
128 > +      (narrow-to-region (overlay-start overlay) (1- (overlay-end overlay)))\r
129 > +      (delete-region (overlay-start overlay) (1- (overlay-end overlay)))\r
130 > +      (goto-char (overlay-start overlay))\r
131 > +      (apply #'notmuch-show-insert-bodypart-internal (nconc part-args (list button)))\r
132 \r
133 Is there a reason 'button' couldn't be included in parts-args when\r
134 parts-args was originally constructed below?  (If so, then this probably\r
135 deserves a comment.)\r
136 \r
137 > +      (indent-rigidly (overlay-start overlay)\r
138 > +                   (1- (overlay-end overlay))\r
139 > +                   depth))\r
140 > +    ;; We deferred deleting this character to simplify handling of the\r
141 > +    ;; overlay: all of the above takes place inside the overlay.\r
142 > +    (delete-region (1- (overlay-end overlay)) (overlay-end overlay))))\r
143 > +\r
144 >  (defun notmuch-show-create-part-overlays (msg beg end hide)\r
145 >    "Add an overlay to the part between BEG and END"\r
146 >    (let* ((button (button-at beg))\r
147 > @@ -888,7 +911,12 @@ If HIDE is non-nil then initially hide this part."\r
148 >        (button (unless (string= mime-type "text/plain")\r
149 >                  (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename)))))\r
150 >  \r
151 > -    (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button)\r
152 > +    (if (not hide)\r
153 > +        (notmuch-show-insert-bodypart-internal msg part mime-type nth depth content-type button)\r
154 > +      (insert "lazy part")\r
155 \r
156 The insert is worth a comment.  Or fixing if it's not too difficult.\r
157 \r
158 > +      (button-put button :notmuch-lazy-part\r
159 > +                  (list msg part mime-type nth depth content-type)))\r
160 > +\r
161 \r
162 To summarize the IRC discussion for the record, this changes the\r
163 behavior of lazily inserted parts that we can't render.  Currently the\r
164 only way we know if we can render a part is by attempting to render it.\r
165 As a result, lazily inserted parts that we can't render that would\r
166 previously have offered to save the part when the part button was\r
167 selected will now attempt to render the part and simply not display\r
168 anything.\r
169 \r
170 >      ;; Some of the body part handlers leave point somewhere up in the\r
171 >      ;; part, so we make sure that we're down at the end.\r
172 >      (goto-char (point-max))\r
173 > -- \r
174 > 1.7.9.1\r
175 >\r
176 > _______________________________________________\r
177 > notmuch mailing list\r
178 > notmuch@notmuchmail.org\r
179 > http://notmuchmail.org/mailman/listinfo/notmuch\r