--- /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 A15E6429E26\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Jul 2012 14:42:55 -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 Wp1CQwayWa+R for <notmuch@notmuchmail.org>;\r
+ Mon, 9 Jul 2012 14:42:54 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+ [18.9.25.14])\r
+ by olra.theworths.org (Postfix) with ESMTP id 02331429E31\r
+ for <notmuch@notmuchmail.org>; Mon, 9 Jul 2012 14:42:50 -0700 (PDT)\r
+X-AuditID: 1209190e-b7fb56d0000008b2-57-4ffb5058ad69\r
+Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
+ by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id E6.51.02226.8505BFF4; Mon, 9 Jul 2012 17:42:48 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id q69Lglak030908; \r
+ Mon, 9 Jul 2012 17:42:47 -0400\r
+Received: from drake.dyndns.org (26-4-176.dynamic.csail.mit.edu [18.26.4.176])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q69LgiKb022685\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 9 Jul 2012 17:42:45 -0400 (EDT)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1SoLjA-0004fx-0l; Mon, 09 Jul 2012 17:42:44 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 4/9] emacs: Move search-target logic to\r
+ `notmuch-search-show-result'\r
+Date: Mon, 9 Jul 2012 17:42:37 -0400\r
+Message-Id: <1341870162-17782-5-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1341870162-17782-1-git-send-email-amdragon@mit.edu>\r
+References: <1341354059-29396-1-git-send-email-amdragon@mit.edu>\r
+ <1341870162-17782-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrKIsWRmVeSWpSXmKPExsUixCmqrRsR8NvfYNkmHYvVc3ksrt+cyWzx\r
+ ZuU8Vgdmj52z7rJ7HP66kMXj2apbzAHMUVw2Kak5mWWpRfp2CVwZd+fsYizYL1dxva2dpYFx\r
+ m0QXIyeHhICJxOYF2xghbDGJC/fWs4HYQgL7GCXunKjvYuQCstczSsz6M5MVwjnJJPHlQwcb\r
+ hDOXUeLhx4vMIC1sAhoS2/YvBxslIiAtsfPubFYQm1kgTmLLlP9gcWGBcInTK0FWcHCwCKhK\r
+ zFyhAhLmFXCQWLfhBhPEFfIST+/3gV3BKeAoMefmDkaIi8olPt/4xzyBkX8BI8MqRtmU3Crd\r
+ 3MTMnOLUZN3i5MS8vNQiXWO93MwSvdSU0k2M4NCS5NvB+PWg0iFGAQ5GJR7eaKbf/kKsiWXF\r
+ lbmHGCU5mJREefM8gUJ8SfkplRmJxRnxRaU5qcWHGCU4mJVEeG+5AuV4UxIrq1KL8mFS0hws\r
+ SuK8V1Ju+gsJpCeWpGanphakFsFkZTg4lCR4p/kDNQoWpaanVqRl5pQgpJk4OEGG8wANPwdS\r
+ w1tckJhbnJkOkT/FqCglznsdJCEAksgozYPrhcX+K0ZxoFeEeXeAVPEA0wZc9yugwUxAg9t7\r
+ foEMLklESEk1MGrNP/oiUaOg7dzSR1N8/t9NeL1yaqyTnWZa3P2cLR4n3UPXR1rxvNaQP/Pp\r
+ /4y//28e3shs+mRdx1UG65CFgm6rRIMn7/vDVTpDpqDSaJqGnJSF0cGY9Is/3305dmvB3LmJ\r
+ BQJaTK/Kbbrup72Q35K3LefB71luXjbVMybx9b6SKztnYH7xwAYlluKMREMt5qLiRADEo/LE\r
+ 2AIAAA==\r
+Cc: tomi.ollila@iki.fi\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, 09 Jul 2012 21:42:56 -0000\r
+\r
+This is a simpler place to do this, since we can avoid any point\r
+motion and hence any save-excursions in\r
+`notmuch-search-process-filter', which in turn lets us put all of the\r
+search-target logic outside of any save-excursions.\r
+\r
+`notmuch-search-show-{result,error}' are now responsible for their own\r
+point motion.\r
+\r
+`notmuch-search-process-filter' could use some reindentation after\r
+this, but we're about to rewrite it entirely, so we won't bother.\r
+---\r
+ emacs/notmuch.el | 41 ++++++++++++++++++++---------------------\r
+ 1 file changed, 20 insertions(+), 21 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index f952fa8..5bf01ca 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -730,29 +730,34 @@ non-authors is found, assume that all of the authors match."\r
+ (defun notmuch-search-show-result (thread-id date count authors subject tags)\r
+ ;; Ignore excluded matches\r
+ (unless (eq (aref count 1) ?0)\r
+- (let ((beg (point))\r
++ (let ((beg (point-max))\r
+ (tags-str (mapconcat 'identity tags " ")))\r
+- (dolist (spec notmuch-search-result-format)\r
+- (notmuch-search-insert-field (car spec) (cdr spec)\r
+- date count authors subject tags-str))\r
+- (insert "\n")\r
+- (notmuch-search-color-line beg (point) tags)\r
+- (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
+- (put-text-property beg (point) 'notmuch-search-authors authors)\r
+- (put-text-property beg (point) 'notmuch-search-subject subject))))\r
++ (save-excursion\r
++ (goto-char beg)\r
++ (dolist (spec notmuch-search-result-format)\r
++ (notmuch-search-insert-field (car spec) (cdr spec)\r
++ date count authors subject tags-str))\r
++ (insert "\n")\r
++ (notmuch-search-color-line beg (point) tags)\r
++ (put-text-property beg (point) 'notmuch-search-thread-id thread-id)\r
++ (put-text-property beg (point) 'notmuch-search-authors authors)\r
++ (put-text-property beg (point) 'notmuch-search-subject subject))\r
++ (when (string= thread-id notmuch-search-target-thread)\r
++ (setq notmuch-search-target-thread "found")\r
++ (goto-char beg)))))\r
+ \r
+ (defun notmuch-search-show-error (string &rest objects)\r
+- (insert "Error: Unexpected output from notmuch search:\n")\r
+- (insert (apply #'format string objects))\r
+- (insert "\n"))\r
++ (save-excursion\r
++ (goto-char (point-max))\r
++ (insert "Error: Unexpected output from notmuch search:\n")\r
++ (insert (apply #'format string objects))\r
++ (insert "\n")))\r
+ \r
+ (defun notmuch-search-process-filter (proc string)\r
+ "Process and filter the output of \"notmuch search\""\r
+- (let ((buffer (process-buffer proc))\r
+- (found-target nil))\r
++ (let ((buffer (process-buffer proc)))\r
+ (if (buffer-live-p buffer)\r
+ (with-current-buffer buffer\r
+- (save-excursion\r
+ (let ((line 0)\r
+ (more t)\r
+ (inhibit-read-only t)\r
+@@ -769,13 +774,9 @@ non-authors is found, assume that all of the authors match."\r
+ (subject (match-string 5 string))\r
+ (tags (match-string 6 string))\r
+ (tag-list (if tags (save-match-data (split-string tags)))))\r
+- (goto-char (point-max))\r
+ (if (/= (match-beginning 1) line)\r
+ (notmuch-search-show-error\r
+ (substring string line (match-beginning 1))))\r
+- (when (string= thread-id notmuch-search-target-thread)\r
+- (set 'found-target (point))\r
+- (set 'notmuch-search-target-thread "found"))\r
+ (notmuch-search-show-result thread-id date count authors subject tag-list)\r
+ (set 'line (match-end 0)))\r
+ (set 'more nil)\r
+@@ -784,8 +785,6 @@ non-authors is found, assume that all of the authors match."\r
+ (if (< line (length string))\r
+ (setq notmuch-search-process-filter-data (substring string line)))\r
+ ))))\r
+- (if found-target\r
+- (goto-char found-target)))\r
+ (delete-process proc))))\r
+ \r
+ (defun notmuch-search-tag-all (&optional tag-changes)\r
+-- \r
+1.7.10\r
+\r