Re: [PATCH] add has: query prefix to search for specific properties
[notmuch-archives.git] / 7b / 203bde82bb154cd04704c0caf6feaa073fb436
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 125A0431FB6\r
6         for <notmuch@notmuchmail.org>; Thu, 30 May 2013 07:33:41 -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 PcSsA6FYWOFv for <notmuch@notmuchmail.org>;\r
17         Thu, 30 May 2013 07:33:32 -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 938CE431FAE\r
22         for <notmuch@notmuchmail.org>; Thu, 30 May 2013 07:33:32 -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 1Ui3ut-0002P3-1l; Thu, 30 May 2013 15:33:28 +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 1Ui3us-0000lS-7O; Thu, 30 May 2013 15:33:22 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH v2 0/5] emacs: Part command improvements\r
34 In-Reply-To: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
35 References: <1369876428-13537-1-git-send-email-amdragon@mit.edu>\r
36 User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1\r
37         (i486-pc-linux-gnu)\r
38 Date: Thu, 30 May 2013 15:33:21 +0100\r
39 Message-ID: <87k3mgh70u.fsf@qmul.ac.uk>\r
40 MIME-Version: 1.0\r
41 Content-Type: text/plain; charset=us-ascii\r
42 X-Sender-Host-Address: 93.97.24.31\r
43 X-QM-SPAM-Info: Sender has good ham record.  :)\r
44 X-QM-Body-MD5: 754b925b7f2ccd33a9a4934d587db674 (of first 20000 bytes)\r
45 X-SpamAssassin-Score: -0.1\r
46 X-SpamAssassin-SpamBar: /\r
47 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
48         determine if it is\r
49         spam. We require at least 5.0 points to mark a message as spam.\r
50         This message scored -0.1 points.\r
51         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.1 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: Thu, 30 May 2013 14:33:41 -0000\r
69 \r
70 \r
71 This looks excellent. +1 from me.\r
72 \r
73 Best wishes\r
74 \r
75 Mark\r
76 \r
77 \r
78 Austin Clements <amdragon@MIT.EDU> writes:\r
79 \r
80 > This is v2 of id:87zjvghx82.fsf@qmul.ac.uk.  In addition to some\r
81 > general improvements, this fixes the handling of part overlays in\r
82 > indented messages, removes the special part button map entirely in\r
83 > favor of the "." submap, and adds a NEWS patch.\r
84 >\r
85 > The diff from v1 follows\r
86 >\r
87 > diff --git a/NEWS b/NEWS\r
88 > index a7f2ec6..23f4c6a 100644\r
89 > --- a/NEWS\r
90 > +++ b/NEWS\r
91 > @@ -61,6 +61,22 @@ notmuch-vim, but of course that is their decision.\r
92 >  Emacs Interface\r
93 >  ---------------\r
94 >  \r
95 > +New keymap to view/save parts\r
96 > +\r
97 > +  To view or save a single MIME part of a message, use the new "."\r
98 > +  submap (e.g., ". s" to save, ". v" to view).  Previously, these keys\r
99 > +  were only available when point was on a part button and they did not\r
100 > +  have the "." prefix, so they were difficult to invoke (impossible if\r
101 > +  a part did not have a button) and clashed with other bindings.\r
102 > +  These new bindings also appear in show's help, so you don't have to\r
103 > +  memorize them.\r
104 > +\r
105 > +Default part save directory is now `mm-default-directory`\r
106 > +\r
107 > +  Previously, notmuch offered to save parts and attachments to a mix\r
108 > +  of `mm-default-directory`, `mailcap-download-directory`, and `~/`.\r
109 > +  This has been standardized on `mm-default-directory`.\r
110 > +\r
111 >  No Emacs 22 support\r
112 >  \r
113 >    The Emacs 22 support added late 2010 was sufficient only for a short\r
114 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
115 > index 09ce25e..2186783 100644\r
116 > --- a/emacs/notmuch-lib.el\r
117 > +++ b/emacs/notmuch-lib.el\r
118 > @@ -360,21 +360,17 @@ OBJECT."\r
119 >     below\r
120 >     string))\r
121 >  \r
122 > -(defun notmuch-put-text-property-if-nil (start end property value\r
123 > -                                            &optional object)\r
124 > -  "Like `put-text-property', but only set the property where it is nil."\r
125 > +(defun notmuch-map-text-property (start end prop func &optional object)\r
126 > +  "Transform text property PROP using FUNC.\r
127 > +\r
128 > +Applies FUNC to each distinct value of the text property PROP\r
129 > +between START and END of OBJECT, setting PROP to the value\r
130 > +returned by FUNC."\r
131 >    (while (< start end)\r
132 > -    (let ((start-nil (text-property-any start end property nil object)))\r
133 > -      (if (null start-nil)\r
134 > -       ;; There are no more nil regions; exit the loop\r
135 > -       (setq start end)\r
136 > -     ;; Find the end of the nil region\r
137 > -     (let ((end-nil\r
138 > -            (or (text-property-not-all start-nil end property nil object)\r
139 > -                end)))\r
140 > -       ;; Set the property\r
141 > -       (put-text-property start-nil end-nil property value object)\r
142 > -       (setq start end-nil))))))\r
143 > +    (let ((value (get-text-property start prop object))\r
144 > +       (next (next-single-property-change start prop object end)))\r
145 > +      (put-text-property start next prop (funcall func value) object)\r
146 > +      (setq start next))))\r
147 >  \r
148 >  (defun notmuch-logged-error (msg &optional extra)\r
149 >    "Log MSG and EXTRA to *Notmuch errors* and signal MSG.\r
150 > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
151 > index 380b144..613e666 100644\r
152 > --- a/emacs/notmuch-show.el\r
153 > +++ b/emacs/notmuch-show.el\r
154 > @@ -466,7 +466,6 @@ message at DEPTH in the current thread."\r
155 >  \r
156 >  (define-button-type 'notmuch-show-part-button-type\r
157 >    'action 'notmuch-show-part-button-default\r
158 > -  'keymap 'notmuch-show-part-button-map\r
159 >    'follow-link t\r
160 >    'face 'message-mml\r
161 >    :supertype 'notmuch-button-type)\r
162 > @@ -843,8 +842,15 @@ If HIDE is non-nil then initially hide this part."\r
163 >        (insert "\n"))\r
164 >      (notmuch-show-create-part-overlays msg beg (point) hide)\r
165 >      ;; Record part information.  Since we already inserted subparts,\r
166 > -    ;; don't override exiting :notmuch-part properties.\r
167 > -    (notmuch-put-text-property-if-nil beg (point) :notmuch-part part)))\r
168 > +    ;; don't override existing :notmuch-part properties.\r
169 > +    (notmuch-map-text-property beg (point) :notmuch-part\r
170 > +                            (lambda (v) (or v part)))\r
171 > +    ;; Make :notmuch-part front sticky and rear non-sticky so it stays\r
172 > +    ;; applied to the beginning of each line when we indent the message.\r
173 > +    (notmuch-map-text-property beg (point) 'front-sticky\r
174 > +                            (lambda (v) (pushnew :notmuch-part v)))\r
175 > +    (notmuch-map-text-property beg (point) 'rear-nonsticky\r
176 > +                            (lambda (v) (pushnew :notmuch-part v)))))\r
177 >  \r
178 >  (defun notmuch-show-insert-body (msg body depth)\r
179 >    "Insert the body BODY at depth DEPTH in the current thread."\r
180 > @@ -1194,11 +1200,6 @@ reset based on the original query."\r
181 >    "Submap for part commands")\r
182 >  (fset 'notmuch-show-part-map notmuch-show-part-map)\r
183 >  \r
184 > -(defvar notmuch-show-part-button-map\r
185 > -  (make-composed-keymap notmuch-show-part-map button-map)\r
186 > -  "Keymap for part button commands")\r
187 > -(fset 'notmuch-show-part-button-map notmuch-show-part-button-map)\r
188 > -\r
189 >  (defvar notmuch-show-mode-map\r
190 >        (let ((map (make-sparse-keymap)))\r
191 >       (define-key map "?" 'notmuch-help)\r
192 > @@ -1365,7 +1366,7 @@ Some useful entries are:\r
193 >      (get-text-property (point) :notmuch-message-properties)))\r
194 >  \r
195 >  (defun notmuch-show-get-part-properties ()\r
196 > -  "Return the properties of the part containing point.\r
197 > +  "Return the properties of the innermost part containing point.\r
198 >  \r
199 >  This is the part property list retrieved from the CLI.  Signals\r
200 >  an error if there is no part containing point."\r