Re: [PATCH] create .mailmap file (for git shortlog/blame)
[notmuch-archives.git] / 7d / e9861fbf72345729f7df5533080eb836596a36
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 389A8429E35\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 17:22:15 -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 ErUFsnXHfZwJ for <notmuch@notmuchmail.org>;\r
16         Tue, 22 Oct 2013 17:22:07 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (dmz-mailsec-scanner-4.mit.edu\r
18         [18.9.25.15])\r
19         by olra.theworths.org (Postfix) with ESMTP id 25E79431FBC\r
20         for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 17:22:07 -0700 (PDT)\r
21 X-AuditID: 1209190f-b7fa08e0000009c6-a5-526716ae4fce\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id CC.A6.02502.EA617625; Tue, 22 Oct 2013 20:22:06 -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 r9N0M5AH027448; \r
27         Tue, 22 Oct 2013 20:22:05 -0400\r
28 Received: from drake.dyndns.org\r
29         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [216.15.114.40]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9N0M3t2005843\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Tue, 22 Oct 2013 20:22:04 -0400\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1VYmD5-0008KK-PF; Tue, 22 Oct 2013 20:22:03 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH v2 4/8] emacs: Use interactive specifications for tag changes\r
41         in search\r
42 Date: Tue, 22 Oct 2013 20:21:57 -0400\r
43 Message-Id: <1382487721-31776-5-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.8.4.rc3\r
45 In-Reply-To: <1382487721-31776-1-git-send-email-amdragon@mit.edu>\r
46 References: <1382487721-31776-1-git-send-email-amdragon@mit.edu>\r
47 X-Brightmail-Tracker:\r
48  H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixCmqrbtOLD3IYOk+dYvVc3ksrt+cyezA\r
49         5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZVxe3sVa0KhTcbnlGFMD4w2VLkZODgkBE4mu\r
50         1Y8ZIWwxiQv31rN1MXJxCAnsY5SYMmcxlLORUeLgldUsEM4dJomfRx5AZeYySvxeupwNpJ9N\r
51         QENi2/7lYLNEBKQldt6dzQpiMws4SnzevwisRlggXKJjWhdYDYuAqsTkv3uBajg4eAUcJGb+\r
52         M4E4Q0li4altYK2cQK1vdnwAaxUCKpmy8wzLBEb+BYwMqxhlU3KrdHMTM3OKU5N1i5MT8/JS\r
53         i3RN9HIzS/RSU0o3MYIDSZJ/B+O3g0qHGAU4GJV4eB+0pAUJsSaWFVfmHmKU5GBSEuVV508P\r
54         EuJLyk+pzEgszogvKs1JLT7EKMHBrCTC2+wLVM6bklhZlVqUD5OS5mBREue9yWEfJCSQnliS\r
55         mp2aWpBaBJOV4eBQkuBlAkaMkGBRanpqRVpmTglCmomDE2Q4D9BwZZAa3uKCxNzizHSI/ClG\r
56         RSlx3jOiQAkBkERGaR5cLyzSXzGKA70izPsMpIoHmCTgul8BDWYCGjxlCcjVxSWJCCmpBsa8\r
57         CPb3D3Ker3YKXbUgTv8gx4dX08P7zfIE3J8UhTy2tZ4gzsu3cUbJ/bo/NvpLgvw3SzFffTxF\r
58         cmnkSu4D73f/nxwxe3Jn/tf9ku5MXH3PuI67LJ1kbzVxykPT518m27E5T2mskPFjO6DOcL36\r
59         iejOz/w1bNW710SaTK/z27WE75/F9E8RS/qVWIozEg21mIuKEwFU8m84zwIAAA==\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Wed, 23 Oct 2013 00:22:15 -0000\r
73 \r
74 This is similar to the previous commit, but applies to search.\r
75 \r
76 Search is somewhat more complicated because its tagging operations can\r
77 also apply to a region.  Hence, this lifts interactive prompting into\r
78 a helper function.  This also takes advantage of the new ability to\r
79 provide a prompt to distinguish tagging a single thread from tagging a\r
80 region of threads.\r
81 ---\r
82  emacs/notmuch.el | 73 ++++++++++++++++++++++++++++++++++++--------------------\r
83  1 file changed, 47 insertions(+), 26 deletions(-)\r
84 \r
85 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
86 index e0511c8..53e9826 100644\r
87 --- a/emacs/notmuch.el\r
88 +++ b/emacs/notmuch.el\r
89 @@ -560,43 +560,62 @@ will be signaled."\r
90         (setq output (append output (notmuch-search-get-tags pos)))))\r
91      output))\r
92  \r
93 -(defun notmuch-search-tag-region (beg end &optional tag-changes)\r
94 -  "Change tags for threads in the given region."\r
95 +(defun notmuch-search-interactive-region ()\r
96 +  "Return the bounds of the current interactive region.\r
97 +\r
98 +This returns (BEG END), where BEG and END are the bounds of the\r
99 +region if the region is active, or both `point' otherwise."\r
100 +  (if (region-active-p)\r
101 +      (list (region-beginning) (region-end))\r
102 +    (list (point) (point))))\r
103 +\r
104 +(defun notmuch-search-interactive-tag-changes (&optional initial-input)\r
105 +  "Prompt for tag changes for the current thread or region.\r
106 +\r
107 +Returns (TAG-CHANGES REGION-BEGIN REGION-END)."\r
108 +  (let* ((region (notmuch-search-interactive-region))\r
109 +        (beg (first region)) (end (second region))\r
110 +        (prompt (if (= beg end) "Tag thread" "Tag region")))\r
111 +    (cons (notmuch-read-tag-changes\r
112 +          (notmuch-search-get-tags-region beg end) prompt initial-input)\r
113 +         region)))\r
114 +\r
115 +(defun notmuch-search-tag (tag-changes &optional beg end)\r
116 +  "Change tags for the currently selected thread or region.\r
117 +\r
118 +See `notmuch-tag' for information on the format of TAG-CHANGES.\r
119 +When called interactively, this uses the region if the region is\r
120 +active.  When called directly, BEG and END provide the region.\r
121 +If these are nil or not provided, this applies to the thread at\r
122 +point."\r
123 +  (interactive (notmuch-search-interactive-tag-changes))\r
124 +  (unless (and beg end) (setq beg (point) end (point)))\r
125    (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))\r
126 -    (setq tag-changes (notmuch-tag search-string tag-changes))\r
127 +    (notmuch-tag search-string tag-changes)\r
128      (notmuch-search-foreach-result beg end\r
129        (lambda (pos)\r
130         (notmuch-search-set-tags\r
131          (notmuch-update-tags (notmuch-search-get-tags pos) tag-changes)\r
132          pos)))))\r
133  \r
134 -(defun notmuch-search-tag (&optional tag-changes)\r
135 -  "Change tags for the currently selected thread or region.\r
136 -\r
137 -See `notmuch-tag' for information on the format of TAG-CHANGES."\r
138 -  (interactive)\r
139 -  (let* ((beg (if (region-active-p) (region-beginning) (point)))\r
140 -        (end (if (region-active-p) (region-end) (point))))\r
141 -    (notmuch-search-tag-region beg end tag-changes)))\r
142 -\r
143 -(defun notmuch-search-add-tag ()\r
144 -  "Change tags for the current thread (defaulting to add).\r
145 +(defun notmuch-search-add-tag (tag-changes &optional beg end)\r
146 +  "Change tags for the current thread or region (defaulting to add).\r
147  \r
148  Same as `notmuch-search-tag' but sets initial input to '+'."\r
149 -  (interactive)\r
150 -  (notmuch-search-tag "+"))\r
151 +  (interactive (notmuch-search-interactive-tag-changes "+"))\r
152 +  (notmuch-search-tag tag-changes beg end))\r
153  \r
154 -(defun notmuch-search-remove-tag ()\r
155 -  "Change tags for the current thread (defaulting to remove).\r
156 +(defun notmuch-search-remove-tag (tag-changes &optional beg end)\r
157 +  "Change tags for the current thread or region (defaulting to remove).\r
158  \r
159  Same as `notmuch-search-tag' but sets initial input to '-'."\r
160 -  (interactive)\r
161 -  (notmuch-search-tag "-"))\r
162 +  (interactive (notmuch-search-interactive-tag-changes "-"))\r
163 +  (notmuch-search-tag tag-changes beg end))\r
164  \r
165  (put 'notmuch-search-archive-thread 'notmuch-prefix-doc\r
166       "Un-archive the currently selected thread.")\r
167 -(defun notmuch-search-archive-thread (&optional unarchive)\r
168 -  "Archive the currently selected thread.\r
169 +(defun notmuch-search-archive-thread (&optional unarchive beg end)\r
170 +  "Archive the currently selected thread or region.\r
171  \r
172  Archive each message in the currently selected thread by applying\r
173  the tag changes in `notmuch-archive-tags' to each (remove the\r
174 @@ -605,10 +624,10 @@ messages will be \"unarchived\" (i.e. the tag changes in\r
175  `notmuch-archive-tags' will be reversed).\r
176  \r
177  This function advances the next thread when finished."\r
178 -  (interactive "P")\r
179 +  (interactive (cons current-prefix-arg (notmuch-search-interactive-region)))\r
180    (when notmuch-archive-tags\r
181      (notmuch-search-tag\r
182 -     (notmuch-tag-change-list notmuch-archive-tags unarchive)))\r
183 +     (notmuch-tag-change-list notmuch-archive-tags unarchive) beg end))\r
184    (notmuch-search-next-thread))\r
185  \r
186  (defun notmuch-search-update-result (result &optional pos)\r
187 @@ -832,11 +851,13 @@ non-authors is found, assume that all of the authors match."\r
188         (notmuch-sexp-parse-partial-list 'notmuch-search-show-result\r
189                                          results-buf)))))\r
190  \r
191 -(defun notmuch-search-tag-all (&optional tag-changes)\r
192 +(defun notmuch-search-tag-all (tag-changes)\r
193    "Add/remove tags from all messages in current search buffer.\r
194  \r
195  See `notmuch-tag' for information on the format of TAG-CHANGES."\r
196 -  (interactive)\r
197 +  (interactive\r
198 +   (list (notmuch-read-tag-changes\r
199 +         (notmuch-search-get-tags-region (point-min) (point-max)) "Tag all")))\r
200    (notmuch-tag notmuch-search-query-string tag-changes))\r
201  \r
202  (defun notmuch-search-buffer-title (query)\r
203 -- \r
204 1.8.4.rc3\r
205 \r