[PATCH 27/32] emacs: define a few variables as automatically buffer-local

Subject: [PATCH 27/32] emacs: define a few variables as automatically buffer-local

Date: Mon, 14 Dec 2020 17:23:56 +0100

To: notmuch@notmuchmail.org

Cc:

From: Jonas Bernoulli


Define these variables as automatically buffer-local, meaning that
they always become buffer-local when set unless explicitly told
otherwise using `setq-default' or when using the Custom interface.

Previously they were declared, which keeps the byte-compiler quiet but
is not actually the same as being defined.  `notmuch-search-mode' then
made them buffer-local in the current buffer and then set the local
values.  This works but is not kosher.

The definitions of the three non-option variables have to be moved up
a bit to enable the change in the next commit, which see.
---
 emacs/notmuch-lib.el |  1 +
 emacs/notmuch.el     | 16 ++++++----------
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 72549a98..2fd9a27d 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -101,6 +101,7 @@ (defcustom notmuch-search-oldest-first t
 search."
   :type 'boolean
   :group 'notmuch-search)
+(make-variable-buffer-local 'notmuch-search-oldest-first)
 
 (defcustom notmuch-poll-script nil
   "[Deprecated] Command to run to incorporate new mail into the notmuch database.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 35f825b9..464960e4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -205,6 +205,12 @@ (defvar notmuch-search-mode-map
     map)
   "Keymap for \"notmuch search\" buffers.")
 
+;;; Internal Variables
+
+(defvar-local notmuch-search-query-string nil)
+(defvar-local notmuch-search-target-thread nil)
+(defvar-local notmuch-search-target-line nil)
+
 ;;; Stashing
 
 (defvar notmuch-search-stash-map
@@ -226,12 +232,6 @@ (defun notmuch-stash-query ()
   (interactive)
   (notmuch-common-do-stash (notmuch-search-get-query)))
 
-;;; Variables
-
-(defvar notmuch-search-query-string)
-(defvar notmuch-search-target-thread)
-(defvar notmuch-search-target-line)
-
 ;;; Movement
 
 (defun notmuch-search-scroll-up ()
@@ -404,10 +404,6 @@ (define-derived-mode notmuch-search-mode fundamental-mode "notmuch-search"
 Complete list of currently available key bindings:
 
 \\{notmuch-search-mode-map}"
-  (make-local-variable 'notmuch-search-query-string)
-  (make-local-variable 'notmuch-search-oldest-first)
-  (make-local-variable 'notmuch-search-target-thread)
-  (make-local-variable 'notmuch-search-target-line)
   (setq notmuch-buffer-refresh-function #'notmuch-search-refresh-view)
   (setq-local scroll-preserve-screen-position t)
   (add-to-invisibility-spec (cons 'ellipsis t))
-- 
2.29.1
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: