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

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

Date: Sun, 19 Jan 2014 14:51:42 +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 | 4 +++-
 emacs/notmuch-lib.el | 7 +++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 42bfbd9..1b2db7e 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -40,7 +40,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-lib.el b/emacs/notmuch-lib.el
index 2be409b..81eed54 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -168,6 +168,13 @@ Otherwise the output will be returned"
       (notmuch-check-exit-status status (cons notmuch-command args) output)
       output)))
 
+;; defconst notmuch-emacs-version to a value during build-time byte compilation
+(defconst notmuch-emacs-version
+  (eval-when-compile (if (boundp 'notmuch--version)
+			 notmuch--version
+		       "not-compiled"))
+  "Version string of this version of Notmuch Emacs MUA.")
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
-- 
1.8.4.2


Thread: