From: Austin Clements Date: Tue, 7 Aug 2012 16:03:52 +0000 (+2000) Subject: Re: [PATCH] emacs: notmuch search bugfix X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=56ff72d337de86a3299284d323fea28e0e918654;p=notmuch-archives.git Re: [PATCH] emacs: notmuch search bugfix --- diff --git a/6b/3972ee534210328a7c2a13148766d70b78d562 b/6b/3972ee534210328a7c2a13148766d70b78d562 new file mode 100644 index 000000000..81f1952fc --- /dev/null +++ b/6b/3972ee534210328a7c2a13148766d70b78d562 @@ -0,0 +1,148 @@ +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 52936431FAF + for ; Tue, 7 Aug 2012 09:03:58 -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 73KH8BJ18aqs for ; + Tue, 7 Aug 2012 09:03:57 -0700 (PDT) +Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU + [18.7.68.34]) + by olra.theworths.org (Postfix) with ESMTP id 9964A431FC0 + for ; Tue, 7 Aug 2012 09:03:57 -0700 (PDT) +X-AuditID: 12074422-b7f1f6d00000090b-56-50213c6b2d26 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP + id 4A.E6.02315.B6C31205; Tue, 7 Aug 2012 12:03:55 -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 q77G3soB013642; + Tue, 7 Aug 2012 12:03:55 -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 q77G3rS0007508 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 7 Aug 2012 12:03:54 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1SymG9-0002qx-6O; Tue, 07 Aug 2012 12:03:53 -0400 +Date: Tue, 7 Aug 2012 12:03:52 -0400 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH] emacs: notmuch search bugfix +Message-ID: <20120807160352.GA2811@mit.edu> +References: <87boinpqfg.fsf@qmul.ac.uk> <20120806234732.GM22601@mit.edu> + <87pq72bthc.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87pq72bthc.fsf@qmul.ac.uk> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42IR4hTV1s22UQwweDdL0WL1XB6L6zdnMjsw + eeycdZfd49mqW8wBTFFcNimpOZllqUX6dglcGS8+HmEr+CxSsfD2TrYGxhcCXYycHBICJhKN + Ox6xQthiEhfurWfrYuTiEBLYxyix6vJZVghnPaPEnVmtTCBVQgInmCSeHJaGSCxhlFj29wYz + SIJFQEXixPTtLCA2m4CGxLb9yxlBbBEBHYnbhxawg9jMAtIS3343gw0SFjCU2NX1Emw1r4C2 + xNeLj4B6OYCGZkg82mENERaUODnzCQtEq5bEjX8vmUBKQMYs/8cBEuYE2rR8EsQmUaALppzc + xjaBUWgWku5ZSLpnIXQvYGRexSibklulm5uYmVOcmqxbnJyYl5dapGuql5tZopeaUrqJERTS + 7C5KOxh/HlQ6xCjAwajEw3uBSyFAiDWxrLgy9xCjJAeTkiivsbligBBfUn5KZUZicUZ8UWlO + avEhRgkOZiUR3sM7gcp5UxIrq1KL8mFS0hwsSuK811Ju+gsJpCeWpGanphakFsFkZTg4lCR4 + N1kDDRUsSk1PrUjLzClBSDNxcIIM5wEavhWkhre4IDG3ODMdIn+KUVFKnHcFSEIAJJFRmgfX + C0s5rxjFgV4R5uW2AKriAaYruO5XQIOZgAZ7y8uBDC5JREhJNTCqqFYcXZ116O2BhCq/eXdS + g1/v6mWUmmgkvk4gWGTTLw1OAeFnhcxhO/e31acveO3O++2Uze7y29qtM8pXsYka+dQaO88/ + WnCu/ZS0h+i/5c67Hspctmfa8HtR53Q1ZkGrl4cWhwR++tit4Dv3MWtS6IHwZ3NUnh/9PD9A + t1o7okZ5tZuOcpsSS3FGoqEWc1FxIgCc7jvXFAMAAA== +Cc: 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: Tue, 07 Aug 2012 16:03:58 -0000 + +Quoth Mark Walters on Aug 07 at 4:40 pm: +> +> The recent change to use json for notmuch-search.el introduced a bug +> in the code for keeping position on refresh. The problem is a +> comparison between (plist-get result :thread) and a thread-id returned +> by notmuch-search-find-thread-id: the latter is prefixed with +> "thread:" +> +> We fix this by adding an option to notmuch-search-find-thread-id to +> return the bare thread-id. It appears that notmuch-search-refresh-view +> is the only caller of notmuch-search that supplies a thread-id so this +> change should be safe (but could theoretically break users .emacs +> functions). +> --- +> +> This is a different version of the bugfix suggested in the parent to +> this thread. I think it is nicer but there is a slight risk of breaking +> users .emacs lisp functions. +> +> In general I think the thread: prefix should be present where the term +> is "really" a search term, but absent when it is must be a thread-id, +> and this fits with that idea. + +Agreed. + +> With 0.14 freeze pretty close it might be best to apply this to master +> and the simpler no breakage option (in id:"87boinpqfg.fsf@qmul.ac.uk") +> to the branch. +> +> Best wishes +> +> Mark +> +> emacs/notmuch.el | 10 ++++++---- +> 1 files changed, 6 insertions(+), 4 deletions(-) +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index d2d82a9..0fff58a 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -475,10 +475,12 @@ BEG." +> (push (plist-get (notmuch-search-get-result pos) property) output))) +> output)) +> +> -(defun notmuch-search-find-thread-id () +> - "Return the thread for the current thread" +> +(defun notmuch-search-find-thread-id (&optional bare) +> + "Return the thread for the current thread +> + +> +If BARE is set then do not prefix with \"thread:\"" +> (let ((thread (plist-get (notmuch-search-get-result) :thread))) +> - (when thread (concat "thread:" thread)))) +> + (when thread (concat (when (not bare) "thread:") thread)))) + +(unless bare "thread:")? + +> +> (defun notmuch-search-find-thread-id-region (beg end) +> "Return a list of threads for the current region" +> @@ -993,7 +995,7 @@ same relative position within the new buffer." +> (interactive) +> (let ((target-line (line-number-at-pos)) +> (oldest-first notmuch-search-oldest-first) +> - (target-thread (notmuch-search-find-thread-id)) +> + (target-thread (notmuch-search-find-thread-id t)) + +Perhaps pass 'bare instead of t to make this self-documenting? + +> (query notmuch-search-query-string) +> (continuation notmuch-search-continuation)) +> (notmuch-kill-this-buffer)