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 F0C30431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 09:38:48 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 4o5mNdoT9Efr for <notmuch@notmuchmail.org>;
\r
17 Thu, 26 Jan 2012 09:38:48 -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 D26BE431FAE
\r
22 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 09:38:47 -0800 (PST)
\r
23 Received: by bkbzt19 with SMTP id zt19so782544bkb.26
\r
24 for <notmuch@notmuchmail.org>; Thu, 26 Jan 2012 09:38:46 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=from:to:cc:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type;
\r
28 bh=ReMARUJ4gzWk4MV6FccgllYy/jiz6t48loU540xRPBk=;
\r
29 b=iIvM7gzK9Ya5rL1StzU5EFWHb/TO5s/pKvTXmdynFNCmIHL8GwUvSHDuJisDNYllXv
\r
30 E9TegGNely0aBhOS/l9rN+vB3jW0+7TnJINRV2A4fLWpTwSDUEBBlUQePdTXhl5F2Hzh
\r
31 bOJrTFmM+vjmhEcJVgXZ/wxQCL2TtmUB3gJgc=
\r
32 Received: by 10.205.128.133 with SMTP id he5mr1480834bkc.17.1327599526492;
\r
33 Thu, 26 Jan 2012 09:38:46 -0800 (PST)
\r
34 Received: from localhost ([91.144.186.21])
\r
35 by mx.google.com with ESMTPS id z15sm7456782bkd.7.2012.01.26.09.38.45
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Thu, 26 Jan 2012 09:38:45 -0800 (PST)
\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
39 To: Austin Clements <amdragon@MIT.EDU>
\r
40 Subject: Re: [PATCH v4] emacs: add completion to "tag all" operation ("*"
\r
42 In-Reply-To: <20120126070439.GC1940@mit.edu>
\r
43 References: <1327540351-5249-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
44 <1327554400-7616-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
45 <20120126070439.GC1940@mit.edu>
\r
46 User-Agent: Notmuch/0.11+116~ge6e10b8 (http://notmuchmail.org) Emacs/23.3.1
\r
47 (x86_64-pc-linux-gnu)
\r
48 Date: Thu, 26 Jan 2012 21:37:38 +0400
\r
49 Message-ID: <87y5su8ivx.fsf@gmail.com>
\r
51 Content-Type: text/plain; charset=us-ascii
\r
52 Cc: notmuch@notmuchmail.org
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Thu, 26 Jan 2012 17:38:49 -0000
\r
67 On Thu, 26 Jan 2012 02:04:39 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
\r
68 > Quoth Dmitry Kurochkin on Jan 26 at 9:06 am:
\r
69 > > The patch adds <tab> completion to "tag all" operation bound to "*"
\r
70 > > (`notmuch-search-operate-all' function).
\r
73 > > On a second thought, `notmuch-select-tag-with-completion' should never
\r
74 > > need `prefixes' argument at all. So I reverted the API and related
\r
81 > > * do not change `notmuch-select-tag-with-completion' API, revert
\r
86 > > * fixed comments from Austin's review [1]
\r
90 > > * s/thistag/this_tag/ for consistency with "that_tag", since we touch
\r
96 > > [1] id:"20120126013727.GB1176@mit.edu"
\r
98 > > emacs/notmuch.el | 53 ++++++++++++++++++++++++++++++++++++++++-------------
\r
99 > > 1 files changed, 40 insertions(+), 13 deletions(-)
\r
101 > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
102 > > index e02966f..d2af630 100644
\r
103 > > --- a/emacs/notmuch.el
\r
104 > > +++ b/emacs/notmuch.el
\r
105 > > @@ -48,6 +48,7 @@
\r
106 > > ;; required, but is available from http://notmuchmail.org).
\r
108 > > (eval-when-compile (require 'cl))
\r
109 > > +(require 'crm)
\r
110 > > (require 'mm-view)
\r
111 > > (require 'message)
\r
113 > > @@ -75,12 +76,36 @@ For example:
\r
114 > > (defvar notmuch-query-history nil
\r
115 > > "Variable to store minibuffer history for notmuch queries")
\r
117 > > -(defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
118 > > +(defun notmuch-tag-completions (&optional prefixes search-terms)
\r
119 > > (let ((tag-list
\r
120 > > (with-output-to-string
\r
121 > > (with-current-buffer standard-output
\r
122 > > (apply 'call-process notmuch-command nil t nil "search-tags" search-terms)))))
\r
123 > > - (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))
\r
124 > > + (setq tag-list (split-string tag-list "\n+" t))
\r
126 > Since this setq is unconditional, you can do the split-string right in
\r
127 > the let binding, around the with-output-to-string.
\r
130 I was thinking about it, but decided to use `setq', to make the diff
\r
131 smaller and the let binding simpler. Changed in v5.
\r
133 > > + (if (null prefixes)
\r
135 > > + (apply #'append
\r
136 > > + (mapcar (lambda (tag)
\r
137 > > + (mapcar (lambda (prefix)
\r
138 > > + (concat prefix tag)) prefixes))
\r
139 > > + tag-list)))))
\r
141 > > +(defun notmuch-select-tag-with-completion (prompt &rest search-terms)
\r
142 > > + (let ((tag-list (notmuch-tag-completions nil search-terms)))
\r
143 > > + (completing-read prompt tag-list)))
\r
145 > > +(defun notmuch-select-tags-with-completion (prompt &optional prefixes &rest search-terms)
\r
146 > > + (let ((tag-list (notmuch-tag-completions prefixes search-terms))
\r
147 > > + (crm-separator " ")
\r
148 > > + (crm-local-completion-map
\r
149 > > + (let ((map (make-sparse-keymap)))
\r
150 > > + (set-keymap-parent map crm-local-completion-map)
\r
152 > > + ;; By default, space is bound to "complete word" function.
\r
153 > > + ;; Re-bind it to insert a space instead. Note that <tab> still
\r
154 > > + ;; does the completion.
\r
155 > > + (define-key crm-local-completion-map " " 'self-insert-command)
\r
157 > You could do the define-key inside the (let ((map ..)) ..) so you get
\r
158 > back the fully formed keymap. Your call.
\r
161 Good point. Changed in v5.
\r
163 > > + (completing-read-multiple prompt tag-list)))
\r
165 > > (defun notmuch-foreach-mime-part (function mm-handle)
\r
166 > > (cond ((stringp (car mm-handle))
\r
167 > > @@ -849,7 +874,7 @@ non-authors is found, assume that all of the authors match."
\r
168 > > (goto-char found-target)))
\r
169 > > (delete-process proc))))
\r
171 > > -(defun notmuch-search-operate-all (action)
\r
172 > > +(defun notmuch-search-operate-all (&rest actions)
\r
173 > > "Add/remove tags from all matching messages.
\r
175 > > This command adds or removes tags from all messages matching the
\r
176 > > @@ -860,16 +885,18 @@ will prompt for tags to be added or removed. Tags prefixed with
\r
177 > > Each character of the tag name may consist of alphanumeric
\r
178 > > characters as well as `_.+-'.
\r
180 > > - (interactive "sOperation (+add -drop): notmuch tag ")
\r
181 > > - (let ((action-split (split-string action " +")))
\r
182 > > - ;; Perform some validation
\r
183 > > - (let ((words action-split))
\r
184 > > - (when (null words) (error "No operation given"))
\r
186 > > - (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
\r
187 > > - (error "Action must be of the form `+thistag -that_tag'"))
\r
188 > > - (setq words (cdr words))))
\r
189 > > - (apply 'notmuch-tag notmuch-search-query-string action-split)))
\r
190 > > + (interactive (notmuch-select-tags-with-completion
\r
191 > > + "Operations (+add -drop): notmuch tag "
\r
193 > > + (setq actions (delete "" actions))
\r
195 > Either this line isn't necessary or
\r
196 > notmuch-select-tags-with-completion can do something funny that it
\r
197 > should take care of internally.
\r
200 It is necessary and it belongs to `notmuch-select-tags-with-completion',
\r
201 thanks. Changed in v5.
\r
206 > > + ;; Perform some validation
\r
207 > > + (let ((words actions))
\r
208 > > + (when (null words) (error "No operations given"))
\r
210 > > + (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
\r
211 > > + (error "Action must be of the form `+this_tag' or `-that_tag'"))
\r
212 > > + (setq words (cdr words))))
\r
213 > > + (apply 'notmuch-tag notmuch-search-query-string actions))
\r
215 > > (defun notmuch-search-buffer-title (query)
\r
216 > > "Returns the title for a buffer with notmuch search results."
\r