unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Ioan-Adrian Ratiu <adi@adirat.com>
To: notmuch@notmuchmail.org
Subject: [PATCH v3 2/4] emacs: notmuch-show: refresh all windows showing a buffer
Date: Thu, 6 Oct 2016 16:42:25 +0300	[thread overview]
Message-ID: <20161006134227.17194-3-adi@adirat.com> (raw)
In-Reply-To: <20161006134227.17194-1-adi@adirat.com>

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 messaged based on the (point) location. Store the state
of all displayed windows when refreshing a notmuch-show buffer and
re-apply the current shown message for all windows.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
---
 emacs/notmuch-show.el | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f2487ab..ac7eb77 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1317,8 +1317,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"
@@ -1345,8 +1350,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.
@@ -1355,8 +1360,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.
-- 
2.10.0

  parent reply	other threads:[~2016-10-06 14:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06 13:42 [PATCH v3 0/4] Add refresh all buffers functionality Ioan-Adrian Ratiu
2016-10-06 13:42 ` [PATCH v3 1/4] emacs: reuse buffer when refreshing searches Ioan-Adrian Ratiu
2016-10-06 13:42 ` Ioan-Adrian Ratiu [this message]
2016-10-06 13:42 ` [PATCH v3 3/4] emacs: add refresh buffer optional no-display arg Ioan-Adrian Ratiu
2016-10-06 17:24   ` Mark Walters
2016-10-06 20:59     ` Ioan-Adrian Ratiu
2016-10-06 21:42       ` [PATCH] emacs: make the refresh code more consistent Mark Walters
2016-10-07 14:49         ` Ioan-Adrian Ratiu
2016-10-06 13:42 ` [PATCH v3 4/4] emacs: notmuch-lib: add refresh all buffers function Ioan-Adrian Ratiu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161006134227.17194-3-adi@adirat.com \
    --to=adi@adirat.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).