[PATCH v3 3/3] emacs: defun notmuch-hello-versions and bind 'v' in hello mode to it

Subject: [PATCH v3 3/3] emacs: defun notmuch-hello-versions and bind 'v' in hello mode to it

Date: Sun, 23 Feb 2014 23:01:48 +0200

To: notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Tomi Ollila


If notmuch cli & notmuch emacs MUA versions differ, print also the
emacs MUA version string (along with the cli version) to the
minibuffer.
---
 emacs/notmuch-hello.el | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 7b3d76b..f5e7268 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -513,6 +513,18 @@ Such a list can be computed with `notmuch-hello-query-counts'."
       (remove-hook 'window-configuration-change-hook
 		   #'notmuch-hello-window-configuration-change))))
 
+;; the following variable is defined as being defconst in notmuch.el
+(defvar notmuch-emacs-version)
+
+(defun notmuch-hello-versions ()
+  "Display the notmuch version(s)"
+  (interactive)
+  (let ((notmuch-cli-version (notmuch-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
   (let ((map (if (fboundp 'make-composed-keymap)
@@ -523,8 +535,7 @@ Such a list can be computed with `notmuch-hello-query-counts'."
 	       ;; it's unlikely to change.
 	       (copy-keymap widget-keymap))))
     (set-keymap-parent map notmuch-common-keymap)
-    (define-key map "v" (lambda () "Display the notmuch version" (interactive)
-			  (message "notmuch version %s" (notmuch-version))))
+    (define-key map "v" 'notmuch-hello-versions)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     map)
   "Keymap for \"notmuch hello\" buffers.")
-- 
1.8.0


Thread: