From: Austin Clements Date: Tue, 3 Jul 2012 22:20:54 +0000 (+2000) Subject: [PATCH 3/8] emacs: Move search-target logic to `notmuch-search-show-result' X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4ff692acc9b9757c1e8997bbb51d67de5477d734;p=notmuch-archives.git [PATCH 3/8] emacs: Move search-target logic to `notmuch-search-show-result' --- diff --git a/6d/44ab9f87cfeb97485c069d4f6c3ca643d12a09 b/6d/44ab9f87cfeb97485c069d4f6c3ca643d12a09 new file mode 100644 index 000000000..d1d455ab7 --- /dev/null +++ b/6d/44ab9f87cfeb97485c069d4f6c3ca643d12a09 @@ -0,0 +1,154 @@ +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 8B69C431FD8 + for ; Tue, 3 Jul 2012 15:21:10 -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 ZNO-aod-YEZG for ; + Tue, 3 Jul 2012 15:21:06 -0700 (PDT) +Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU + [18.7.68.37]) + by olra.theworths.org (Postfix) with ESMTP id 68416431FAF + for ; Tue, 3 Jul 2012 15:21:06 -0700 (PDT) +X-AuditID: 12074425-b7f9b6d0000008c4-5c-4ff37051c068 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP + id 99.1B.02244.15073FF4; Tue, 3 Jul 2012 18:21:05 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id q63ML40M022244; + Tue, 3 Jul 2012 18:21:05 -0400 +Received: from drake.dyndns.org (26-4-182.dynamic.csail.mit.edu [18.26.4.182]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q63ML1wU023221 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 3 Jul 2012 18:21:02 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1SmBSv-0007fP-0N; Tue, 03 Jul 2012 18:21:01 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH 3/8] emacs: Move search-target logic to + `notmuch-search-show-result' +Date: Tue, 3 Jul 2012 18:20:54 -0400 +Message-Id: <1341354059-29396-4-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +In-Reply-To: <1341354059-29396-1-git-send-email-amdragon@mit.edu> +References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFrrIIsWRmVeSWpSXmKPExsUixG6nohtY8NnfYMpfQ4sje2axWyw985/Z + 4vrNmcwWb1bOY3Vg8dg56y67x+GvC1k8nq26xezR9GMxawBLFJdNSmpOZllqkb5dAlfG429r + 2QtmS1fcO3mFqYHxhWgXIyeHhICJxI+ja1ggbDGJC/fWs3UxcnEICexjlJi5rpEVwlnPKPH+ + xWOwKiGBk0wS105ZQiTmMkpM2H+XCSTBJqAhsW3/ckYQW0RAWmLn3dmsIDazQK7E2dbDYHFh + gRCJKXeWg9WzCKhKXPhwGSzOK+Ag0bbqCiPEGfIST+/3sYHYnAKOEitunoVa7CCx7UMH6wRG + /gWMDKsYZVNyq3RzEzNzilOTdYuTE/PyUot0LfRyM0v0UlNKNzGCQ85FdQfjhENKhxgFOBiV + eHgTFT77C7EmlhVX5h5ilORgUhLlvZIHFOJLyk+pzEgszogvKs1JLT7EKMHBrCTCuzoJKMeb + klhZlVqUD5OS5mBREue9kXLTX0ggPbEkNTs1tSC1CCYrw8GhJMHbmg/UKFiUmp5akZaZU4KQ + ZuLgBBnOAzR8GUgNb3FBYm5xZjpE/hSjopQ4bxVIQgAkkVGaB9cLSwmvGMWBXhHm7QSp4gGm + E7juV0CDmYAG5y3+BDK4JBEhJdXAaPzC4MFWKafuVWvvyr8009my1GgOY1jR/dKOtO+aDyL/ + fdm1s6Ii4XJBxLLt38KLao448JR/O/1a+vCbksXNW6RcNdMVj7z/Mc11VWh6498rsm66t9Tn + CByZdvnCqgLenljJ1olblx2+aBLHFf9gd9rFM1H/n16VX5IpuFk+SsXnELt/yqJuEyWW4oxE + Qy3mouJEAF295MLkAgAA +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: Tue, 03 Jul 2012 22:21:10 -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-process-filter' could use some reindentation after +this, but we're about to rewrite it entirely, so we won't bother. +--- + emacs/notmuch.el | 33 +++++++++++++++------------------ + 1 file changed, 15 insertions(+), 18 deletions(-) + +diff --git a/emacs/notmuch.el b/emacs/notmuch.el +index dadc6d6..4a6490a 100644 +--- a/emacs/notmuch.el ++++ b/emacs/notmuch.el +@@ -729,24 +729,27 @@ 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 (format notmuch-search-result-format) +- (notmuch-search-insert-field (car format) (cdr format) +- 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 (format notmuch-search-result-format) ++ (notmuch-search-insert-field (car format) (cdr format) ++ 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-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) +@@ -763,12 +766,8 @@ 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) + (insert (concat "Error: Unexpected output from notmuch search:\n" (substring string line (match-beginning 1)) "\n"))) +- (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) +@@ -777,8 +776,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 +