From aecdac3494ad2ecc918b5b4cb1e6930d8a027c62 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Thu, 5 Jul 2012 12:17:08 +2000 Subject: [PATCH] Re: [PATCH 3/8] emacs: Move search-target logic to `notmuch-search-show-result' --- c2/efac579cf03c2d52e7ebe94eb62637f45fad5c | 177 ++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 c2/efac579cf03c2d52e7ebe94eb62637f45fad5c diff --git a/c2/efac579cf03c2d52e7ebe94eb62637f45fad5c b/c2/efac579cf03c2d52e7ebe94eb62637f45fad5c new file mode 100644 index 000000000..1246ce664 --- /dev/null +++ b/c2/efac579cf03c2d52e7ebe94eb62637f45fad5c @@ -0,0 +1,177 @@ +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 AE1CE431FB6 + for ; Wed, 4 Jul 2012 09:17:15 -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 DASSV8SpTi9h for ; + Wed, 4 Jul 2012 09:17:15 -0700 (PDT) +Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU + [18.7.68.36]) + by olra.theworths.org (Postfix) with ESMTP id B539E431FAE + for ; Wed, 4 Jul 2012 09:17:14 -0700 (PDT) +X-AuditID: 12074424-b7f2a6d0000008bf-67-4ff46c8808cc +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP + id A7.FD.02239.88C64FF4; Wed, 4 Jul 2012 12:17:12 -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 q64GHBa9025847; + Wed, 4 Jul 2012 12:17:11 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q64GH96i005569 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Wed, 4 Jul 2012 12:17:10 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SmSGK-0000CO-RW; Wed, 04 Jul 2012 12:17:08 -0400 +Date: Wed, 4 Jul 2012 12:17:08 -0400 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH 3/8] emacs: Move search-target logic to + `notmuch-search-show-result' +Message-ID: <20120704161708.GB21653@mit.edu> +References: <1341354059-29396-1-git-send-email-amdragon@mit.edu> + <1341354059-29396-4-git-send-email-amdragon@mit.edu> + <87hatnhqm6.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87hatnhqm6.fsf@qmul.ac.uk> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFprOKsWRmVeSWpSXmKPExsUixCmqrduR88XfYNthbovVc3ksrt+cyWzx + ZuU8Vgdmj52z7rJ7HP66kMXj2apbzAHMUVw2Kak5mWWpRfp2CVwZLdNOMxa8Va5Yv/YXUwPj + D+kuRk4OCQETiVuf97NC2GISF+6tZwOxhQT2MUrseenXxcgFZK9nlLjctIQZInGCSeL7XEaI + xBJGicNLJ7N0MXJwsAioSBx9pwJSwyagIbFt/3JGEFtEQEfi9qEF7CA2s4C+xMqTM8HmCAtE + SZxZBDGTF6jmzd2DUDOnMkqs7Z7HBJEQlDg58wkLRLOWxI1/L5lAdjELSEss/8cBEuYE2nXl + 3lGwclGgE6ac3MY2gVFoFpLuWUi6ZyF0L2BkXsUom5JbpZubmJlTnJqsW5ycmJeXWqRrrpeb + WaKXmlK6iREU5uwuKjsYmw8pHWIU4GBU4uFNVPjsL8SaWFZcmXuIUZKDSUmUd1PWF38hvqT8 + lMqMxOKM+KLSnNTiQ4wSHMxKIrz24UA53pTEyqrUonyYlDQHi5I47/WUm/5CAumJJanZqakF + qUUwWRkODiUJ3g/ZQI2CRanpqRVpmTklCGkmDk6Q4TxAw9+C1PAWFyTmFmemQ+RPMepyrHtz + 5AajEEtefl6qlDjvO5AiAZCijNI8uDmw9PSKURzoLWHeyyBVPMDUBjfpFdASJqAleYs/gSwp + SURISTUwsjVK1nlZuzdZLxe/dutkv3YQY9SqWqd7pYmGF1j4avcd91lcKmUftePa3JZTFxSO + ByyTelx4PvV+cx//vnPvuuSuiehrCSk9VBbcOtNgWubxZTHfPi9f0rac+wjbGwWZxEdnJh86 + vZNpHauqzBwPAyfL0kdnp76OsFzyJDKuNG7lfsfmN6LHlFiKMxINtZiLihMBXpKsuioDAAA= +Cc: tomi.ollila@iki.fi, notmuch@notmuchmail.org +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: Wed, 04 Jul 2012 16:17:15 -0000 + +Quoth Mark Walters on Jul 04 at 9:34 am: +> On Tue, 03 Jul 2012, Austin Clements wrote: +> > 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"))) +> +> Does this mean that error information now comes just before the matching +> thread, rather than at the place in the thread list the error actually +> occurs? This is not a complaint: just everything else looks like it is +> functionally equivalent. (Maybe it is all made irrelevant by a later +> patch anyway). + +In fact, the errors will appear before the first message *until* you +reach the matched message. I think this was the result of overzealous +rebasing. I'm happy to fix it here for posterity (possibly by +swapping this and the next patch), though as you point out the next +patch in the series also fixes it, so I'm also happy to leave it +alone. + +> Best wishes +> +> Mark +> +> +> > - (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) -- 2.26.2