---

This is continuation of id:m2y59ag9yj.fsf at guru.guru-group.fi

This is draft of code which could be used to do exact version comparison
between notmuch cli and notmuch Emacs MUA.

In case the versions aren't exactly same a warning message is shown
to the user before notmuch-hello window is filled the first time.

If this approach gets support I'll write more prepared patches
(in addition to make fully working patch...).

Tomi

 emacs/Makefile.local   |  4 +++-
 emacs/notmuch-hello.el | 26 +++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index a910aff..fd45d4a 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -36,7 +36,9 @@ $(dir)/.eldeps: $(dir)/Makefile.local $(dir)/make-deps.el 
$(emacs_sources)
 CLEAN+=$(dir)/.eldeps $(dir)/.eldeps.tmp

 %.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 $<

 ifeq ($(WITH_EMACS),1)
 ifeq ($(HAVE_EMACS),1)
diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 147c08c..d97aee3 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -29,6 +29,18 @@
 (declare-function notmuch-search "notmuch" (&optional query oldest-first 
target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())

+;; defconst notmuch-version to a value during build-time byte compilation...
+;; the compiled output will only contain the defconst definition
+(eval-when-compile
+  (defmacro expand-defconst-notmuch-version ()
+    `(if ,(boundp 'notmuch--version)
+         (defconst notmuch-version ,notmuch--version
+           "Version string for this version of Notmuch.")
+       (defconst notmuch-version "unknown"
+         "Placeholder for Notmuch version string. Set during build process.")))
+)
+(expand-defconst-notmuch-version)
+
 (defcustom notmuch-hello-recent-searches-max 10
   "The number of recent searches to display."
   :type 'integer
@@ -762,7 +774,19 @@ following:

   (if no-display
       (set-buffer "*notmuch-hello*")
-    (switch-to-buffer "*notmuch-hello*"))
+    (switch-to-buffer "*notmuch-hello*")
+    (if notmuch-hello-first-run
+       (let ((v (replace-regexp-in-string "^notmuch " ""
+                                          (car (process-lines notmuch-command
+                                                              "--version")))))
+         (unless (string= v notmuch-version)
+           (save-excursion
+             (erase-buffer)
+             (insert "
+Notmuch CLI version: " v "
+Notmuch Emacs version: " notmuch-version "
+
+XXX") (y-or-n-p "Press y or n to continue"))))))

   (let ((target-line (line-number-at-pos))
        (target-column (current-column))
-- 
1.8.1.4

Reply via email to