unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* notmuch.el: notmuch-search: avoid wiping out buffer-local variables
@ 2020-07-21 23:03 Sean Whitton
  2020-07-22 10:32 ` David Edmondson
  0 siblings, 1 reply; 5+ messages in thread
From: Sean Whitton @ 2020-07-21 23:03 UTC (permalink / raw)
  To: notmuch

Hello,

I have some code to cycle through a list of searches.  The remaining
searches are stored in a buffer-local variable, working something like
this (simplified):

    (defun spw/next-unread-group ()
           (interactive)
           (notmuch-search (car spw/more-unread-groups)
           (set (make-local-variable 'spw/more-unread-groups)
                (cdr spw/more-unread-groups))))

However, my spw/more-unread-groups variable gets wiped out by
notmuch-refresh-this-buffer, because the latter calls
notmuch-search-mode, and major modes wipe out buffer-local variables.

So far as I can tell that call doesn't actually have any effect when the
mode is already notmuch-search-mode, so may I propose this patch to
support my use case:

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index dd18f2e1..dcbc1eb2 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -987,7 +987,8 @@ the configured default sort order."
     (if no-display
 	(set-buffer buffer)
       (switch-to-buffer buffer))
-    (notmuch-search-mode)
+    (unless (eq major-mode 'notmuch-search-mode)
+      (notmuch-search-mode))
     ;; Don't track undo information for this buffer
     (set 'buffer-undo-list t)
     (set 'notmuch-search-query-string query)

-- 
Sean Whitton

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-22 22:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 23:03 notmuch.el: notmuch-search: avoid wiping out buffer-local variables Sean Whitton
2020-07-22 10:32 ` David Edmondson
2020-07-22 15:11   ` [PATCH] emacs: " Sean Whitton
2020-07-22 15:46     ` David Edmondson
2020-07-22 22:51     ` David Bremner

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).