--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 295D1431FC2\r
+ for <notmuch@notmuchmail.org>; Sat, 21 Mar 2015 03:16:32 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.438\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rO88FvzUAoqU for <notmuch@notmuchmail.org>;\r
+ Sat, 21 Mar 2015 03:16:28 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by olra.theworths.org (Postfix) with ESMTP id 1EE3C431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 21 Mar 2015 03:16:28 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id 81F6410008C; Sat, 21 Mar 2015 12:16:06 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: header\r
+Date: Sat, 21 Mar 2015 12:15:55 +0200\r
+Message-Id: <1426932955-23174-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 21 Mar 2015 10:16:32 -0000\r
+\r
+Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA\r
+use that as a part of User-Agent: header to provide more accurate\r
+version information when sending emails.\r
+\r
+In case some incomplete installation of notmuch emacs MUA is used and\r
+`notmuch-emacs-version' is defined as "unknown" then fall back to ask\r
+version info from cli (as it used to be) -- the function to do that was\r
+renamed from `notmuch-version' to `notmuch-cli-version' to make this\r
+clearer and more consistent.\r
+\r
+The hub of getting version information is new `notmuch-versions'\r
+function. It normally returns cons pair\r
+(notmuch-emacs-version . notmuch-cli-version).\r
+This function takes optional argument which makes the cdr of the return\r
+value work differently; if `notmuch-emacs-version' is "unknown", return\r
+pair as if the option were not given; otherwise return\r
+(notmuch-emacs-version . notmuch-emacs-version).\r
+This special case is useful to simplify setting User-Agent: header\r
+-- just use the cdr of the returned value.\r
+---\r
+\r
+This is v2 of id:1407496781-17458-1-git-send-email-tomi.ollila@iki.fi\r
+\r
+(NEWS dropped from this one (for now) -- will arrive later)\r
+\r
+ emacs/notmuch-hello.el | 13 +++++--------\r
+ emacs/notmuch-lib.el | 20 +++++++++++++++++++-\r
+ emacs/notmuch-mua.el | 2 +-\r
+ emacs/notmuch.el | 4 ----\r
+ 4 files changed, 25 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 65d0627..62345fe 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -622,18 +622,15 @@ (defun notmuch-hello-window-configuration-change ()\r
+ (remove-hook 'window-configuration-change-hook\r
+ #'notmuch-hello-window-configuration-change))))\r
+ \r
+-;; the following variable is defined as being defconst in notmuch-version.el\r
+-(defvar notmuch-emacs-version)\r
+-\r
+ (defun notmuch-hello-versions ()\r
+ "Display the notmuch version(s)"\r
+ (interactive)\r
+- (let ((notmuch-cli-version (notmuch-version)))\r
++ (let ((notmuch-versions (notmuch-versions)))\r
+ (message "notmuch version %s"\r
+- (if (string= notmuch-emacs-version notmuch-cli-version)\r
+- notmuch-cli-version\r
+- (concat notmuch-cli-version\r
+- " (emacs mua version " notmuch-emacs-version ")")))))\r
++ (if (string= (car notmuch-versions) (cdr notmuch-versions))\r
++ (car notmuch-versions)\r
++ (concat (cdr notmuch-versions)\r
++ " (emacs mua version " (car notmuch-versions) ")")))))\r
+ \r
+ (defvar notmuch-hello-mode-map\r
+ (let ((map (if (fboundp 'make-composed-keymap)\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index f8e5165..370b648 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -25,6 +25,10 @@\r
+ (require 'mm-decode)\r
+ (require 'cl)\r
+ \r
++(unless (require 'notmuch-version nil t)\r
++ (defconst notmuch-emacs-version "unknown"\r
++ "Placeholder variable when notmuch-version.el[c] is not available."))\r
++\r
+ (autoload 'notmuch-jump-search "notmuch-jump"\r
+ "Jump to a saved search by shortcut key." t)\r
+ \r
+@@ -192,7 +196,7 @@ (defun notmuch-assert-cli-sane ()\r
+ "Perhaps you haven't run \"notmuch setup\" yet? Try running this\r
+ on the command line, and then retry your notmuch command")))\r
+ \r
+-(defun notmuch-version ()\r
++(defun notmuch-cli-version ()\r
+ "Return a string with the notmuch version number."\r
+ (let ((long-string\r
+ ;; Trim off the trailing newline.\r
+@@ -202,6 +206,20 @@ (defun notmuch-version ()\r
+ (match-string 2 long-string)\r
+ "unknown")))\r
+ \r
++(defun notmuch-versions (&optional cdr-as-emacs-version-unless-unknown)\r
++ "Returns cons pair (notmuch-emacs-version . (`notmuch-cli-version'))\r
++If optional argument CDR-AS-EMACS-VERSION-UNLESS-UNKNOWN is non-nil\r
++and `notmuch-emacs-version' is not \"unknown\" return cons pair\r
++(notmuch-emacs-version . notmuch-emacs-version).\r
++`notmuch-mua-user-agent-notmuch' utilizes this option, and uses the cdr\r
++of this cons pair in User-Agent: header"\r
++ (interactive)\r
++ (cons notmuch-emacs-version\r
++ (if (or (not cdr-as-emacs-version-unless-unknown)\r
++ (string= notmuch-emacs-version "unknown"))\r
++ (notmuch-cli-version)\r
++ notmuch-emacs-version)))\r
++\r
+ (defun notmuch-config-get (item)\r
+ "Return a value from the notmuch configuration."\r
+ (let* ((val (notmuch-command-to-string "config" "get" item))\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 33f1399..ac067f2 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -118,7 +118,7 @@ (defun notmuch-mua-user-agent-full ()\r
+ \r
+ (defun notmuch-mua-user-agent-notmuch ()\r
+ "Generate a `User-Agent:' string suitable for notmuch."\r
+- (concat "Notmuch/" (notmuch-version) " (http://notmuchmail.org)"))\r
++ (concat "Notmuch/" (cdr (notmuch-versions t)) " (http://notmuchmail.org)"))\r
+ \r
+ (defun notmuch-mua-user-agent-emacs ()\r
+ "Generate a `User-Agent:' string suitable for notmuch."\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index ab00454..0cae117 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -61,10 +61,6 @@\r
+ (require 'notmuch-message)\r
+ (require 'notmuch-parser)\r
+ \r
+-(unless (require 'notmuch-version nil t)\r
+- (defconst notmuch-emacs-version "unknown"\r
+- "Placeholder variable when notmuch-version.el[c] is not available."))\r
+-\r
+ (defcustom notmuch-search-result-format\r
+ `(("date" . "%12s ")\r
+ ("count" . "%-7s ")\r
+-- \r
+2.1.0\r
+\r