emacs: prefer notmuch-emacs-version in User-Agent: header

Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA
use that as a part of User-Agent: header to provide more accurate
version information when sending emails.

In case some incomplete installation of notmuch emacs MUA is used and
`notmuch-emacs-version' is defined as "unknown" then fall back to ask
version info from cli (as it used to be before this commit).

Requiring notmuch-version[.elc] and if that is missing setting
"fallback" notmuch-emacs-version (to "unknown") was moved from
notmuch.el to notmuch-lib.el as notmuch-mua.el (which provides
User-Agent: information) require's the latter.
This commit is contained in:
Tomi Ollila 2015-08-02 17:48:14 +03:00 committed by David Bremner
parent 0c565fa29f
commit 3c1eea5646
3 changed files with 8 additions and 5 deletions

View file

@ -25,6 +25,10 @@
(require 'mm-decode) (require 'mm-decode)
(require 'cl) (require 'cl)
(unless (require 'notmuch-version nil t)
(defconst notmuch-emacs-version "unknown"
"Placeholder variable when notmuch-version.el[c] is not available."))
(autoload 'notmuch-jump-search "notmuch-jump" (autoload 'notmuch-jump-search "notmuch-jump"
"Jump to a saved search by shortcut key." t) "Jump to a saved search by shortcut key." t)

View file

@ -118,7 +118,10 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
(defun notmuch-mua-user-agent-notmuch () (defun notmuch-mua-user-agent-notmuch ()
"Generate a `User-Agent:' string suitable for notmuch." "Generate a `User-Agent:' string suitable for notmuch."
(concat "Notmuch/" (notmuch-cli-version) " (http://notmuchmail.org)")) (let ((notmuch-version (if (string= notmuch-emacs-version "unknown")
(notmuch-cli-version)
notmuch-emacs-version)))
(concat "Notmuch/" notmuch-version " (http://notmuchmail.org)")))
(defun notmuch-mua-user-agent-emacs () (defun notmuch-mua-user-agent-emacs ()
"Generate a `User-Agent:' string suitable for notmuch." "Generate a `User-Agent:' string suitable for notmuch."

View file

@ -61,10 +61,6 @@
(require 'notmuch-message) (require 'notmuch-message)
(require 'notmuch-parser) (require 'notmuch-parser)
(unless (require 'notmuch-version nil t)
(defconst notmuch-emacs-version "unknown"
"Placeholder variable when notmuch-version.el[c] is not available."))
(defcustom notmuch-search-result-format (defcustom notmuch-search-result-format
`(("date" . "%12s ") `(("date" . "%12s ")
("count" . "%-7s ") ("count" . "%-7s ")