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 1/4] emacs: reuse buffer when refreshing searches
Date: Thu, 6 Oct 2016 16:42:24 +0300	[thread overview]
Message-ID: <20161006134227.17194-2-adi@adirat.com> (raw)
In-Reply-To: <20161006134227.17194-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 888672b..586c84e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -985,7 +985,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
@@ -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

  reply	other threads:[~2016-10-06 14:39 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 ` Ioan-Adrian Ratiu [this message]
2016-10-06 13:42 ` [PATCH v3 2/4] emacs: notmuch-show: refresh all windows showing a buffer Ioan-Adrian Ratiu
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-2-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).