Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 623B7431FC0 for ; Wed, 17 Jul 2013 12:53:20 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6HJRZq5UTnET for ; Wed, 17 Jul 2013 12:53:12 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id CB5E5431FBF for ; Wed, 17 Jul 2013 12:53:11 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id 5478F1000F4; Wed, 17 Jul 2013 22:53:04 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [DRAFT PATCH] emacs: notmuch-version and version comparison with CLI Date: Wed, 17 Jul 2013 22:53:02 +0300 Message-Id: <1374090782-10273-1-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 1.8.0 Cc: tomi.ollila@iki.fi X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 19:53:20 -0000 --- This is continuation of id:m2y59ag9yj.fsf@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