--- /dev/null
+Return-Path: <markwalters1009@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 4C7FC431FC3\r
+ for <notmuch@notmuchmail.org>; Fri, 14 Feb 2014 01:15:58 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 5yoPKUTCT1sO for <notmuch@notmuchmail.org>;\r
+ Fri, 14 Feb 2014 01:15:52 -0800 (PST)\r
+Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com\r
+ [209.85.212.172]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id DA4C3431FAE\r
+ for <notmuch@notmuchmail.org>; Fri, 14 Feb 2014 01:15:36 -0800 (PST)\r
+Received: by mail-wi0-f172.google.com with SMTP id e4so250829wiv.5\r
+ for <notmuch@notmuchmail.org>; Fri, 14 Feb 2014 01:15:35 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=jgTuoGDRLVGeqvCm1pXe6eINyEJNe87IgtL0xzTC82c=;\r
+ b=UZ06rYhGAkd0zL8UR5qYHbqnBrUg4h+b+lhXgJPbnbsB6YtqvnqQnbVa2VLK91H4+E\r
+ 0gtL/x3IKLbrHpjNq6+6LsBVVWa083ZpmJz7euPYp8a6QtEAEtG2TkjlkQcxLX5UeqXm\r
+ ITPq9MkPuMQ8ScbMa6KsAdPvYu7g8NCtVj/zMgtonBmni6XtDCJVfI/UA1/ZqCt0Nh+B\r
+ Le9cu4n4YNczTf+gZv8c2c2p+yQk8VV54qLL4DXOXB5kt+G7EOALnLLKZH9NE1h/BbB5\r
+ ZGlbqM6Vd9W9K4azRguPjihDYDg6E3Vyir1xGt6fNL2SrTEqcmMFWBWaEUxQK1zhlRCb\r
+ i8xw==\r
+X-Received: by 10.194.119.230 with SMTP id kx6mr3297974wjb.13.1392369335761;\r
+ Fri, 14 Feb 2014 01:15:35 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id v6sm2462420wif.0.2014.02.14.01.15.35\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Fri, 14 Feb 2014 01:15:35 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org,\r
+ Austin Clements <amdragon@MIT.EDU>\r
+Subject: [WIP Patch 6/7] emacs: search: use orig-tags in search\r
+Date: Fri, 14 Feb 2014 09:15:18 +0000\r
+Message-Id: <1392369319-24508-7-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1392369319-24508-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1392369319-24508-1-git-send-email-markwalters1009@gmail.com>\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: Fri, 14 Feb 2014 09:15:58 -0000\r
+\r
+This uses the recent functionality to show the tag changes in the\r
+search buffer. Currently this is only used to show changes the search\r
+buffer makes itself: i.e., it does not make display any changes\r
+reflecting tagging done by other notmuch-buffers.\r
+---\r
+ emacs/notmuch.el | 40 ++++++++++++++++++++++++----------------\r
+ 1 files changed, 24 insertions(+), 16 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 1436e5a..f07b216 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -753,24 +753,32 @@ non-authors is found, assume that all of the authors match."\r
+ format-string (notmuch-sanitize (plist-get result :authors))))\r
+ \r
+ ((string-equal field "tags")\r
+- (let ((tags (plist-get result :tags)))\r
+- (insert (format format-string (notmuch-tag-format-tags tags tags)))))))\r
++ (let ((tags (plist-get result :tags))\r
++ (orig-tags (plist-get result :orig-tags)))\r
++ (insert (format format-string (notmuch-tag-format-tags tags orig-tags)))))))\r
+ \r
+-(defun notmuch-search-show-result (result &optional pos)\r
+- "Insert RESULT at POS or the end of the buffer if POS is null."\r
++(defun notmuch-search-show-result (result beg)\r
++ "Insert RESULT at BEG."\r
+ ;; Ignore excluded matches\r
+ (unless (= (plist-get result :matched) 0)\r
+- (let ((beg (or pos (point-max))))\r
+- (save-excursion\r
+- (goto-char beg)\r
+- (dolist (spec notmuch-search-result-format)\r
+- (notmuch-search-insert-field (car spec) (cdr spec) result))\r
+- (insert "\n")\r
+- (notmuch-search-color-line beg (point) (plist-get result :tags))\r
+- (put-text-property beg (point) 'notmuch-search-result result))\r
+- (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
+- (setq notmuch-search-target-thread "found")\r
+- (goto-char beg)))))\r
++ (save-excursion\r
++ (goto-char beg)\r
++ (dolist (spec notmuch-search-result-format)\r
++ (notmuch-search-insert-field (car spec) (cdr spec) result))\r
++ (insert "\n")\r
++ (notmuch-search-color-line beg (point) (plist-get result :tags))\r
++ (put-text-property beg (point) 'notmuch-search-result result))\r
++ (when (string= (plist-get result :thread) notmuch-search-target-thread)\r
++ (setq notmuch-search-target-thread "found")\r
++ (goto-char beg))))\r
++\r
++(defun notmuch-search-append-result (result)\r
++ "Insert RESULT at the end of the buffer.\r
++\r
++This is only called when a result is first inserted so it also\r
++sets the :orig-tag property."\r
++ (plist-put result :orig-tags (plist-get result :tags))\r
++ (notmuch-search-show-result result (point-max)))\r
+ \r
+ (defun notmuch-search-process-filter (proc string)\r
+ "Process and filter the output of \"notmuch search\""\r
+@@ -784,7 +792,7 @@ non-authors is found, assume that all of the authors match."\r
+ (save-excursion\r
+ (goto-char (point-max))\r
+ (insert string))\r
+- (notmuch-sexp-parse-partial-list 'notmuch-search-show-result\r
++ (notmuch-sexp-parse-partial-list 'notmuch-search-append-result\r
+ results-buf)))))\r
+ \r
+ (defun notmuch-search-tag-all (tag-changes)\r
+-- \r
+1.7.9.1\r
+\r