--- /dev/null
+Return-Path: <amdragon@mit.edu>\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 5296C429E34\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:18 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 FbcMHZGpI7nK for <notmuch@notmuchmail.org>;\r
+ Tue, 22 Oct 2013 12:51:12 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
+ [18.7.68.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 4B553431FDE\r
+ for <notmuch@notmuchmail.org>; Tue, 22 Oct 2013 12:51:07 -0700 (PDT)\r
+X-AuditID: 12074424-b7f528e0000009aa-96-5266d7286083\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id C7.D9.02474.827D6625; Tue, 22 Oct 2013 15:51:05 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id r9MJp3AB015068; \r
+ Tue, 22 Oct 2013 15:51:04 -0400\r
+Received: from drake.dyndns.org (31-33-57.wireless.csail.mit.edu\r
+ [128.31.33.57]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r9MJp1no005192\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Tue, 22 Oct 2013 15:51:03 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1VYhym-0006yf-NX; Tue, 22 Oct 2013 15:51:00 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/8] emacs: Take prompt and current tags in\r
+ `notmuch-read-tag-changes'\r
+Date: Tue, 22 Oct 2013 15:50:51 -0400\r
+Message-Id: <1382471457-26056-3-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.8.4.rc3\r
+In-Reply-To: <1382471457-26056-1-git-send-email-amdragon@mit.edu>\r
+References: <1382471457-26056-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsUixCmqrKt5PS3IYP8uRovrN2cyOzB6PFt1\r
+ izmAMYrLJiU1J7MstUjfLoEro7/pFHPBP8mKFT83MTYwLhftYuTkkBAwkfi/p50dwhaTuHBv\r
+ PVsXIxeHkMA+RolnO+czQzgbGSXWdl+GyhxjkpjZcJQJwpnLKPHw6QywfjYBDYlt+5czgtgi\r
+ AtISO+/OZu1i5OBgFlCT+NOlAhIWFgiTeHB0DlgJi4CqxIal38BaeQUcJF51rGGGOENJYuGp\r
+ bawgNqeAo8T0ff/YQMYIAdWcusMxgZF/ASPDKkbZlNwq3dzEzJzi1GTd4uTEvLzUIl1zvdzM\r
+ Er3UlNJNjKCgYXdR2cHYfEjpEKMAB6MSD++DlrQgIdbEsuLK3EOMkhxMSqK8EVeBQnxJ+SmV\r
+ GYnFGfFFpTmpxYcYJTiYlUR4m32BcrwpiZVVqUX5MClpDhYlcd5bHPZBQgLpiSWp2ampBalF\r
+ MFkZDg4lCV6ha0CNgkWp6akVaZk5JQhpJg5OkOE8QMOPgSzmLS5IzC3OTIfIn2JUlBLnFQZp\r
+ FgBJZJTmwfXCovoVozjQK8K8DiBVPMCEANf9CmgwE9DgKUvABpckIqSkGhi1PD67b+Qq9hfo\r
+ /FrZeifReEZF5bKynutdq60mC15SmOctcp6xPWCbgA3XB+/7c/IsrvvcvL1q2/nP6tKbctJ1\r
+ Dhoeq+SQOv5430vVgy84fI5WX4tOOKTOdb+5rUho5ZqbocsbX7FIxX370aOZslukm7nlgu4t\r
+ 6bm5TKX10vkGUy3eK93if6jEUpyRaKjFXFScCADGglDCxQIAAA==\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: Tue, 22 Oct 2013 19:51:18 -0000\r
+\r
+This modifies the interface of `notmuch-read-tag-changes' to take an\r
+optional prompt string as well as a list of existing tags instead of a\r
+query. This list of tags is used to populate the tag removal\r
+completions and lets the caller compute these in a more\r
+efficient/consistent manner than performing a potentially large or\r
+complex query. This patch also updates the sole current caller of\r
+`notmuch-read-tag-changes'.\r
+---\r
+ emacs/notmuch-tag.el | 24 ++++++++++++++++--------\r
+ 1 file changed, 16 insertions(+), 8 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el\r
+index 064cfa8..f9c1740 100644\r
+--- a/emacs/notmuch-tag.el\r
++++ b/emacs/notmuch-tag.el\r
+@@ -188,7 +188,7 @@ the messages that were tagged"\r
+ "Variable to store minibuffer history for\r
+ `notmuch-read-tag-changes' function.")\r
+ \r
+-(defun notmuch-tag-completions (&optional search-terms)\r
++(defun notmuch-tag-completions (&rest search-terms)\r
+ (if (null search-terms)\r
+ (setq search-terms (list "*")))\r
+ (split-string\r
+@@ -202,14 +202,21 @@ the messages that were tagged"\r
+ (let ((tag-list (notmuch-tag-completions search-terms)))\r
+ (completing-read prompt tag-list nil nil nil 'notmuch-select-tag-history)))\r
+ \r
+-(defun notmuch-read-tag-changes (&optional initial-input &rest search-terms)\r
++(defun notmuch-read-tag-changes (current-tags &optional prompt initial-input)\r
++ "Prompt for tag changes in the minibuffer.\r
++\r
++CURRENT-TAGS is a list of tags that are present on the message or\r
++messages to be changed. These are offered as tag removal\r
++completions. CURRENT-TAGS may contain duplicates. PROMPT, if\r
++non-nil, is the query string to present in the minibuffer. It\r
++defaults to \"Tags\". INITIAL-INPUT, if non-nil, will be the\r
++initial input in the minibuffer."\r
++\r
+ (let* ((all-tag-list (notmuch-tag-completions))\r
+ (add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))\r
+- (remove-tag-list (mapcar (apply-partially 'concat "-")\r
+- (if (null search-terms)\r
+- all-tag-list\r
+- (notmuch-tag-completions search-terms))))\r
++ (remove-tag-list (mapcar (apply-partially 'concat "-") current-tags))\r
+ (tag-list (append add-tag-list remove-tag-list))\r
++ (prompt (concat (or prompt "Tags") " (+add -drop): "))\r
+ (crm-separator " ")\r
+ ;; By default, space is bound to "complete word" function.\r
+ ;; Re-bind it to insert a space instead. Note that <tab>\r
+@@ -219,7 +226,7 @@ the messages that were tagged"\r
+ (set-keymap-parent map crm-local-completion-map)\r
+ (define-key map " " 'self-insert-command)\r
+ map)))\r
+- (delete "" (completing-read-multiple "Tags (+add -drop): "\r
++ (delete "" (completing-read-multiple prompt\r
+ tag-list nil nil initial-input\r
+ 'notmuch-read-tag-changes-history))))\r
+ \r
+@@ -260,7 +267,8 @@ notmuch-after-tag-hook will be run."\r
+ ;; Perform some validation\r
+ (if (string-or-null-p tag-changes)\r
+ (if (or (string= tag-changes "-") (string= tag-changes "+") (null tag-changes))\r
+- (setq tag-changes (notmuch-read-tag-changes tag-changes query))\r
++ (setq tag-changes (notmuch-read-tag-changes\r
++ (notmuch-tag-completions query) nil tag-changes))\r
+ (setq tag-changes (list tag-changes))))\r
+ (mapc (lambda (tag-change)\r
+ (unless (string-match-p "^[-+]\\S-+$" tag-change)\r
+-- \r
+1.8.4.rc3\r
+\r