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 v4 2/6] emacs: notmuch-search-refresh-view: reuse buffer
Date: Sun,  9 Oct 2016 00:01:35 +0300	[thread overview]
Message-ID: <20161008210139.25322-3-adi@adirat.com> (raw)
In-Reply-To: <20161008210139.25322-1-adi@adirat.com>

There's no reason to completely kill a buffer while refreshing its
search results because the buffer name is constant between refreshes
(based on the search query), only its contents may change and notmuch
search kills all local variables, so it's safe to reuse.

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 commits 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@adirat.com>
---
 emacs/notmuch.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ee1bb54..17a784d 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -985,7 +985,7 @@ the configured default sort order."
 (defun notmuch-search-refresh-view (&rest ignore)
   "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
@@ -993,8 +993,10 @@ 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))
+    (remove-overlays)
+    (erase-buffer)
     (notmuch-search query oldest-first target-thread target-line)
     (goto-char (point-min))))
 
-- 
2.10.0

  parent reply	other threads:[~2016-10-08 21:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-08 21:01 [PATCH v4 0/6] Add refresh all buffers functionality Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 1/6] emacs: make the refresh code more consistent Ioan-Adrian Ratiu
2016-10-09 16:19   ` Tomi Ollila
2016-10-08 21:01 ` Ioan-Adrian Ratiu [this message]
2016-10-08 21:01 ` [PATCH v4 3/6] emacs: notmuch-search: add no-display functionality Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 4/6] emacs: notmuch-show: refresh all windows displaying buffer Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 5/6] emacs: add no-display arg to generic refresh functions Ioan-Adrian Ratiu
2016-10-08 21:01 ` [PATCH v4 6/6] 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=20161008210139.25322-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).