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 B3E39431FAE
\r
6 for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 17:22:31 -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 JuWa5BY8Ep22 for <notmuch@notmuchmail.org>;
\r
16 Tue, 22 Oct 2013 17:22:26 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (dmz-mailsec-scanner-5.mit.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id 11059429E29
\r
20 for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 17:22:09 -0700 (PDT)
\r
21 X-AuditID: 12074422-b7f5a8e000000a34-11-526716b0867f
\r
22 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id AF.C5.02612.0B617625; Tue, 22 Oct 2013 20:22:08 -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 r9N0M5gN027447;
\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 r9N0M3ir005837
\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-0008KE-N2; 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 2/8] emacs: Take prompt and current tags in
\r
41 `notmuch-read-tag-changes'
\r
42 Date: Tue, 22 Oct 2013 20:21:55 -0400
\r
43 Message-Id: <1382487721-31776-3-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+NgFtrNIsWRmVeSWpSXmKPExsUixCmqrbtBLD3IoOukscXquTwW12/OZHZg
\r
49 8tg56y67x7NVt5gDmKK4bFJSczLLUov07RK4Mvqm9jMXTJepWPP/DHMD4wTxLkZODgkBE4kN
\r
50 LYdYIWwxiQv31rN1MXJxCAnsY5RY/bKdCcLZyCjxe8MGdgjnDpNE348NLCAtQgJzGSXau9RA
\r
51 bDYBDYlt+5czgtgiAtISO+/OBhvLLOAo8Xn/IjYQW1ggUmLXx6dAcQ4OFgFViY6uMJAwr4CD
\r
52 xN6bfcwQVyhJLDy1DayVE6j1zY4PbBCrHCSm7DzDMoGRfwEjwypG2ZTcKt3cxMyc4tRk3eLk
\r
53 xLy81CJdU73czBK91JTSTYygMGJ3UdrB+POg0iFGAQ5GJR7eBy1pQUKsiWXFlbmHGCU5mJRE
\r
54 edX504OE+JLyUyozEosz4otKc1KLDzFKcDArifA2+wKV86YkVlalFuXDpKQ5WJTEeW9x2AcJ
\r
55 CaQnlqRmp6YWpBbBZGU4OJQkeLtEgYYKFqWmp1akZeaUIKSZODhBhvMADV8BUsNbXJCYW5yZ
\r
56 DpE/xagoJc57BiQhAJLIKM2D64XF+StGcaBXhCHaeYApAq77FdBgJqDBU5aAXF1ckoiQkmpg
\r
57 TDiQemLmi8mpC5/b75Ofr9u91ZzRfQNv7emL2z86nV3rGXLlmOIGvyTOlcfFnznoXd+qvX39
\r
58 2XSLp8bC+TavzBsybzOZshnyTT/9tVnBUf/R7jcLGzdlPz7EYLb0nnu9cbNRbY/LqQO7nYvf
\r
59 rd2/NXxO0jNNl0gfdYeCZW2R+cb7rh3cGLjlhBJLcUaioRZzUXEiAMhRcr3OAgAA
\r
60 X-BeenThere: notmuch@notmuchmail.org
\r
61 X-Mailman-Version: 2.1.13
\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:32 -0000
\r
74 This modifies the interface of `notmuch-read-tag-changes' to take an
\r
75 optional prompt string as well as a list of existing tags instead of a
\r
76 query. This list of tags is used to populate the tag removal
\r
77 completions and lets the caller compute these in a more
\r
78 efficient/consistent manner than performing a potentially large or
\r
79 complex query. This patch also updates the sole current caller of
\r
80 `notmuch-read-tag-changes'.
\r
82 emacs/notmuch-tag.el | 29 ++++++++++++++++++++---------
\r
83 1 file changed, 20 insertions(+), 9 deletions(-)
\r
85 diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
\r
86 index 064cfa8..3ad53b2 100644
\r
87 --- a/emacs/notmuch-tag.el
\r
88 +++ b/emacs/notmuch-tag.el
\r
89 @@ -188,7 +188,10 @@ the messages that were tagged"
\r
90 "Variable to store minibuffer history for
\r
91 `notmuch-read-tag-changes' function.")
\r
93 -(defun notmuch-tag-completions (&optional search-terms)
\r
94 +(defun notmuch-tag-completions (&rest search-terms)
\r
95 + "Return a list of tags for messages matching SEARCH-TERMS.
\r
97 +Returns all tags if no search terms are given."
\r
98 (if (null search-terms)
\r
99 (setq search-terms (list "*")))
\r
101 @@ -199,17 +202,24 @@ the messages that were tagged"
\r
104 (defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
105 - (let ((tag-list (notmuch-tag-completions search-terms)))
\r
106 + (let ((tag-list (apply #'notmuch-tag-completions search-terms)))
\r
107 (completing-read prompt tag-list nil nil nil 'notmuch-select-tag-history)))
\r
109 -(defun notmuch-read-tag-changes (&optional initial-input &rest search-terms)
\r
110 +(defun notmuch-read-tag-changes (current-tags &optional prompt initial-input)
\r
111 + "Prompt for tag changes in the minibuffer.
\r
113 +CURRENT-TAGS is a list of tags that are present on the message or
\r
114 +messages to be changed. These are offered as tag removal
\r
115 +completions. CURRENT-TAGS may contain duplicates. PROMPT, if
\r
116 +non-nil, is the query string to present in the minibuffer. It
\r
117 +defaults to \"Tags\". INITIAL-INPUT, if non-nil, will be the
\r
118 +initial input in the minibuffer."
\r
120 (let* ((all-tag-list (notmuch-tag-completions))
\r
121 (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))
\r
122 - (remove-tag-list (mapcar (apply-partially 'concat "-")
\r
123 - (if (null search-terms)
\r
125 - (notmuch-tag-completions search-terms))))
\r
126 + (remove-tag-list (mapcar (apply-partially 'concat "-") current-tags))
\r
127 (tag-list (append add-tag-list remove-tag-list))
\r
128 + (prompt (concat (or prompt "Tags") " (+add -drop): "))
\r
129 (crm-separator " ")
\r
130 ;; By default, space is bound to "complete word" function.
\r
131 ;; Re-bind it to insert a space instead. Note that <tab>
\r
132 @@ -219,7 +229,7 @@ the messages that were tagged"
\r
133 (set-keymap-parent map crm-local-completion-map)
\r
134 (define-key map " " 'self-insert-command)
\r
136 - (delete "" (completing-read-multiple "Tags (+add -drop): "
\r
137 + (delete "" (completing-read-multiple prompt
\r
138 tag-list nil nil initial-input
\r
139 'notmuch-read-tag-changes-history))))
\r
141 @@ -260,7 +270,8 @@ notmuch-after-tag-hook will be run."
\r
142 ;; Perform some validation
\r
143 (if (string-or-null-p tag-changes)
\r
144 (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))
\r
145 - (setq tag-changes (notmuch-read-tag-changes tag-changes query))
\r
146 + (setq tag-changes (notmuch-read-tag-changes
\r
147 + (notmuch-tag-completions query) nil tag-changes))
\r
148 (setq tag-changes (list tag-changes))))
\r
149 (mapc (lambda (tag-change)
\r
150 (unless (string-match-p "^[-+]\\S-+$" tag-change)
\r