notmuch.el: notmuch-search: avoid wiping out buffer-local variables

Subject: notmuch.el: notmuch-search: avoid wiping out buffer-local variables

Date: Tue, 21 Jul 2020 16:03:27 -0700

To: notmuch@notmuchmail.org

Cc:

From: Sean Whitton


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
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: