Re: Filesystem functionality used by notmuch
[notmuch-archives.git] / 6d / a7ffcbaf44aecb8844c9d13eae93c26c5ccb6d
1 Return-Path: <m.walters@qmul.ac.uk>\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 B3BC3431FC0\r
6         for <notmuch@notmuchmail.org>; Sun,  1 Sep 2013 11:03:46 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id HPsDWAnexEi2 for <notmuch@notmuchmail.org>;\r
17         Sun,  1 Sep 2013 11:03:42 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id D4E4C431FBC\r
22         for <notmuch@notmuchmail.org>; Sun,  1 Sep 2013 11:03:41 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1VGBzs-0004Dm-Lf; Sun, 01 Sep 2013 19:03:37 +0100\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1VGBzs-0004iU-76; Sun, 01 Sep 2013 19:03:36 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH] emacs: insert quotable parts in reply as they are\r
34         displayed in show view\r
35 In-Reply-To: <1378058393-29590-1-git-send-email-jani@nikula.org>\r
36 References: <1378058393-29590-1-git-send-email-jani@nikula.org>\r
37 User-Agent: Notmuch/0.15.2+269~g01f5508 (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Sun, 01 Sep 2013 19:03:34 +0100\r
40 Message-ID: <87li3gifm1.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 93.97.24.31\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: a75e901657806feaa64c741356378bf4 (of first 20000 bytes)\r
46 X-SpamAssassin-Score: 0.0\r
47 X-SpamAssassin-SpamBar: /\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored 0.0 points. Summary of the scoring: \r
52         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
53         provider *      (markwalters1009[at]gmail.com)\r
54         *  0.0 AWL AWL: From: address is in the auto white-list\r
55 X-QM-Scan-Virus: ClamAV says the message is clean\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Sun, 01 Sep 2013 18:03:46 -0000\r
69 \r
70 \r
71 This version gets a +1 from me\r
72 \r
73 Mark\r
74 \r
75 \r
76 On Sun, 01 Sep 2013, Jani Nikula <jani@nikula.org> wrote:\r
77 > In reply, insert quotable parts using notmuch-show-insert-bodypart\r
78 > instead of calling notmuch-mm-display-part-inline directly to render\r
79 > the quoted parts as they are rendered in show view.\r
80 >\r
81 > We use a temp buffer to not leak text properties from the show\r
82 > renderer into the reply. This way we also don't need to worry about\r
83 > narrowing or point placement. Credits to Mark Walters\r
84 > <markwalters1009@gmail.com> and Austin Clements <amdragon@MIT.EDU> for\r
85 > getting this part straight.\r
86 >\r
87 > The notable change is that replies to text/calendar parts quote the\r
88 > pretty printed output of icalendar-import-buffer rather than the ugly\r
89 > raw vcalendar.\r
90 >\r
91 > ---\r
92 >\r
93 > v2: use (narrow-to-region (point-min) (point)) in\r
94 > notmuch-mua-insert-quotable-part instead of adding the ugly recenter\r
95 > in notmuch-mua-reply. Thanks to Austin and Mark for figuring this out.\r
96 >\r
97 > v3: Incorporate id:87eh98twws.fsf@qmul.ac.uk from Mark\r
98 > ---\r
99 >  emacs/notmuch-mua.el  | 17 +++++++++++------\r
100 >  emacs/notmuch-show.el | 18 +++++++++++++-----\r
101 >  2 files changed, 24 insertions(+), 11 deletions(-)\r
102 >\r
103 > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
104 > index 2baae5f..ff8149b 100644\r
105 > --- a/emacs/notmuch-mua.el\r
106 > +++ b/emacs/notmuch-mua.el\r
107 > @@ -28,6 +28,8 @@\r
108 >  \r
109 >  (eval-when-compile (require 'cl))\r
110 >  \r
111 > +(declare-function notmuch-show-insert-bodypart "notmuch-show" (msg part depth &optional hide))\r
112 > +\r
113 >  ;;\r
114 >  \r
115 >  (defcustom notmuch-mua-send-hook '(notmuch-mua-message-send-hook)\r
116 > @@ -128,12 +130,15 @@ list."\r
117 >         collect part))\r
118 >  \r
119 >  (defun notmuch-mua-insert-quotable-part (message part)\r
120 > -  (save-restriction\r
121 > -    (narrow-to-region (point) (point))\r
122 > -    (notmuch-mm-display-part-inline message part (plist-get part :id)\r
123 > -                                 (plist-get part :content-type)\r
124 > -                                 notmuch-show-process-crypto)\r
125 > -    (goto-char (point-max))))\r
126 > +  ;; We don't want text properties leaking from the show renderer into\r
127 > +  ;; the reply so we use a temp buffer. Also we don't want hooks, such\r
128 > +  ;; as notmuch-wash-*, to be run on the quotable part so we set\r
129 > +  ;; notmuch-show-insert-text/plain-hook to nil.\r
130 > +  (insert (with-temp-buffer\r
131 > +         (let ((notmuch-show-insert-text/plain-hook nil))\r
132 > +           ;; Show the part but do not add buttons.\r
133 > +           (notmuch-show-insert-bodypart message part 0 'no-buttons))\r
134 > +         (buffer-substring-no-properties (point-min) (point-max)))))\r
135 >  \r
136 >  ;; There is a bug in emacs 23's message.el that results in a newline\r
137 >  ;; not being inserted after the References header, so the next header\r
138 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
139 > index 2896aae..904b98e 100644\r
140 > --- a/emacs/notmuch-show.el\r
141 > +++ b/emacs/notmuch-show.el\r
142 > @@ -844,7 +844,11 @@ message at DEPTH in the current thread."\r
143 >  (defun notmuch-show-insert-bodypart (msg part depth &optional hide)\r
144 >    "Insert the body part PART at depth DEPTH in the current thread.\r
145 >  \r
146 > -If HIDE is non-nil then initially hide this part."\r
147 > +HIDE determines whether to show or hide the part and the button\r
148 > +as follows: If HIDE is nil, show the part and the button. If HIDE\r
149 > +is t, hide the part initially and show the button. If HIDE is\r
150 > +'no-buttons, show the part but do not add any buttons (this is\r
151 > +useful for quoting in replies)."\r
152 >  \r
153 >    (let* ((content-type (downcase (plist-get part :content-type)))\r
154 >        (mime-type (or (and (string= content-type "application/octet-stream")\r
155 > @@ -854,15 +858,19 @@ If HIDE is non-nil then initially hide this part."\r
156 >                       content-type))\r
157 >        (nth (plist-get part :id))\r
158 >        (beg (point))\r
159 > -      ;; We omit the part button for the first (or only) part if this is text/plain.\r
160 > -      (button (unless (and (string= mime-type "text/plain") (<= nth 1))\r
161 > +      ;; Hide the part initially if HIDE is t.\r
162 > +      (show-part (not (equal hide t)))\r
163 > +      ;; We omit the part button for the first (or only) part if\r
164 > +      ;; this is text/plain, or HIDE is 'no-buttons.\r
165 > +      (button (unless (or (equal hide 'no-buttons)\r
166 > +                          (and (string= mime-type "text/plain") (<= nth 1)))\r
167 >                  (notmuch-show-insert-part-header nth mime-type content-type (plist-get part :filename))))\r
168 >        (content-beg (point)))\r
169 >  \r
170 >      ;; Store the computed mime-type for later use (e.g. by attachment handlers).\r
171 >      (plist-put part :computed-type mime-type)\r
172 >  \r
173 > -    (if (not hide)\r
174 > +    (if show-part\r
175 >          (notmuch-show-insert-bodypart-internal msg part mime-type nth depth button)\r
176 >        (button-put button :notmuch-lazy-part\r
177 >                    (list msg part mime-type nth depth button)))\r
178 > @@ -875,7 +883,7 @@ If HIDE is non-nil then initially hide this part."\r
179 >        (insert "\n"))\r
180 >      ;; We do not create the overlay for hidden (lazy) parts until\r
181 >      ;; they are inserted.\r
182 > -    (if (not hide)\r
183 > +    (if show-part\r
184 >       (notmuch-show-create-part-overlays button content-beg (point))\r
185 >        (save-excursion\r
186 >       (notmuch-show-toggle-part-invisibility button)))\r
187 > -- \r
188 > 1.8.4.rc3\r