--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id C47F0429E36\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 17:48:16 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id fmkQ864dweL6 for <notmuch@notmuchmail.org>;\r
+ Wed, 25 Jan 2012 17:48:16 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+ [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A122D431FBC\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 17:48:15 -0800 (PST)\r
+Received: by bkbzt19 with SMTP id zt19so58492bkb.26\r
+ for <notmuch@notmuchmail.org>; Wed, 25 Jan 2012 17:48:14 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+ :mime-version:content-type;\r
+ bh=cc7FxKkN6l/j5Slz/O1TDbAZncZmvmZbi1uoIifqatQ=;\r
+ b=JLEt4+8Z2n+XOVcgmNll+kBPJ6+DhOmUxtSD9VXvPh9UiT2e/X8w3INAP6Whl4w0hp\r
+ odqgD/jmUKqTNeFyhczVfK3wrBB3HESbfi+AezCpipv+sl/FczO+vx8WvJE3YlKwyaI3\r
+ LUB+T4k8ivrIYzhs9d2MpIv1Kf2og/W7e7Jyo=\r
+Received: by 10.204.10.66 with SMTP id o2mr13126bko.104.1327542494267;\r
+ Wed, 25 Jan 2012 17:48:14 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id fb7sm5040552bkc.9.2012.01.25.17.48.13\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Wed, 25 Jan 2012 17:48:13 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: add completion to "tag all" operation ("*"\r
+ binding)\r
+In-Reply-To: <20120126013727.GB1176@mit.edu>\r
+References: <1327540351-5249-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+ <20120126013727.GB1176@mit.edu>\r
+User-Agent: Notmuch/0.11+116~ge6e10b8 (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Thu, 26 Jan 2012 05:47:07 +0400\r
+Message-ID: <87wr8fqlpg.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 26 Jan 2012 01:48:16 -0000\r
+\r
+On Wed, 25 Jan 2012 20:37:27 -0500, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> Neat. As an aside, I would love to see a prompt like this for + and\r
+> -, allowing multiple tags to be modified at once (and starting out\r
+> with whichever of + or - got you in to the prompt).\r
+> \r
+\r
+Yeah, I was thinking about making "+" and "-" accepting multiple tags\r
+using `notmuch-select-tags-with-completion'. But that is for another\r
+patch.\r
+\r
+> Quoth Dmitry Kurochkin on Jan 26 at 5:12 am:\r
+> > The patch adds <tab> completion to "tag all" operation bound to "*"\r
+> > (`notmuch-search-operate-all' function).\r
+> > ---\r
+> > emacs/notmuch.el | 48 ++++++++++++++++++++++++++++++++++++------------\r
+> > 1 files changed, 36 insertions(+), 12 deletions(-)\r
+> > \r
+> > diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+> > index e02966f..71b0221 100644\r
+> > --- a/emacs/notmuch.el\r
+> > +++ b/emacs/notmuch.el\r
+> > @@ -48,6 +48,7 @@\r
+> > ;; required, but is available from http://notmuchmail.org).\r
+> > \r
+> > (eval-when-compile (require 'cl))\r
+> > +(require 'crm)\r
+> > (require 'mm-view)\r
+> > (require 'message)\r
+> > \r
+> > @@ -75,12 +76,33 @@ For example:\r
+> > (defvar notmuch-query-history nil\r
+> > "Variable to store minibuffer history for notmuch queries")\r
+> > \r
+> > -(defun notmuch-select-tag-with-completion (prompt &rest search-terms)\r
+> > +(defun notmuch-tag-completions (&optional search-terms prefixes)\r
+> > (let ((tag-list\r
+> > (with-output-to-string\r
+> > (with-current-buffer standard-output\r
+> > (apply 'call-process notmuch-command nil t nil "search-tags" search-terms)))))\r
+> > - (completing-read prompt (split-string tag-list "\n+" t) nil nil nil)))\r
+> > + (setq tag-list (split-string tag-list "\n+" t))\r
+> > + (if (null prefixes)\r
+> > + tag-list\r
+> > + (apply #'append\r
+> > + (mapcar (lambda (tag)\r
+> > + (mapcar (lambda (prefix)\r
+> > + (concat prefix tag)) prefixes))\r
+> > + tag-list)))))\r
+> > +\r
+> > +(defun notmuch-select-tag-with-completion (prompt &optional search-terms prefixes)\r
+> \r
+> This changes the API of notmuch-select-tag-with-completion in a\r
+> non-backwards-compatible way. I'm pretty sure this breaks\r
+> notmuch-search-remove-tag and notmuch-show-remove-tag, but I haven't\r
+> tested it.\r
+> \r
+\r
+I tested only tag additions. It works, and I assumed tag removal is no\r
+different. Will fix.\r
+\r
+> > + (let ((tag-list (notmuch-tag-completions search-terms prefixes)))\r
+> > + (completing-read prompt tag-list)))\r
+> > +\r
+> > +(defun notmuch-select-tags-with-completion (prompt &optional search-terms prefixes)\r
+> > + (let ((tag-list (notmuch-tag-completions search-terms prefixes))\r
+> > + (crm-separator " ")\r
+> > + (crm-local-completion-map (copy-keymap crm-local-completion-map)))\r
+> \r
+> Alternatively, you could create a child keymap.\r
+> crm-local-completion-map is small enough that it probably doesn't\r
+> matter, so whatever makes the code clearer.\r
+> \r
+\r
+Thanks, I will look into it.\r
+\r
+> > + ;; By default, space is bound to "complete word" function.\r
+> > + ;; Re-bind it to insert a space instead. Note that <tab> still\r
+> > + ;; does the completion.\r
+> > + (define-key crm-local-completion-map " " 'self-insert-command)\r
+> > + (completing-read-multiple prompt tag-list)))\r
+> > \r
+> > (defun notmuch-foreach-mime-part (function mm-handle)\r
+> > (cond ((stringp (car mm-handle))\r
+> > @@ -860,16 +882,18 @@ will prompt for tags to be added or removed. Tags prefixed with\r
+> > Each character of the tag name may consist of alphanumeric\r
+> > characters as well as `_.+-'.\r
+> > "\r
+> \r
+> Technically this changes the API of notmuch-search-operate-all, though\r
+> the new one is better. Perhaps it should test for (stringp action)\r
+> and be backwards-compatible?\r
+> \r
+\r
+In this case, I do not think there are many users of the function. So I\r
+would prefer to keep the code clean.\r
+\r
+> The argument should probably be called "actions" now and it may even\r
+> make sense to make it a &rest argument (though then you can't make it\r
+> backwards-compatible).\r
+> \r
+\r
+Makes sense, will do.\r
+\r
+> > - (interactive "sOperation (+add -drop): notmuch tag ")\r
+> > - (let ((action-split (split-string action " +")))\r
+> > - ;; Perform some validation\r
+> > - (let ((words action-split))\r
+> > - (when (null words) (error "No operation given"))\r
+> > - (while words\r
+> > - (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))\r
+> > - (error "Action must be of the form `+thistag -that_tag'"))\r
+> > - (setq words (cdr words))))\r
+> > - (apply 'notmuch-tag notmuch-search-query-string action-split)))\r
+> > + (interactive (list (notmuch-select-tags-with-completion\r
+> > + "Operation (+add -drop): notmuch tag " nil\r
+> > + '("+" "-"))))\r
+> > + (setq action (delete "" action))\r
+> > + ;; Perform some validation\r
+> > + (let ((words action))\r
+> > + (when (null words) (error "No operation given"))\r
+> > + (while words\r
+> > + (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))\r
+> > + (error "Action must be of the form `+thistag -that_tag'"))\r
+> > + (setq words (cdr words))))\r
+> \r
+> This should really be a mapc or a dolist, but maybe that's for another\r
+> patch.\r
+> \r
+\r
+Yes, I changed "this_tag" spelling in v2, but would prefer to leave\r
+non-trivial changes in this code for another patch.\r
+\r
+Regards,\r
+ Dmitry\r
+\r
+> > + (apply 'notmuch-tag notmuch-search-query-string action))\r
+> > \r
+> > (defun notmuch-search-buffer-title (query)\r
+> > "Returns the title for a buffer with notmuch search results."\r