unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs/show: Only recenter interactively
@ 2024-11-23 15:16 Damien Cassou
  2024-12-15  8:12 ` Damien Cassou
  2024-12-15  9:33 ` Pengji Zhang
  0 siblings, 2 replies; 6+ messages in thread
From: Damien Cassou @ 2024-11-23 15:16 UTC (permalink / raw)
  To: notmuch; +Cc: Damien Cassou

Several notmuch-show commands recenter the window by calling
`notmuch-show-message-adjust`. This is fine when these commands are
called interactively but not when used inside non-interactive
functions. An example of the problem is when `which-func-mode` is
activated: each time the user moves the point to a different line, the
window is recentered. This happens because `which-func-mode` calls
`imenu` which calls `notmuch-show-imenu-prev-index-position-function`
which calls `notmuch-show-previous-message` which recenters the
window.

This patch makes sure that commands only invoke
`notmuch-show-message-adjust` when they have been called
interactively.
---
 emacs/notmuch-show.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 14e3c698..c08375b8 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1535,7 +1535,7 @@ (defun notmuch-show-goto-message (msg-id)
 		   until (not (notmuch-show-goto-message-next)))
     (goto-char (point-min))
     (message "Message-id not found."))
-  (notmuch-show-message-adjust))
+  (when (interactive-p) (notmuch-show-message-adjust)))
 
 (defun notmuch-show-apply-state (state)
   "Apply STATE to the current buffer.
@@ -2052,7 +2052,7 @@ (defun notmuch-show-rewind ()
       (when (<= (count-screen-lines (window-start) start-of-message)
 		next-screen-context-lines)
 	(goto-char (notmuch-show-message-top))
-	(notmuch-show-message-adjust))
+	(when (interactive-p) (notmuch-show-message-adjust)))
       ;; Move to the top left of the window.
       (goto-char (window-start)))
      (t
@@ -2109,7 +2109,7 @@ (defun notmuch-show-next-message (&optional pop-at-end)
 thread, navigate to the next thread in the parent search buffer."
   (interactive "P")
   (if (notmuch-show-goto-message-next)
-      (notmuch-show-message-adjust)
+      (when (interactive-p) (notmuch-show-message-adjust))
     (if pop-at-end
 	(notmuch-show-next-thread)
       (goto-char (point-max)))))
@@ -2120,7 +2120,7 @@ (defun notmuch-show-previous-message ()
   (if (= (point) (notmuch-show-message-top))
       (notmuch-show-goto-message-previous)
     (notmuch-show-move-to-message-top))
-  (notmuch-show-message-adjust))
+  (when (interactive-p) (notmuch-show-message-adjust)))
 
 (defun notmuch-show-next-open-message (&optional pop-at-end)
   "Show the next open message.
@@ -2134,7 +2134,7 @@ (defun notmuch-show-next-open-message (&optional pop-at-end)
     (while (and (setq r (notmuch-show-goto-message-next))
 		(not (notmuch-show-message-visible-p))))
     (if r
-	(notmuch-show-message-adjust)
+	(when (interactive-p) (notmuch-show-message-adjust))
       (if pop-at-end
 	  (notmuch-show-next-thread)
 	(goto-char (point-max))))
@@ -2147,7 +2147,7 @@ (defun notmuch-show-next-matching-message ()
     (while (and (setq r (notmuch-show-goto-message-next))
 		(not (notmuch-show-get-prop :match))))
     (if r
-	(notmuch-show-message-adjust)
+	(when (interactive-p) (notmuch-show-message-adjust))
       (goto-char (point-max)))))
 
 (defun notmuch-show-open-if-matched ()
@@ -2176,7 +2176,7 @@ (defun notmuch-show-previous-open-message ()
 		  (notmuch-show-goto-message-previous)
 		(notmuch-show-move-to-message-top))
 	      (not (notmuch-show-message-visible-p))))
-  (notmuch-show-message-adjust))
+  (when (interactive-p) (notmuch-show-message-adjust)))
 
 (defun notmuch-show-view-raw-message ()
   "View the original source of the current message."
-- 
2.47.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-17 19:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-23 15:16 [PATCH] emacs/show: Only recenter interactively Damien Cassou
2024-12-15  8:12 ` Damien Cassou
2024-12-15  9:33 ` Pengji Zhang
2024-12-15 12:47   ` Damien Cassou
2024-12-17 11:44     ` Pengji Zhang
2024-12-17 19:32       ` Damien Cassou

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).