From: Jonas Bernoulli Date: Mon, 16 Nov 2020 21:28:25 +0000 (+0100) Subject: emacs: sanitize function that displays version X-Git-Tag: 0.32_rc0~192 X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=dfd99c7fba16d787cad7f8a6c39d66310b1af909;hp=ff80122972c3ab9882654a0d75698c6692007e15;p=notmuch emacs: sanitize function that displays version 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. --- 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 @@ 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-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 "") 'widget-backward) map) "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 @@ For example, if you wanted to remove an \"inbox\" tag and add an (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 @@ on the command line, and then retry your notmuch command"))) (match-string 2 long-string) "unknown"))) +(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))