[PATCH 2/3] emacs: defconst notmuch-emacs-version to a value during byte compilation

Subject: [PATCH 2/3] emacs: defconst notmuch-emacs-version to a value during byte compilation

Date: Sat, 22 Feb 2014 01:20:36 +0200

To: notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Tomi Ollila


The notmuch cli program and emacs lisp versions may differ. For now
we can help users with their emacs client problems better if we can
ask what version of emacs MUA they are running. In the future we can
put the emacs MUA version to User-Agent: string in outgoing mail.
---
 emacs/Makefile.local | 6 +++++-
 emacs/notmuch.el     | 7 +++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 42bfbd9..e78699e 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -24,6 +24,8 @@ emacs_images := \
 
 emacs_bytecode = $(emacs_sources:.el=.elc)
 
+$(dir)/notmuch.elc: version.stamp
+
 # Because of defmacro's and defsubst's, we have to account for load
 # dependencies between Elisp files when byte compiling.  Otherwise,
 # the byte compiler may load an old .elc file when processing a
@@ -40,7 +42,9 @@ CLEAN+=$(dir)/.eldeps $(dir)/.eldeps.tmp
 
 ifeq ($(HAVE_EMACS),1)
 %.elc: %.el $(global_deps)
-	$(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
+	$(call quiet,EMACS) --directory emacs \
+		--eval "(setq notmuch--version \"$(VERSION)\")" \
+		-batch -f batch-byte-compile $<
 endif
 
 ifeq ($(WITH_EMACS),1)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0471750..1b15054 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -81,6 +81,13 @@ To enter a line break in customize, press \\[quoted-insert] C-j."
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch-search)
 
+;; defconst notmuch-version to a value during build-time byte compilation...
+(defconst notmuch-emacs-version
+  (eval-when-compile (if (boundp 'notmuch--version)
+			 notmuch--version
+		       "unknown"))
+  "Version string of this version of Notmuch Emacs MUA.")
+
 (defvar notmuch-query-history nil
   "Variable to store minibuffer history for notmuch queries")
 
-- 
1.8.0


Thread: