[PATCH v4 6/6] emacs: notmuch-lib: add refresh all buffers function

Ioan-Adrian Ratiu adi at adirat.com
Sat Oct 8 14:01:39 PDT 2016


notmuch-refresh-all-buffers calls each buffer's major mode specific
refresh function using the generic notmuch-refresh-this-buffer function.

Each buffer-specific refresh function has the same form, taking a prefix
and a no-display arg. Passing the no-display arg is very useful because
it tells the buffer-specific refresh functions to work in the background
and not bring forward the refreshed buffer in a window. This again is very
useful for silent async background updating the emacs display when new
mail is fetched.

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

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index e1b5066..1162130 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -430,6 +430,21 @@ display the buffer.")
   (notmuch-poll)
   (notmuch-refresh-this-buffer prefix no-display))
 
+(defun notmuch-refresh-all-buffers (&optional no-display)
+  "Invoke `notmuch-refresh-this-buffer' on all notmuch major-mode buffers.
+
+If no-display is non-nil all buffers are silently refreshed, i.e. they are
+not foregrounded to a window if not already displayed. If no-display is nil,
+then each buffer's mode-specific refresh function uses its default behaviour."
+  (dolist (buffer (buffer-list))
+    (let ((buffer-mode (buffer-local-value 'major-mode buffer)))
+      (when (memq buffer-mode '(notmuch-show-mode
+				notmuch-tree-mode
+				notmuch-search-mode
+				notmuch-hello-mode))
+	(with-current-buffer buffer
+	  (notmuch-refresh-this-buffer nil no-display))))))
+
 (defun notmuch-prettify-subject (subject)
   ;; This function is used by `notmuch-search-process-filter' which
   ;; requires that we not disrupt its' matching state.
-- 
2.10.0



More information about the notmuch mailing list