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 5C177431FD7
\r
6 for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:48 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 CAZ2u8zGdxJ3 for <notmuch@notmuchmail.org>;
\r
16 Tue, 22 Oct 2013 12:51:42 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 5D110429E32
\r
20 for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:17 -0700 (PDT)
\r
21 X-AuditID: 12074423-b7fc98e0000009a2-56-5266d7339018
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 28.6A.02466.337D6625; Tue, 22 Oct 2013 15:51:15 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])
\r
26 by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r9MJp39r030254;
\r
27 Tue, 22 Oct 2013 15:51:04 -0400
\r
28 Received: from drake.dyndns.org (31-33-57.wireless.csail.mit.edu
\r
29 [128.31.33.57]) (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 r9MJp17R005196
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Tue, 22 Oct 2013 15:51:03 -0400
\r
34 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1VYhym-0006yk-PV; Tue, 22 Oct 2013 15:51:00 -0400
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 4/8] emacs: Use interactive specifications for tag changes in
\r
41 Date: Tue, 22 Oct 2013 15:50:53 -0400
\r
42 Message-Id: <1382471457-26056-5-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.8.4.rc3
\r
44 In-Reply-To: <1382471457-26056-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1382471457-26056-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrWt8PS3IYMdeHovrN2cyOzB6PFt1
\r
48 izmAMYrLJiU1J7MstUjfLoEr48TsP0wFr7UqFi9qY2tgvKvcxcjJISFgIrHu6k4WCFtM4sK9
\r
49 9WxdjFwcQgL7GCX2b1vABOFsZJSYefY+K4RzjEniYs9/dghnLqPEyu9vmED62QQ0JLbtX84I
\r
50 YosISEvsvDsbqIODg1lATeJPlwpIWFggROJ0wyQ2EJtFQFWi+eJCZhCbV8BBorfvPBvEGUoS
\r
51 C09tYwWxOQUcJabv+8cGMkYIqObUHY4JjPwLGBlWMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Zrp
\r
52 5WaW6KWmlG5iBAUNu4vyDsY/B5UOMQpwMCrx8D5oSQsSYk0sK67MPcQoycGkJMobcRUoxJeU
\r
53 n1KZkVicEV9UmpNafIhRgoNZSYS32Rcox5uSWFmVWpQPk5LmYFES573FYR8kJJCeWJKanZpa
\r
54 kFoEk5Xh4FCS4BW6BtQoWJSanlqRlplTgpBm4uAEGc4DNPwYyGLe4oLE3OLMdIj8KUZFKXFe
\r
55 YZBmAZBERmkeXC8sql8xigO9IszLCVLFA0wIcN2vgAYzAQ2esgRscEkiQkoKGN36UvHzpvCw
\r
56 a5e6OMbp9UhWLnoStD+rlCVQSMdy/dPgyTZZIRbS6zb43j68vNgz0ObO6p1xC87xc0o6FTLu
\r
57 atdxZO7mqDng+pJdjf/ArgTbuCjmXwqZge0Kzh/sN733W7G02vyEseTbqZptfAU6RXWqrXl6
\r
58 2z/k5kzYpetxT+1UsdIegx9KLMUZiYZazEXFiQDnOcw0xQIAAA==
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Tue, 22 Oct 2013 19:51:48 -0000
\r
73 This is similar to the previous commit, but applies to search.
\r
75 Search is somewhat more complicated because its tagging operations can
\r
76 also apply to a region. Hence, this lifts interactive prompting into
\r
77 a helper function. This also takes advantage of the new ability to
\r
78 provide a prompt to distinguish tagging a single thread from tagging a
\r
81 emacs/notmuch.el | 70 +++++++++++++++++++++++++++++++++++---------------------
\r
82 1 file changed, 44 insertions(+), 26 deletions(-)
\r
84 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
85 index e0511c8..5492e1b 100644
\r
86 --- a/emacs/notmuch.el
\r
87 +++ b/emacs/notmuch.el
\r
88 @@ -560,43 +560,59 @@ will be signaled."
\r
89 (setq output (append output (notmuch-search-get-tags pos)))))
\r
92 -(defun notmuch-search-tag-region (beg end &optional tag-changes)
\r
93 - "Change tags for threads in the given region."
\r
94 +(defun notmuch-search-interactive-region ()
\r
95 + "Return the bounds of the current interactive region.
\r
97 +This returns (BEG END), where BEG and END are the bounds of the
\r
98 +region if the region is active, or both `point' otherwise."
\r
99 + (if (region-active-p)
\r
100 + (list (region-beginning) (region-end))
\r
101 + (list (point) (point))))
\r
103 +(defun notmuch-search-interactive-tag-changes (&optional initial-input)
\r
104 + "Prompt for tag changes for the current thread or region.
\r
106 +Returns (TAG-CHANGES REGION-BEGIN REGION-END)."
\r
107 + (let* ((region (notmuch-search-interactive-region))
\r
108 + (beg (first region)) (end (second region))
\r
109 + (prompt (if (= beg end) "Tag thread" "Tag region")))
\r
110 + (cons (notmuch-read-tag-changes
\r
111 + (notmuch-search-get-tags-region beg end) prompt initial-input)
\r
114 +(defun notmuch-search-tag (tag-changes &optional beg end)
\r
115 + "Change tags for the currently selected thread or region.
\r
117 +See `notmuch-tag' for information on the format of TAG-CHANGES.
\r
118 +If BEG or END are nil, applies to the thread at point."
\r
119 + (interactive (notmuch-search-interactive-tag-changes))
\r
120 + (unless (and beg end) (setq beg (point) end (point)))
\r
121 (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))
\r
122 - (setq tag-changes (notmuch-tag search-string tag-changes))
\r
123 + (notmuch-tag search-string tag-changes)
\r
124 (notmuch-search-foreach-result beg end
\r
126 (notmuch-search-set-tags
\r
127 (notmuch-update-tags (notmuch-search-get-tags pos) tag-changes)
\r
130 -(defun notmuch-search-tag (&optional tag-changes)
\r
131 - "Change tags for the currently selected thread or region.
\r
133 -See `notmuch-tag' for information on the format of TAG-CHANGES."
\r
135 - (let* ((beg (if (region-active-p) (region-beginning) (point)))
\r
136 - (end (if (region-active-p) (region-end) (point))))
\r
137 - (notmuch-search-tag-region beg end tag-changes)))
\r
139 -(defun notmuch-search-add-tag ()
\r
140 - "Change tags for the current thread (defaulting to add).
\r
141 +(defun notmuch-search-add-tag (tag-changes &optional beg end)
\r
142 + "Change tags for the current thread or region (defaulting to add).
\r
144 Same as `notmuch-search-tag' but sets initial input to '+'."
\r
146 - (notmuch-search-tag "+"))
\r
147 + (interactive (notmuch-search-interactive-tag-changes "+"))
\r
148 + (notmuch-search-tag tag-changes beg end))
\r
150 -(defun notmuch-search-remove-tag ()
\r
151 - "Change tags for the current thread (defaulting to remove).
\r
152 +(defun notmuch-search-remove-tag (tag-changes &optional beg end)
\r
153 + "Change tags for the current thread or region (defaulting to remove).
\r
155 Same as `notmuch-search-tag' but sets initial input to '-'."
\r
157 - (notmuch-search-tag "-"))
\r
158 + (interactive (notmuch-search-interactive-tag-changes "-"))
\r
159 + (notmuch-search-tag tag-changes beg end))
\r
161 (put 'notmuch-search-archive-thread 'notmuch-prefix-doc
\r
162 "Un-archive the currently selected thread.")
\r
163 -(defun notmuch-search-archive-thread (&optional unarchive)
\r
164 - "Archive the currently selected thread.
\r
165 +(defun notmuch-search-archive-thread (&optional unarchive beg end)
\r
166 + "Archive the currently selected thread or region.
\r
168 Archive each message in the currently selected thread by applying
\r
169 the tag changes in `notmuch-archive-tags' to each (remove the
\r
170 @@ -605,10 +621,10 @@ messages will be \"unarchived\" (i.e. the tag changes in
\r
171 `notmuch-archive-tags' will be reversed).
\r
173 This function advances the next thread when finished."
\r
174 - (interactive "P")
\r
175 + (interactive (cons current-prefix-arg (notmuch-search-interactive-region)))
\r
176 (when notmuch-archive-tags
\r
177 (notmuch-search-tag
\r
178 - (notmuch-tag-change-list notmuch-archive-tags unarchive)))
\r
179 + (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end))
\r
180 (notmuch-search-next-thread))
\r
182 (defun notmuch-search-update-result (result &optional pos)
\r
183 @@ -832,11 +848,13 @@ non-authors is found, assume that all of the authors match."
\r
184 (notmuch-sexp-parse-partial-list 'notmuch-search-show-result
\r
187 -(defun notmuch-search-tag-all (&optional tag-changes)
\r
188 +(defun notmuch-search-tag-all (tag-changes)
\r
189 "Add/remove tags from all messages in current search buffer.
\r
191 See `notmuch-tag' for information on the format of TAG-CHANGES."
\r
194 + (list (notmuch-read-tag-changes
\r
195 + (notmuch-search-get-tags-region (point-min) (point-max)) "Tag all")))
\r
196 (notmuch-tag notmuch-search-query-string tag-changes))
\r
198 (defun notmuch-search-buffer-title (query)
\r