[PATCH 1/4] emacs: reuse buffer when refreshing searches

Mark Walters markwalters1009 at gmail.com
Fri Sep 16 12:59:50 PDT 2016


Hi

On Sat, 10 Sep 2016, Ioan-Adrian Ratiu <adi at adirat.com> wrote:
> There's no reason to completely kill a buffer while refreshing its
> search results because its buffer name is constant between refreshes
> (based on the search query) and only its contents may change.
>
> Reusing the same buffer also makes it possible to do things like
> refreshing a buffer which is not focused or even not shown in any
> window - this will be used in the next patches to add auto-refresh
> capabilities to all existing notmuch buffers + a function to call
> after syncing mail to refresh everything.
>
> Signed-off-by: Ioan-Adrian Ratiu <adi at adirat.com>
> ---
>  emacs/notmuch.el | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 43d56f7..c33c55c 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -990,7 +990,7 @@ the configured default sort order."
>  (defun notmuch-search-refresh-view ()
>    "Refresh the current view.
>  
> -Kills the current buffer and runs a new search with the same
> +Erases the current buffer and runs a new search with the same
>  query string as the current search. If the current thread is in
>  the new search results, then point will be placed on the same
>  thread. Otherwise, point will be moved to attempt to be in the
> @@ -998,8 +998,9 @@ same relative position within the new buffer."
>    (let ((target-line (line-number-at-pos))
>  	(oldest-first notmuch-search-oldest-first)
>  	(target-thread (notmuch-search-find-thread-id 'bare))
> -	(query notmuch-search-query-string))
> -    (notmuch-bury-or-kill-this-buffer)
> +	(query notmuch-search-query-string)
> +	(inhibit-read-only t))
> +    (erase-buffer)
>      (notmuch-search query oldest-first target-thread target-line)

This looks fine.  It might be worth putting a comment in that
notmuch-search kills all local variables as otherwise a reader may worry
about that. The chain to get to kill-all-local-variables is relatively
long:

notmuch-search
notmuch-search-mode
define-derived-mode
fundamental-mode


Best wishes

Mark


More information about the notmuch mailing list