--- /dev/null
+Return-Path: <pieter@praet.org>\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 AD565429E2B\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Jul 2011 23:53:11 -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 bqE13AQQ0Q3E for <notmuch@notmuchmail.org>;\r
+ Sun, 3 Jul 2011 23:53:11 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+ [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 1F359431FD0\r
+ for <notmuch@notmuchmail.org>; Sun, 3 Jul 2011 23:53:10 -0700 (PDT)\r
+Received: by mail-wy0-f181.google.com with SMTP id 22so3733696wyh.26\r
+ for <notmuch@notmuchmail.org>; Sun, 03 Jul 2011 23:53:10 -0700 (PDT)\r
+Received: by 10.216.68.2 with SMTP id k2mr4294185wed.0.1309762390792;\r
+ Sun, 03 Jul 2011 23:53:10 -0700 (PDT)\r
+Received: from localhost ([109.131.160.67])\r
+ by mx.google.com with ESMTPS id ei4sm4224028wbb.60.2011.07.03.23.53.09\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sun, 03 Jul 2011 23:53:10 -0700 (PDT)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Austin Clements <amdragon@mit.edu>\r
+Subject: [PATCH 5/5] emacs: make `notmuch-search-operate-all' use\r
+ matched-msgids instead of the original query string\r
+Date: Mon, 4 Jul 2011 08:51:58 +0200\r
+Message-Id: <1309762318-4530-6-git-send-email-pieter@praet.org>\r
+X-Mailer: git-send-email 1.7.5.4\r
+In-Reply-To: <1309762318-4530-1-git-send-email-pieter@praet.org>\r
+References: <20110703171743.GL15901@mit.edu>\r
+ <1309762318-4530-1-git-send-email-pieter@praet.org>\r
+Cc: Notmuch Mail <notmuch@notmuchmail.org>\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: Mon, 04 Jul 2011 06:53:11 -0000\r
+\r
+Signed-off-by: Pieter Praet <pieter@praet.org>\r
+---\r
+ emacs/notmuch.el | 7 +++++--\r
+ 1 files changed, 5 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 46e276a..0d040a2 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -869,7 +869,10 @@ Each character of the tag name may consist of alphanumeric\r
+ characters as well as `_.+-'.\r
+ "\r
+ (interactive "sOperation (+add -drop): notmuch tag ")\r
+- (let ((action-split (split-string action " +")))\r
++ (let ((action-split (split-string action " +"))\r
++ (msgids (mapconcat 'identity\r
++ (notmuch-search-find-matched-msgids-region (point-min) (- (point-max) 2))\r
++ " or ")))\r
+ ;; Perform some validation\r
+ (let ((words action-split))\r
+ (when (null words) (error "No operation given"))\r
+@@ -877,7 +880,7 @@ characters as well as `_.+-'.\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
++ (apply 'notmuch-tag msgids action-split)))\r
+ \r
+ (defun notmuch-search-buffer-title (query)\r
+ "Returns the title for a buffer with notmuch search results."\r
+-- \r
+1.7.5.4\r
+\r