[PATCH v2 4/4] emacs: notmuch-lib: add refresh all buffers function

Mark Walters markwalters1009 at gmail.com
Sun Sep 25 04:11:21 PDT 2016


On Sat, 24 Sep 2016, Ioan-Adrian Ratiu <adi at adirat.com> wrote:
> notmuch-refresh-all-buffers calls each buffer's major mode specific
> refresh function using the generic notmuch-refresh-this-buffer function.
>
> It is very useful because by passing a non-nil arg to the buffer specific
> refresh functions it refreshes all notmuch buffers in the background and
> this again is very useful when doing periodic timer-based mail syncing.
>
> Signed-off-by: Ioan-Adrian Ratiu <adi at adirat.com>
> ---
>  emacs/notmuch-lib.el | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 6618365..72fee4d 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -428,6 +428,18 @@ in a window on screen, no-display has no effect."
>    (notmuch-poll)
>    (notmuch-refresh-this-buffer))
>  
> +(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 even if not displayed in any window. 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 (string-prefix-p "notmuch" (format "%s" buffer-mode))

I think I would prefer an explicit list of possible matches e.g.,

  (when (memq buffer-mode '(notmuch-show-mode
                            notmuch-tree-mode
                            notmuch-hello-mode
                            notmuch-search-mode)

This makes it easier to see when it will be called, and makes sure we
don't do anything weird if we have notmuch-compose-mode for example.

Best wishes

Mark


> +	(with-current-buffer buffer
> +	  (notmuch-refresh-this-buffer 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