Re: Hi all
[notmuch-archives.git] / 67 / 99f13dae02e6de6a4eb4ce23a9f462013b0b40
1 Return-Path: <dmitry.kurochkin@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 33666431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 23:15:29 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] 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 YcX2iICcIfgX for <notmuch@notmuchmail.org>;\r
17         Sat,  4 Feb 2012 23:15:26 -0800 (PST)\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 090F6431FBD\r
22         for <notmuch@notmuchmail.org>; Sat,  4 Feb 2012 23:15:25 -0800 (PST)\r
23 Received: by mail-bk0-f53.google.com with SMTP id 11so4650313bke.26\r
24         for <notmuch@notmuchmail.org>; Sat, 04 Feb 2012 23:15:25 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=iw5X6IRHB9kRJqk0kUC/6uFY/gwRrswLXwUe20s6Xxw=;\r
28         b=JVGIRjLf8zhuy9RJ4h6FlwTvD84l/xYkP7TVv8020KWAo5c1IS306n9WIxj/VYGWfL\r
29         khOzq04b95R8NDAZp1PRFGxTttjvbIUptV+pDESciKmr+pSgd9PKJS6gBB9rQtJKOcyS\r
30         5HctYpgF7E5gBN1XIJ8jDySKSvoTVn2JKvoZE=\r
31 Received: by 10.204.156.155 with SMTP id x27mr6275814bkw.4.1328426125696;\r
32         Sat, 04 Feb 2012 23:15:25 -0800 (PST)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id bw9sm33010948bkb.8.2012.02.04.23.15.24\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Sat, 04 Feb 2012 23:15:25 -0800 (PST)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v5 04/12] emacs: make "+" and "-" tagging operations in\r
40         notmuch-show more flexible\r
41 Date: Sun,  5 Feb 2012 11:13:45 +0400\r
42 Message-Id: <1328426033-21480-5-git-send-email-dmitry.kurochkin@gmail.com>\r
43 X-Mailer: git-send-email 1.7.9\r
44 In-Reply-To: <1328426033-21480-1-git-send-email-dmitry.kurochkin@gmail.com>\r
45 References: <1327725684-5887-1-git-send-email-dmitry.kurochkin@gmail.com>\r
46         <1328426033-21480-1-git-send-email-dmitry.kurochkin@gmail.com>\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Sun, 05 Feb 2012 07:15:29 -0000\r
60 \r
61 Before the change, "+" and "-" tagging operations in notmuch-show view\r
62 accepted only a single tag.  The patch makes them use the recently\r
63 added `notmuch-read-tag-changes' function, which allows to enter\r
64 multiple tags with "+" and "-" prefixes.  So after the change, "+" and\r
65 "-" bindings in notmuch-show view allow to both add and remove\r
66 multiple tags.  The only difference between "+" and "-" is the\r
67 minibuffer initial input ("+" and "-" respectively).\r
68 ---\r
69  emacs/notmuch-show.el |   73 +++++++++++++++++-------------------------------\r
70  1 files changed, 26 insertions(+), 47 deletions(-)\r
71 \r
72 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
73 index 7469e2e..48a2a60 100644\r
74 --- a/emacs/notmuch-show.el\r
75 +++ b/emacs/notmuch-show.el\r
76 @@ -38,9 +38,10 @@\r
77  \r
78  (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))\r
79  (declare-function notmuch-fontify-headers "notmuch" nil)\r
80 -(declare-function notmuch-select-tag-with-completion "notmuch" (prompt &rest search-terms))\r
81 +(declare-function notmuch-read-tag-changes "notmuch" (&optional initial-input &rest search-terms))\r
82  (declare-function notmuch-search-next-thread "notmuch" nil)\r
83  (declare-function notmuch-search-show-thread "notmuch" nil)\r
84 +(declare-function notmuch-update-tags "notmuch" (current-tags tag-changes))\r
85  \r
86  (defcustom notmuch-message-headers '("Subject" "To" "Cc" "Date")\r
87    "Headers that should be shown in a message, in this order.\r
88 @@ -1282,7 +1283,7 @@ Some useful entries are:\r
89  \r
90  (defun notmuch-show-mark-read ()\r
91    "Mark the current message as read."\r
92 -  (notmuch-show-remove-tag "unread"))\r
93 +  (notmuch-show-tag-message "-unread"))\r
94  \r
95  ;; Functions for getting attributes of several messages in the current\r
96  ;; thread.\r
97 @@ -1495,51 +1496,32 @@ than only the current message."\r
98             (message (format "Command '%s' exited abnormally with code %d"\r
99                              shell-command exit-code))))))))\r
100  \r
101 -(defun notmuch-show-add-tags-worker (current-tags add-tags)\r
102 -  "Add to `current-tags' with any tags from `add-tags' not\r
103 -currently present and return the result."\r
104 -  (let ((result-tags (copy-sequence current-tags)))\r
105 -    (mapc (lambda (add-tag)\r
106 -           (unless (member add-tag current-tags)\r
107 -             (setq result-tags (push add-tag result-tags))))\r
108 -           add-tags)\r
109 -    (sort result-tags 'string<)))\r
110 -\r
111 -(defun notmuch-show-del-tags-worker (current-tags del-tags)\r
112 -  "Remove any tags in `del-tags' from `current-tags' and return\r
113 -the result."\r
114 -  (let ((result-tags (copy-sequence current-tags)))\r
115 -    (mapc (lambda (del-tag)\r
116 -           (setq result-tags (delete del-tag result-tags)))\r
117 -         del-tags)\r
118 -    result-tags))\r
119 -\r
120 -(defun notmuch-show-add-tag (&rest toadd)\r
121 -  "Add a tag to the current message."\r
122 -  (interactive\r
123 -   (list (notmuch-select-tag-with-completion "Tag to add: ")))\r
124 +(defun notmuch-show-tag-message (&rest tag-changes)\r
125 +  "Change tags for the current message.\r
126  \r
127 +TAG-CHANGES is a list of tag operations for `notmuch-tag'."\r
128    (let* ((current-tags (notmuch-show-get-tags))\r
129 -        (new-tags (notmuch-show-add-tags-worker current-tags toadd)))\r
130 -\r
131 +        (new-tags (notmuch-update-tags current-tags tag-changes)))\r
132      (unless (equal current-tags new-tags)\r
133 -      (apply 'notmuch-tag (notmuch-show-get-message-id)\r
134 -            (mapcar (lambda (s) (concat "+" s)) toadd))\r
135 +      (apply 'notmuch-tag (notmuch-show-get-message-id) tag-changes)\r
136        (notmuch-show-set-tags new-tags))))\r
137  \r
138 -(defun notmuch-show-remove-tag (&rest toremove)\r
139 -  "Remove a tag from the current message."\r
140 -  (interactive\r
141 -   (list (notmuch-select-tag-with-completion\r
142 -         "Tag to remove: " (notmuch-show-get-message-id))))\r
143 +(defun notmuch-show-tag (&optional initial-input)\r
144 +  "Change tags for the current message, read input from the minibuffer."\r
145 +  (interactive)\r
146 +  (let ((tag-changes (notmuch-read-tag-changes\r
147 +                     initial-input (notmuch-show-get-message-id))))\r
148 +    (apply 'notmuch-show-tag-message tag-changes)))\r
149  \r
150 -  (let* ((current-tags (notmuch-show-get-tags))\r
151 -        (new-tags (notmuch-show-del-tags-worker current-tags toremove)))\r
152 +(defun notmuch-show-add-tag ()\r
153 +  "Same as `notmuch-show-tag' but sets initial input to '+'."\r
154 +  (interactive)\r
155 +  (notmuch-show-tag "+"))\r
156  \r
157 -    (unless (equal current-tags new-tags)\r
158 -      (apply 'notmuch-tag (notmuch-show-get-message-id)\r
159 -            (mapcar (lambda (s) (concat "-" s)) toremove))\r
160 -      (notmuch-show-set-tags new-tags))))\r
161 +(defun notmuch-show-remove-tag ()\r
162 +  "Same as `notmuch-show-tag' but sets initial input to '-'."\r
163 +  (interactive)\r
164 +  (notmuch-show-tag "-"))\r
165  \r
166  (defun notmuch-show-toggle-headers ()\r
167    "Toggle the visibility of the current message headers."\r
168 @@ -1587,10 +1569,8 @@ argument, hide all of the messages."\r
169  If the remove switch is given, tags will be removed instead of\r
170  added."\r
171    (goto-char (point-min))\r
172 -  (let ((tag-function (if remove\r
173 -                         'notmuch-show-remove-tag\r
174 -                       'notmuch-show-add-tag)))\r
175 -    (loop do (funcall tag-function tag)\r
176 +  (let ((op (if remove "-" "+")))\r
177 +    (loop do (notmuch-show-tag-message (concat op tag))\r
178           until (not (notmuch-show-goto-message-next)))))\r
179  \r
180  (defun notmuch-show-add-tag-thread (tag)\r
181 @@ -1653,9 +1633,8 @@ If a prefix argument is given, the message will be\r
182  \"unarchived\" (ie. the \"inbox\" tag will be added instead of\r
183  removed)."\r
184    (interactive "P")\r
185 -  (if unarchive\r
186 -      (notmuch-show-add-tag "inbox")\r
187 -    (notmuch-show-remove-tag "inbox")))\r
188 +  (let ((op (if unarchive "+" "-")))\r
189 +    (notmuch-show-tag-message (concat op "inbox"))))\r
190  \r
191  (defun notmuch-show-archive-message-then-next ()\r
192    "Archive the current message, then show the next open message in the current thread."\r
193 -- \r
194 1.7.9\r
195 \r