]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: prefer notmuch-emacs-version in User-Agent: header
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 2 Aug 2015 14:48:14 +0000 (17:48 +0300)
committerDavid Bremner <david@tethera.net>
Tue, 4 Aug 2015 18:56:38 +0000 (20:56 +0200)
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.

emacs/notmuch-lib.el
emacs/notmuch-mua.el
emacs/notmuch.el

index e16a1b971bd5e29bb3b78ba9f3a823c0b39acb85..201d7ec8593f376c1ae9f20a3671eff52535e4bc 100644 (file)
 (require 'mm-decode)
 (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"
   "Jump to a saved search by shortcut key." t)
 
index 934f6c95e8d4ec5c68fff40e1fac2c1b5ed42da9..3e52d5e2979f8995c33aa2b0b5b4763c536414df 100644 (file)
@@ -118,7 +118,10 @@ Note that these functions use `mail-citation-hook' if that is non-nil."
 
 (defun notmuch-mua-user-agent-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 ()
   "Generate a `User-Agent:' string suitable for notmuch."
index 6564816f078659f23ab5f6a6c6fc51478aa695ae..5284e77174f05a98d46c3c62a1de4007f208f4d3 100644 (file)
 (require 'notmuch-message)
 (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
   `(("date" . "%12s ")
     ("count" . "%-7s ")