[PATCH v2 05/23] emacs: sanitize function that displays version

Subject: [PATCH v2 05/23] emacs: sanitize function that displays version

Date: Mon, 16 Nov 2020 22:28:25 +0100

To: notmuch@notmuchmail.org


From: Jonas Bernoulli

Previously it was defined in "notmuch-hello.el" and its name contained
"hello" solely because it replaced an anonymous function that was
mistakenly only bound in `notmuch-hello-mode-map'.  But it makes more
sense to bind it in all notmuch modes and even if we did not change
that aspect it still would make no sense to have "hello" in its name.
 emacs/notmuch-hello.el | 14 --------------
 emacs/notmuch-lib.el   | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index af170dd4..69d0ad64 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -652,26 +652,12 @@ (defun notmuch-hello-window-configuration-change ()
       (remove-hook 'window-configuration-change-hook
-;; the following variable is defined as being defconst in notmuch-version.el
-(defvar notmuch-emacs-version)
-(defun notmuch-hello-versions ()
-  "Display the notmuch version(s)."
-  (interactive)
-  (let ((notmuch-cli-version (notmuch-cli-version)))
-    (message "notmuch version %s"
-	     (if (string= notmuch-emacs-version notmuch-cli-version)
-		 notmuch-cli-version
-	       (concat notmuch-cli-version
-		       " (emacs mua version " notmuch-emacs-version ")")))))
 (defvar notmuch-hello-mode-map
   ;; Inherit both widget-keymap and notmuch-common-keymap.  We have
   ;; to use make-sparse-keymap to force this to be a new keymap (so
   ;; that when we modify map it does not modify widget-keymap).
   (let ((map (make-composed-keymap (list (make-sparse-keymap) widget-keymap))))
     (set-keymap-parent map notmuch-common-keymap)
-    (define-key map "v" 'notmuch-hello-versions)
     (define-key map (kbd "<C-tab>") 'widget-backward)
   "Keymap for \"notmuch hello\" buffers.")
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index edb40533..8ee3f17f 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -147,6 +147,7 @@ (defcustom notmuch-archive-tags '("-inbox")
 (defvar notmuch-common-keymap
   (let ((map (make-sparse-keymap)))
     (define-key map "?" 'notmuch-help)
+    (define-key map "v" 'notmuch-version)
     (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
     (define-key map "s" 'notmuch-search)
     (define-key map "t" 'notmuch-search-by-tag)
@@ -218,6 +219,21 @@ (defun notmuch-cli-version ()
 	(match-string 2 long-string)
+(defvar notmuch-emacs-version)
+(defun notmuch-version ()
+  "Display the notmuch version.
+The versions of the Emacs package and the `notmuch' executable
+should match, but if and only if they don't, then this command
+displays both values separately."
+  (interactive)
+  (let ((cli-version (notmuch-cli-version)))
+    (message "notmuch version %s"
+	     (if (string= notmuch-emacs-version cli-version)
+		 cli-version
+	       (concat cli-version
+		       " (emacs mua version " notmuch-emacs-version ")")))))
 (defun notmuch-config-get (item)
   "Return a value from the notmuch configuration."
   (let* ((val (notmuch-command-to-string "config" "get" item))
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org