From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id ePg2Nastol6SXgAA0tVLHw (envelope-from ) for ; Fri, 24 Apr 2020 00:07:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8KhCC7Itol4jcQAA1q6Kng (envelope-from ) for ; Fri, 24 Apr 2020 00:07:14 +0000 Received: from arlo.cworth.org (arlo.cworth.org [50.126.95.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A855894132A for ; Fri, 24 Apr 2020 00:07:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 9D6F76DE1385; Thu, 23 Apr 2020 17:07:09 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JZ--Wuo2WnAh; Thu, 23 Apr 2020 17:07:09 -0700 (PDT) Received: from arlo.cworth.org (localhost [IPv6:::1]) by arlo.cworth.org (Postfix) with ESMTP id B9CC26DE136D; Thu, 23 Apr 2020 17:07:07 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 3C5FB6DE136D for ; Thu, 23 Apr 2020 17:07:06 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LTWds87sWZhN for ; Thu, 23 Apr 2020 17:07:05 -0700 (PDT) Received: from cfg.domain (jb55.com [45.79.91.128]) by arlo.cworth.org (Postfix) with ESMTPS id E02956DE10B2 for ; Thu, 23 Apr 2020 17:07:04 -0700 (PDT) Received: from jb55.com (S010660e327dca171.vc.shawcable.net [24.84.152.187]) by jb55.com (OpenSMTPD) with ESMTPSA id ff8b0aa0 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO) for ; Fri, 24 Apr 2020 00:07:14 +0000 (UTC) From: William Casarin To: notmuch@notmuchmail.org Subject: Re: [PATCH 2/3] emacs/tree: enable moving to next thread in search results In-Reply-To: <20200423234715.6633-2-jb55@jb55.com> References: <20200423234715.6633-1-jb55@jb55.com> <20200423234715.6633-2-jb55@jb55.com> Date: Thu, 23 Apr 2020 17:07:04 -0700 Message-ID: <87y2ql4uhj.fsf@jb55.com> MIME-Version: 1.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: notmuch-bounces@notmuchmail.org Sender: "notmuch" X-Scanner: scn0 X-Spam-Score: 0.29 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 50.126.95.6 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Scan-Result: default: False [0.29 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.46032092974669]; MX_INVALID(1.00)[cached]; R_SPF_ALLOW(-0.20)[+a:c]; IP_REPUTATION_HAM(0.00)[asn: 27017(-0.18), country: US(-0.00), ip: 50.126.95.6(-0.46)]; TO_DN_NONE(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[50.126.95.6:from]; MAILLIST(-0.20)[mailman]; RECEIVED_SPAMHAUS_PBL(0.00)[24.84.152.187:received]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:27017, ipnet:50.126.64.0/18, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jb55@jb55.com,notmuch-bounces@notmuchmail.org]; ARC_NA(0.00)[]; URIBL_BLOCKED(0.00)[jb55.com:email,notmuchmail.org:email]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[notmuch@notmuchmail.org]; DMARC_NA(0.00)[jb55.com]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_SEVEN(0.00)[8]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: 50BYy1NGDw1C William Casarin writes: > This introduces a new function called > notmuch-tree-next-thread-from-search which is analogous to > notmuch-show-next-thread. It will switch to the next or previous > thread from the parent search results. > > We rename notmuch-tree-{prev,next}-thread to a more descriptive > notmuch-tree-{prev,next}-thread-in-tree to reflect the fact that it > only moves to the next thread in the current tree. > > notmuch-tree-next-thread now switches to the next thread in the > current tree first, but if there are none, it looks for the next tree > in the search results. > > This makes notmuch-tree feel more like notmuch-show when using the > M-Enter, M-n and M-p bindings. > > Signed-off-by: William Casarin > --- > emacs/notmuch-tree.el | 36 ++++++++++++++++++++++++++++++++++-- > 1 file changed, 34 insertions(+), 2 deletions(-) > > diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el > index f38fef98..dcd335e5 100644 > --- a/emacs/notmuch-tree.el > +++ b/emacs/notmuch-tree.el > @@ -710,12 +710,13 @@ nil otherwise." > (while (not (or (notmuch-tree-get-prop :first) (eobp))) > (forward-line -1)))) > > -(defun notmuch-tree-prev-thread () > +(defun notmuch-tree-prev-thread-in-tree () > + "Move to the next thread in the current tree" > (interactive) > (forward-line -1) > (notmuch-tree-thread-top)) > > -(defun notmuch-tree-next-thread () > +(defun notmuch-tree-next-thread-in-tree () > "Get the next thread in the current tree. Returns t if a thread was > found or nil if not." > (interactive) > @@ -724,6 +725,37 @@ found or nil if not." > (forward-line 1)) > (not (eobp))) > > +(defun notmuch-tree-next-thread-from-search (&optional previous) > + "Move to the next thread in the parent search results, if any. > + > +If PREVIOUS is non-nil, move to the previous item in the > +search results instead." > + (interactive "P") > + (let ((parent-buffer notmuch-tree-parent-buffer)) > + (notmuch-tree-quit t) > + (when (buffer-live-p parent-buffer) > + (switch-to-buffer parent-buffer) > + (if previous > + (notmuch-search-previous-thread) > + (notmuch-search-next-thread)) > + (notmuch-tree-from-search-thread)))) > + > +(defun notmuch-tree-next-thread (&optional previous) > + "Move to the next thread in the current tree or parent search > +results > + > +If PREVIOUS is non-nil, move to the previous thread in the tree or > +search results instead." > + (interactive) > + (unless (notmuch-tree-next-thread-in-tree) > + (notmuch-tree-next-thread-from-search previous))) I only have one more small fix for this in multi-threaded tree mode: diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 6661b12e..20dd1141 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -717,10 +717,11 @@ nil otherwise." (forward-line -1)))) (defun notmuch-tree-prev-thread-in-tree () - "Move to the next thread in the current tree" + "Move to the previous thread in the current tree" (interactive) (forward-line -1) - (notmuch-tree-thread-top)) + (notmuch-tree-thread-top) + (not (bobp))) (defun notmuch-tree-next-thread-in-tree () "Get the next thread in the current tree. Returns t if a thread was @@ -753,7 +754,8 @@ results If PREVIOUS is non-nil, move to the previous thread in the tree or search results instead." (interactive) - (unless (notmuch-tree-next-thread-in-tree) + (unless (if previous (notmuch-tree-prev-thread-in-tree) + (notmuch-tree-next-thread-in-tree)) (notmuch-tree-next-thread-from-search previous))) (defun notmuch-tree-prev-thread () which I will send in a v2 once this gets some Concept ACKs. Feel free to test in the meantime! Hopefully this makes tree-mode more usable for people who only use notmuch-show. Basic usage following the previous emacs/tree improvements: Press M-Enter on a thread from search-mode to enter that thread in notmuch-tree mode. With these patches, M-n and M-p move between search result threads, and A works as you would expect as well (archive and then move to next thread) Let me know what ya'll think! Cheers, Will