Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 89 / d1a8273c4b502b37b6c8e18fc593ff8df45c46
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 B7455429E35\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:24 -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 0JfpifREDQeO for <notmuch@notmuchmail.org>;\r
16         Tue, 22 Oct 2013 12:51:19 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 93524431E64\r
20         for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:08 -0700 (PDT)\r
21 X-AuditID: 1209190e-b7f828e0000009cf-1f-5266d72a22e8\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id B2.0E.02511.A27D6625; Tue, 22 Oct 2013 15:51: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 r9MJp3Rm030253; \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 r9MJp1wi005194\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-0006yi-Oc; 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 3/8] emacs: Use interactive specifications for tag changes in\r
40         show\r
41 Date: Tue, 22 Oct 2013 15:50:52 -0400\r
42 Message-Id: <1382471457-26056-4-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+NgFtrAIsWRmVeSWpSXmKPExsUixCmqrat1PS3IYOdNFYvrN2cyOzB6PFt1\r
48         izmAMYrLJiU1J7MstUjfLoEr48A2s4IHMhU3X/1la2D8Lt7FyMkhIWAi8eL5BmYIW0ziwr31\r
49         bF2MXBxCAvsYJZa/aYByNjJK7L93hAmkSkjgGJPEq68hEIm5jBJ/fn4FS7AJaEhs27+cEcQW\r
50         EZCW2Hl3NmsXIwcHs4CaxJ8uFZCwsECQxLSzi8BKWARUJdbu2sQCYvMKOEgc2LuFEeIKJYmF\r
51         p7axgticAo4S0/f9YwMZIwRUc+oOxwRG/gWMDKsYZVNyq3RzEzNzilOTdYuTE/PyUot0jfVy\r
52         M0v0UlNKNzGCA0aSbwfj14NKhxgFOBiVeHgt2tOChFgTy4orcw8xSnIwKYnyRlwFCvEl5adU\r
53         ZiQWZ8QXleakFh9ilOBgVhLhbfYFyvGmJFZWpRblw6SkOViUxHlvctgHCQmkJ5akZqemFqQW\r
54         wWRlODiUJHgfgQwVLEpNT61Iy8wpQUgzcXCCDOcBGn4MpIa3uCAxtzgzHSJ/ilFRSpx3CUhC\r
55         ACSRUZoH1wuL6FeM4kCvCEO08wCTAVz3K6DBTECDpywBG1ySiJCSamDMyN75NvaGvJPDtSsq\r
56         Ed9nbld4u1N1nkB6cUeb+qp1P2OcTL8Ls6tdEZJ7XZGl3PpslyenqdH0Z9vf9RptX9v2/I1T\r
57         9S4WuR3NP+ZUzFM7o3FxdYbxu4dWe3+mJkzI0b/xQuvtWRndMxv+xJvUXT71sVeOsZeJ86HY\r
58         C+tJs1K+ndqzYvqqrQzaSizFGYmGWsxFxYkAetusnsMCAAA=\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\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:25 -0000\r
72 \r
73 This modifies all tagging operations in show to call\r
74 `notmuch-read-tag-changes' in their interactive specification to input\r
75 tag changes, rather than depending on lower-level functions to prompt\r
76 for tag changes regardless of their calling context.\r
77 \r
78 Besides being more Elispy and providing a more consistent programmatic\r
79 API, this enables callers to provide two call site-specific pieces of\r
80 information: an appropriate prompt, and the set of visible tags.  The\r
81 prompt lets us differentiate * from +/-.  Providing visible tags\r
82 enables a more consistent user experience than retrieving the\r
83 (potentially different) tags from the database, and avoids a\r
84 round-trip to the CLI and database.\r
85 ---\r
86  emacs/notmuch-show.el | 34 +++++++++++++++++++++-------------\r
87  1 file changed, 21 insertions(+), 13 deletions(-)\r
88 \r
89 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
90 index 7325792..ef77839 100644\r
91 --- a/emacs/notmuch-show.el\r
92 +++ b/emacs/notmuch-show.el\r
93 @@ -1780,23 +1780,29 @@ TAG-CHANGES is a list of tag operations for `notmuch-tag'."\r
94        (notmuch-tag (notmuch-show-get-message-id) tag-changes)\r
95        (notmuch-show-set-tags new-tags))))\r
96  \r
97 -(defun notmuch-show-tag (&optional tag-changes)\r
98 +(defun notmuch-show-tag (tag-changes)\r
99    "Change tags for the current message.\r
100  \r
101  See `notmuch-tag' for information on the format of TAG-CHANGES."\r
102 -  (interactive)\r
103 -  (let* ((tag-changes (notmuch-tag (notmuch-show-get-message-id) tag-changes))\r
104 -        (current-tags (notmuch-show-get-tags))\r
105 +  (interactive (list (notmuch-read-tag-changes (notmuch-show-get-tags)\r
106 +                                              "Tag message")))\r
107 +  (notmuch-tag (notmuch-show-get-message-id) tag-changes)\r
108 +  (let* ((current-tags (notmuch-show-get-tags))\r
109          (new-tags (notmuch-update-tags current-tags tag-changes)))\r
110      (unless (equal current-tags new-tags)\r
111        (notmuch-show-set-tags new-tags))))\r
112  \r
113 -(defun notmuch-show-tag-all (&optional tag-changes)\r
114 +(defun notmuch-show-tag-all (tag-changes)\r
115    "Change tags for all messages in the current show buffer.\r
116  \r
117  See `notmuch-tag' for information on the format of TAG-CHANGES."\r
118 -  (interactive)\r
119 -  (setq tag-changes (notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes))\r
120 +  (interactive\r
121 +   (list (let (tags)\r
122 +          (notmuch-show-mapc\r
123 +           (lambda () (setq tags (append (notmuch-show-get-tags) tags))))\r
124 +          (delete-dups tags)\r
125 +          (notmuch-read-tag-changes tags "Tag thread"))))\r
126 +  (notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)\r
127    (notmuch-show-mapc\r
128     (lambda ()\r
129       (let* ((current-tags (notmuch-show-get-tags))\r
130 @@ -1804,19 +1810,21 @@ See `notmuch-tag' for information on the format of TAG-CHANGES."\r
131         (unless (equal current-tags new-tags)\r
132          (notmuch-show-set-tags new-tags))))))\r
133  \r
134 -(defun notmuch-show-add-tag ()\r
135 +(defun notmuch-show-add-tag (tag-changes)\r
136    "Change tags for the current message (defaulting to add).\r
137  \r
138  Same as `notmuch-show-tag' but sets initial input to '+'."\r
139 -  (interactive)\r
140 -  (notmuch-show-tag "+"))\r
141 +  (interactive\r
142 +   (list (notmuch-read-tag-changes (notmuch-show-get-tags) "Tag message" "+")))\r
143 +  (notmuch-show-tag tag-changes))\r
144  \r
145 -(defun notmuch-show-remove-tag ()\r
146 +(defun notmuch-show-remove-tag (tag-changes)\r
147    "Change tags for the current message (defaulting to remove).\r
148  \r
149  Same as `notmuch-show-tag' but sets initial input to '-'."\r
150 -  (interactive)\r
151 -  (notmuch-show-tag "-"))\r
152 +  (interactive\r
153 +   (list (notmuch-read-tag-changes (notmuch-show-get-tags) "Tag message" "-")))\r
154 +  (notmuch-show-tag tag-changes))\r
155  \r
156  (defun notmuch-show-toggle-visibility-headers ()\r
157    "Toggle the visibility of the current message headers."\r
158 -- \r
159 1.8.4.rc3\r
160 \r