From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +2a9OdfYMl8QKAAA0tVLHw (envelope-from ) for ; Tue, 11 Aug 2020 17:43:51 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CLzaM9fYMl+MewAAB5/wlQ (envelope-from ) for ; Tue, 11 Aug 2020 17:43:51 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 2388A940291 for ; Tue, 11 Aug 2020 17:43:51 +0000 (UTC) Received: from [144.217.243.247] (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8243F27DBC; Tue, 11 Aug 2020 13:43:43 -0400 (EDT) X-Greylist: delayed 398 seconds by postgrey-1.36 at nmbug; Tue, 11 Aug 2020 13:43:42 EDT Received: from jb55.com (unknown [IPv6:2600:3c01::f03c:91ff:fe08:5bfb]) by mail.notmuchmail.org (Postfix) with ESMTPS id 4B8541F9DC for ; Tue, 11 Aug 2020 13:43:42 -0400 (EDT) Received: from jb55.com (S010660e327dca171.vc.shawcable.net [24.84.152.187]) by jb55.com (OpenSMTPD) with ESMTPSA id 588473e1 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Tue, 11 Aug 2020 17:37:29 +0000 (UTC) From: William Casarin To: notmuch@notmuchmail.org Cc: Teemu Likonen , William Casarin Subject: [PATCH v2 2/3] emacs/tree: enable moving to next thread in search results Date: Tue, 11 Aug 2020 10:36:52 -0700 Message-Id: <20200811173653.18109-2-jb55@jb55.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200811173653.18109-1-jb55@jb55.com> References: <20200811173653.18109-1-jb55@jb55.com> MIME-Version: 1.0 Message-ID-Hash: VA3FDCTWIURWEUWECAMIFQZGO7T7ZS5S X-Message-ID-Hash: VA3FDCTWIURWEUWECAMIFQZGO7T7ZS5S X-MailFrom: jb55@jb55.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Spam-Score: 2.83 X-TUID: UQliQAOCAjLE 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 | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 29f64851..bf500b60 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -725,12 +725,14 @@ 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 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 () +(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) @@ -739,6 +741,38 @@ 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 (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 () + "Move to the previous thread in the current tree or parent search +results" + (interactive) + (notmuch-tree-next-thread t)) + (defun notmuch-tree-thread-mapcar (function) "Iterate through all messages in the current thread and call FUNCTION for side effects." -- 2.28.0