1 Return-Path: <markwalters1009@gmail.com>
\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 1785E431FC2
\r
6 for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 13:12:15 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id e6pOaAATsk7h for <notmuch@notmuchmail.org>;
\r
18 Tue, 22 Apr 2014 13:12:11 -0700 (PDT)
\r
19 Received: from mail-we0-f175.google.com (mail-we0-f175.google.com
\r
20 [74.125.82.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id CB391431FC0
\r
23 for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 13:12:08 -0700 (PDT)
\r
24 Received: by mail-we0-f175.google.com with SMTP id q58so5386031wes.6
\r
25 for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 13:12:07 -0700 (PDT)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:in-reply-to:references;
\r
28 bh=sdOSw48NlKn58XcRkyvgYWg0Cvs0tiX6J93UPY4P8fQ=;
\r
29 b=sQggZF54V2YGczbd+YPbtNcTEYZQn53xB57+sc/f8MkET+DrhnNRBR1+nlW2oWl4ly
\r
30 wM07alRy7IdbKkysHowTIyXkp0DAlge0aL53O9A/X8rT7biZLQEepQ3HXKph/Lqk733Y
\r
31 KpZXjawhckT5e6MsS5+NwfgoTjUFc6HRreF5DWZH1iNMa/yKr4Pdtj7bVzfqRT3BdK/z
\r
32 LJMB6LrnOCW4lJR9L2gT3eSENiQyzUtisz71WEmD3hulr82kue6aZZFHpTlUgR2SpUGZ
\r
33 IJ5p5v0sJXPQXN9lqmEJLVIjOHaS2ydWn2rbl6rySq3ygx6ofoAdrbNCtB8FFT2WwrPS
\r
35 X-Received: by 10.180.78.225 with SMTP id e1mr20532843wix.17.1398197527525;
\r
36 Tue, 22 Apr 2014 13:12:07 -0700 (PDT)
\r
37 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
\r
38 by mx.google.com with ESMTPSA id
\r
39 lj15sm24552802wic.13.2014.04.22.13.12.06 for <multiple recipients>
\r
40 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
41 Tue, 22 Apr 2014 13:12:07 -0700 (PDT)
\r
42 From: Mark Walters <markwalters1009@gmail.com>
\r
43 To: notmuch@notmuchmail.org
\r
44 Subject: [WIP PATCH 2/4] emacs: search: add a marked thread variable and add
\r
45 to relevant functions
\r
46 Date: Tue, 22 Apr 2014 21:11:48 +0100
\r
47 Message-Id: <1398197510-28224-3-git-send-email-markwalters1009@gmail.com>
\r
48 X-Mailer: git-send-email 1.7.10.4
\r
49 In-Reply-To: <1398197510-28224-1-git-send-email-markwalters1009@gmail.com>
\r
50 References: <1398197510-28224-1-git-send-email-markwalters1009@gmail.com>
\r
51 X-BeenThere: notmuch@notmuchmail.org
\r
52 X-Mailman-Version: 2.1.13
\r
54 List-Id: "Use and development of the notmuch mail system."
\r
55 <notmuch.notmuchmail.org>
\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
59 List-Post: <mailto:notmuch@notmuchmail.org>
\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
63 X-List-Received-Date: Tue, 22 Apr 2014 20:12:15 -0000
\r
65 Add a marked thread variable containing a list of thread ids of marked
\r
66 threads and make it be passed through all relevant functions. This
\r
67 ends up being quite large as there are quite a few callers.
\r
69 Alternatively we could overload beg rather than adding a thread-list
\r
70 variable. This would make a much smaller patch but might be more
\r
73 emacs/notmuch.el | 66 +++++++++++++++++++++++++++++++-----------------------
\r
74 1 file changed, 38 insertions(+), 28 deletions(-)
\r
76 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
77 index cb7c006..7b06458 100644
\r
78 --- a/emacs/notmuch.el
\r
79 +++ b/emacs/notmuch.el
\r
80 @@ -100,6 +100,11 @@ (defcustom notmuch-init-file (locate-user-emacs-file "notmuch-config")
\r
81 (defvar notmuch-query-history nil
\r
82 "Variable to store minibuffer history for notmuch queries")
\r
84 +(defvar notmuch-search-marked-threads nil
\r
85 + "Buffer local list of marked threads")
\r
86 +(make-variable-buffer-local 'notmuch-search-marked-threads)
\r
87 +(put 'notmuch-search-marked-threads 'permanent-local t)
\r
89 (defun notmuch-foreach-mime-part (function mm-handle)
\r
90 (cond ((stringp (car mm-handle))
\r
91 (dolist (part (cdr mm-handle))
\r
92 @@ -375,7 +380,7 @@ (defun notmuch-search-result-end (&optional pos)
\r
93 (next-single-property-change (or pos (point)) 'notmuch-search-result
\r
96 -(defun notmuch-search-foreach-result (beg end function)
\r
97 +(defun notmuch-search-foreach-result (beg end thread-list function)
\r
98 "Invoke FUNCTION for each result between BEG and END.
\r
100 FUNCTION should take no arguments. It will be applied at the
\r
101 @@ -400,9 +405,9 @@ (defun notmuch-search-foreach-result (beg end function)
\r
102 ;; the indentation of callers doesn't get out of hand.
\r
103 (put 'notmuch-search-foreach-result 'lisp-indent-function 2)
\r
105 -(defun notmuch-search-properties-in-region (property beg end)
\r
106 +(defun notmuch-search-properties-in-region (property beg end &optional thread-list)
\r
108 - (notmuch-search-foreach-result beg end
\r
109 + (notmuch-search-foreach-result beg end thread-list
\r
111 (push (plist-get (notmuch-search-get-result) property) output)))
\r
113 @@ -421,13 +426,13 @@ (defun notmuch-search-find-stable-query ()
\r
114 matched and unmatched messages in the current thread."
\r
115 (plist-get (notmuch-search-get-result) :query))
\r
117 -(defun notmuch-search-find-stable-query-region (beg end &optional only-matched)
\r
118 +(defun notmuch-search-find-stable-query-region (beg end &optional only-matched thread-list)
\r
119 "Return the stable query for the current region.
\r
121 If ONLY-MATCHED is non-nil, include only matched messages. If it
\r
122 is nil, include both matched and unmatched messages."
\r
123 (let ((query-list nil) (all (not only-matched)))
\r
124 - (dolist (queries (notmuch-search-properties-in-region :query beg end))
\r
125 + (dolist (queries (notmuch-search-properties-in-region :query beg end thread-list))
\r
126 (when (first queries)
\r
127 (push (first queries) query-list))
\r
128 (when (and all (second queries))
\r
129 @@ -438,17 +443,17 @@ (defun notmuch-search-find-authors ()
\r
130 "Return the authors for the current thread"
\r
131 (plist-get (notmuch-search-get-result) :authors))
\r
133 -(defun notmuch-search-find-authors-region (beg end)
\r
134 +(defun notmuch-search-find-authors-region (beg end &optional thread-list)
\r
135 "Return a list of authors for the current region"
\r
136 - (notmuch-search-properties-in-region :authors beg end))
\r
137 + (notmuch-search-properties-in-region :authors beg end thread-list))
\r
139 (defun notmuch-search-find-subject ()
\r
140 "Return the subject for the current thread"
\r
141 (plist-get (notmuch-search-get-result) :subject))
\r
143 -(defun notmuch-search-find-subject-region (beg end)
\r
144 +(defun notmuch-search-find-subject-region (beg end &optional thread-list)
\r
145 "Return a list of authors for the current region"
\r
146 - (notmuch-search-properties-in-region :subject beg end))
\r
147 + (notmuch-search-properties-in-region :subject beg end thread-list))
\r
149 (defun notmuch-search-show-thread (&optional elide-toggle)
\r
150 "Display the currently selected thread."
\r
151 @@ -497,9 +502,9 @@ (defun notmuch-search-set-tags (tags &optional pos)
\r
152 (defun notmuch-search-get-tags (&optional pos)
\r
153 (plist-get (notmuch-search-get-result pos) :tags))
\r
155 -(defun notmuch-search-get-tags-region (beg end)
\r
156 +(defun notmuch-search-get-tags-region (beg end &optional thread-list)
\r
158 - (notmuch-search-foreach-result beg end
\r
159 + (notmuch-search-foreach-result beg end thread-list
\r
161 (setq output (append output (notmuch-search-get-tags)))))
\r
163 @@ -507,24 +512,29 @@ (defun notmuch-search-get-tags-region (beg end)
\r
164 (defun notmuch-search-interactive-region ()
\r
165 "Return the bounds of the current interactive region.
\r
167 -This returns (BEG END), where BEG and END are the bounds of the
\r
168 -region if the region is active, or both `point' otherwise."
\r
169 +This returns (BEG END THREAD-LIST), where BEG and END are the
\r
170 +bounds of the region if the region is active, or both `point'
\r
171 +otherwise and THREAD-LIST is a list of the marked threads (if
\r
173 (if (region-active-p)
\r
174 - (list (region-beginning) (region-end))
\r
175 - (list (point) (point))))
\r
176 + (list (region-beginning) (region-end) notmuch-search-marked-threads)
\r
177 + (list (point) (point) notmuch-search-marked-threads)))
\r
179 (defun notmuch-search-interactive-tag-changes (&optional initial-input)
\r
180 - "Prompt for tag changes for the current thread or region.
\r
181 + "Prompt for tag changes for the current thread, marked threads or region.
\r
183 -Returns (TAG-CHANGES REGION-BEGIN REGION-END)."
\r
184 +Returns (TAG-CHANGES REGION-BEGIN REGION-END THREAD-LIST)."
\r
185 (let* ((region (notmuch-search-interactive-region))
\r
186 (beg (first region)) (end (second region))
\r
187 - (prompt (if (= beg end) "Tag thread" "Tag region")))
\r
188 + (thread-list (third region))
\r
189 + (prompt (if thread-list
\r
190 + "Tag marked threads"
\r
191 + (if (= beg end) "Tag thread" "Tag region"))))
\r
192 (cons (notmuch-read-tag-changes
\r
193 - (notmuch-search-get-tags-region beg end) prompt initial-input)
\r
194 + (notmuch-search-get-tags-region beg end thread-list) prompt initial-input)
\r
197 -(defun notmuch-search-tag (tag-changes &optional beg end only-matched)
\r
198 +(defun notmuch-search-tag (tag-changes &optional beg end only-matched thread-list)
\r
199 "Change tags for the currently selected thread or region.
\r
201 See `notmuch-tag' for information on the format of TAG-CHANGES.
\r
202 @@ -537,30 +547,30 @@ (defun notmuch-search-tag (tag-changes &optional beg end only-matched)
\r
203 (interactive (notmuch-search-interactive-tag-changes))
\r
204 (unless (and beg end) (setq beg (point) end (point)))
\r
205 (let ((search-string (notmuch-search-find-stable-query-region
\r
206 - beg end only-matched)))
\r
207 + beg end only-matched thread-list)))
\r
208 (notmuch-tag search-string tag-changes)
\r
209 - (notmuch-search-foreach-result beg end
\r
210 + (notmuch-search-foreach-result beg end thread-list
\r
212 (notmuch-search-set-tags
\r
213 (notmuch-update-tags (notmuch-search-get-tags) tag-changes))))))
\r
215 -(defun notmuch-search-add-tag (tag-changes &optional beg end)
\r
216 +(defun notmuch-search-add-tag (tag-changes &optional beg end thread-list)
\r
217 "Change tags for the current thread or region (defaulting to add).
\r
219 Same as `notmuch-search-tag' but sets initial input to '+'."
\r
220 (interactive (notmuch-search-interactive-tag-changes "+"))
\r
221 - (notmuch-search-tag tag-changes beg end))
\r
222 + (notmuch-search-tag tag-changes beg end nil thread-list))
\r
224 -(defun notmuch-search-remove-tag (tag-changes &optional beg end)
\r
225 +(defun notmuch-search-remove-tag (tag-changes &optional beg end thread-list)
\r
226 "Change tags for the current thread or region (defaulting to remove).
\r
228 Same as `notmuch-search-tag' but sets initial input to '-'."
\r
229 (interactive (notmuch-search-interactive-tag-changes "-"))
\r
230 - (notmuch-search-tag tag-changes beg end))
\r
231 + (notmuch-search-tag tag-changes beg end nil thread-list))
\r
233 (put 'notmuch-search-archive-thread 'notmuch-prefix-doc
\r
234 "Un-archive the currently selected thread.")
\r
235 -(defun notmuch-search-archive-thread (&optional unarchive beg end)
\r
236 +(defun notmuch-search-archive-thread (&optional unarchive beg end thread-list)
\r
237 "Archive the currently selected thread or region.
\r
239 Archive each message in the currently selected thread by applying
\r
240 @@ -573,7 +583,7 @@ (defun notmuch-search-archive-thread (&optional unarchive beg end)
\r
241 (interactive (cons current-prefix-arg (notmuch-search-interactive-region)))
\r
242 (when notmuch-archive-tags
\r
243 (notmuch-search-tag
\r
244 - (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end))
\r
245 + (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end thread-list))
\r
246 (notmuch-search-next-thread))
\r
248 (defun notmuch-search-update-result (result &optional pos)
\r