[PATCH 2/4] emacs: adjust all types of notmuch show buffers

Ioan-Adrian Ratiu adi at adirat.com
Sat Sep 10 07:28:17 PDT 2016


The current notmuch-show-message-adjust logic only adjusts the buffer
focused in the current window. Extend it to adjust any kind of buffer,
even buffers in a window without focus or in a different frame or even
not shown at all.

This new logic is very useful to build upon for the auto-refresh all
buffers feature because you can use similar code to refresh any buffer:

(with-current-buffer "*random show buffer*"
  (notmuch-refresh-this-buffer))

Signed-off-by: Ioan-Adrian Ratiu <adi at adirat.com>
---
 emacs/notmuch-show.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6d3149b..74818cc 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1505,7 +1505,16 @@ All currently available key bindings:
   (goto-char (notmuch-show-message-bottom)))
 
 (defun notmuch-show-message-adjust ()
-  (recenter 0))
+  (let ((buffer-window (get-buffer-window (current-buffer) t))
+	(msg-position (point)))
+    (if buffer-window
+	(with-selected-window buffer-window
+	  (goto-char msg-position)
+	  (recenter 0))
+      (save-window-excursion
+	(select-window (display-buffer (current-buffer)))
+	(goto-char msg-position)
+	(recenter 0)))))
 
 ;; Movement related functions.
 
-- 
2.9.3



More information about the notmuch mailing list