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