[PATCH v4] notmuch-show-imenu-prev-index-position-function: Don't recenter

Subject: [PATCH v4] notmuch-show-imenu-prev-index-position-function: Don't recenter

Date: Sun, 16 Feb 2025 22:22:23 +0100

To: notmuch@notmuchmail.org

Cc: Damien Cassou

From: Damien Cassou


The previous version of
notmuch-show-imenu-prev-index-position-function was calling
notmuch-show-previous-message which was recentering the window. This
is a problem when which-func-mode is active because which-func-mode is
called each time the user moves point around.

Because this function is only meant to be executed by imenu, there is
no reason to recenter the window. For the same reason, the new
implementation doesn't have to follow strictly how
notmuch-show-previous-message is implemented because imenu only places
point at very specific locations before calling
notmuch-show-imenu-prev-index-position-function.

---

Changed commit message.

Idea is from Pengji Zhang <me@pengjiz.com>.

Message-ID: <20250116201545.1510489-1-damien@cassou.me>
---
 emacs/notmuch-show.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 14e3c698..921c0ef1 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -2686,7 +2686,9 @@ (defun notmuch-show-imenu-prev-index-position-function ()
 `imenu-prev-index-position-function'."
   (if (bobp)
       nil
-    (notmuch-show-previous-message)
+    (if (eobp)
+	(notmuch-show-move-to-message-top)
+      (notmuch-show-goto-message-previous))
     t))
 
 (defun notmuch-show-imenu-extract-index-name-function ()
-- 
2.47.2

_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: