From: Ioan-Adrian Ratiu Date: Sat, 15 Oct 2016 07:32:44 +0000 (+0100) Subject: emacs: notmuch-show: refresh all windows displaying buffer X-Git-Tag: 0.24_rc0~114 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=4954bc50e8ed35c28ba0eed5470d133205a46654;hp=fae3d361f282ce52430a28d73a40d024783e08d2 emacs: notmuch-show: refresh all windows displaying buffer This updates all windows displaying a notmuch-show buffer when the buffer refresh function is called. Each window displaying a notmuch-show buffer has its own currently displayed message based on the (point) location. We store the state of all displayed windows when refreshing a notmuch-show buffer and re-apply the current shown message (point) for all windows. Implementation note: Each window has it's own (point) value, besides the buffer's (point) value. Sometimes these values are identical like in the case where a single window displays a buffer. When multiple windows display a buffer, (point) returns each window's specific value. What we are storing in this changeset is the window values not the buffer point values. The buffer's point is returned only if no window is displaying the buffer, a case we do not care about here. Signed-off-by: Ioan-Adrian Ratiu --- diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 643dee6e..16ff45ad 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -1319,8 +1319,13 @@ If no messages match the query return NIL." This includes: - the list of open messages, - - the current message." - (list (notmuch-show-get-message-id) (notmuch-show-get-message-ids-for-open-messages))) + - the combination of current message id with/for each visible window." + (let* ((win-list (get-buffer-window-list (current-buffer) nil t)) + (win-id-combo (mapcar (lambda (win) + (with-selected-window win + (list win (notmuch-show-get-message-id)))) + win-list))) + (list win-id-combo (notmuch-show-get-message-ids-for-open-messages)))) (defun notmuch-show-get-query () "Return the current query in this show buffer" @@ -1347,8 +1352,8 @@ This includes: This includes: - opening the messages previously opened, - closing all other messages, - - moving to the correct current message." - (let ((current (car state)) + - moving to the correct current message in every displayed window." + (let ((win-msg-alist (car state)) (open (cadr state))) ;; Open those that were open. @@ -1357,8 +1362,10 @@ This includes: (member (notmuch-show-get-message-id) open)) until (not (notmuch-show-goto-message-next))) - ;; Go to the previously open message. - (notmuch-show-goto-message current))) + (dolist (win-msg-pair win-msg-alist) + (with-selected-window (car win-msg-pair) + ;; Go to the previously open message in this window + (notmuch-show-goto-message (cadr win-msg-pair)))))) (defun notmuch-show-refresh-view (&optional reset-state) "Refresh the current view.