--- /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 1675E431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 13:37:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 6Rbsc7U2qGZq for <notmuch@notmuchmail.org>;\r
+ Wed, 19 Mar 2014 13:37:25 -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 70268431FBF\r
+ for <notmuch@notmuchmail.org>; Wed, 19 Mar 2014 13:37:23 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id C5B101000E2; Wed, 19 Mar 2014 22:37:15 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v4 2/3] emacs: add notmuch-version.el.tmpl and create\r
+ notmuch-version.el from it\r
+Date: Wed, 19 Mar 2014 22:37:10 +0200\r
+Message-Id: <1395261431-24668-2-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+In-Reply-To: <1395261431-24668-1-git-send-email-tomi.ollila@iki.fi>\r
+References: <1395261431-24668-1-git-send-email-tomi.ollila@iki.fi>\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: Wed, 19 Mar 2014 20:37:33 -0000\r
+\r
+The notmuch cli program and emacs lisp versions may differ (especially\r
+in remote usage). It helps to resolve problems if we can determine\r
+the versions of notmuch cli and notmuch emacs mua separately.\r
+\r
+The build process now creates notmuch-version.el from template file\r
+by filling the version info to notmuch-emacs-version variable.\r
+---\r
+ emacs/.gitignore | 1 +\r
+ emacs/Makefile.local | 11 +++++++++--\r
+ emacs/notmuch-version.el.tmpl | 23 +++++++++++++++++++++++\r
+ emacs/notmuch.el | 4 ++++\r
+ 4 files changed, 37 insertions(+), 2 deletions(-)\r
+ create mode 100644 emacs/notmuch-version.el.tmpl\r
+\r
+diff --git a/emacs/.gitignore b/emacs/.gitignore\r
+index 5421301..9fa1c44 100644\r
+--- a/emacs/.gitignore\r
++++ b/emacs/.gitignore\r
+@@ -1,2 +1,3 @@\r
+ .eldeps*\r
+ *.elc\r
++notmuch-version.el\r
+diff --git a/emacs/Makefile.local b/emacs/Makefile.local\r
+index 6a39b32..ca039e5 100644\r
+--- a/emacs/Makefile.local\r
++++ b/emacs/Makefile.local\r
+@@ -17,7 +17,14 @@ emacs_sources := \\r
+ $(dir)/notmuch-crypto.el \\r
+ $(dir)/notmuch-tag.el \\r
+ $(dir)/coolj.el \\r
+- $(dir)/notmuch-print.el\r
++ $(dir)/notmuch-print.el \\r
++ $(dir)/notmuch-version.el\r
++\r
++$(dir)/notmuch-version.el: $(dir)/Makefile.local version.stamp\r
++$(dir)/notmuch-version.el: $(dir)/notmuch-version.el.tmpl\r
++ @sed -e 's/%AG%/Generated file (from $(<F)) -- do not edit!/' \\r
++ -e 's/%VERSION%/"$(VERSION)"/' $< > $@\r
++\r
+ \r
+ emacs_images := \\r
+ $(srcdir)/$(dir)/notmuch-logo.png\r
+@@ -71,4 +78,4 @@ endif\r
+ mkdir -p "$(DESTDIR)$(emacsetcdir)"\r
+ install -m0644 $(emacs_images) "$(DESTDIR)$(emacsetcdir)"\r
+ \r
+-CLEAN := $(CLEAN) $(emacs_bytecode)\r
++CLEAN := $(CLEAN) $(emacs_bytecode) $(dir)/notmuch-version.el\r
+diff --git a/emacs/notmuch-version.el.tmpl b/emacs/notmuch-version.el.tmpl\r
+new file mode 100644\r
+index 0000000..6cf367b\r
+--- /dev/null\r
++++ b/emacs/notmuch-version.el.tmpl\r
+@@ -0,0 +1,23 @@\r
++;; -*- emacs-lisp -*-\r
++;;\r
++;; %AG%\r
++;;\r
++;; This file is part of Notmuch.\r
++;;\r
++;; Notmuch is free software: you can redistribute it and/or modify it\r
++;; under the terms of the GNU General Public License as published by\r
++;; the Free Software Foundation, either version 3 of the License, or\r
++;; (at your option) any later version.\r
++;;\r
++;; Notmuch is distributed in the hope that it will be useful, but\r
++;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
++;; General Public License for more details.\r
++;;\r
++;; You should have received a copy of the GNU General Public License\r
++;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.\r
++\r
++(defconst notmuch-emacs-version %VERSION%\r
++ "Version string of this version of Notmuch Emacs MUA.")\r
++\r
++(provide 'notmuch-version)\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 0471750..b7dd944 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -61,6 +61,10 @@\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
+1.8.0\r
+\r