Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / bf / aad8f1eb26c679e3f6cc32939622555ae40aaa
1 Return-Path: <too@guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 623B7431FC0\r
6         for <notmuch@notmuchmail.org>; Wed, 17 Jul 2013 12:53:20 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 6HJRZq5UTnET for <notmuch@notmuchmail.org>;\r
16         Wed, 17 Jul 2013 12:53:12 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id CB5E5431FBF\r
19         for <notmuch@notmuchmail.org>; Wed, 17 Jul 2013 12:53:11 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 5478F1000F4; Wed, 17 Jul 2013 22:53:04 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [DRAFT PATCH] emacs: notmuch-version and version comparison with CLI\r
25 Date: Wed, 17 Jul 2013 22:53:02 +0300\r
26 Message-Id: <1374090782-10273-1-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 1.8.0\r
28 Cc: tomi.ollila@iki.fi\r
29 X-BeenThere: notmuch@notmuchmail.org\r
30 X-Mailman-Version: 2.1.13\r
31 Precedence: list\r
32 List-Id: "Use and development of the notmuch mail system."\r
33         <notmuch.notmuchmail.org>\r
34 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
35         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
36 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
37 List-Post: <mailto:notmuch@notmuchmail.org>\r
38 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
39 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
41 X-List-Received-Date: Wed, 17 Jul 2013 19:53:20 -0000\r
42 \r
43 ---\r
44 \r
45 This is continuation of id:m2y59ag9yj.fsf@guru.guru-group.fi\r
46 \r
47 This is draft of code which could be used to do exact version comparison\r
48 between notmuch cli and notmuch Emacs MUA.\r
49 \r
50 In case the versions aren't exactly same a warning message is shown\r
51 to the user before notmuch-hello window is filled the first time.\r
52 \r
53 If this approach gets support I'll write more prepared patches\r
54 (in addition to make fully working patch...).\r
55 \r
56 Tomi\r
57 \r
58  emacs/Makefile.local   |  4 +++-\r
59  emacs/notmuch-hello.el | 26 +++++++++++++++++++++++++-\r
60  2 files changed, 28 insertions(+), 2 deletions(-)\r
61 \r
62 diff --git a/emacs/Makefile.local b/emacs/Makefile.local\r
63 index a910aff..fd45d4a 100644\r
64 --- a/emacs/Makefile.local\r
65 +++ b/emacs/Makefile.local\r
66 @@ -36,7 +36,9 @@ $(dir)/.eldeps: $(dir)/Makefile.local $(dir)/make-deps.el $(emacs_sources)\r
67  CLEAN+=$(dir)/.eldeps $(dir)/.eldeps.tmp\r
68  \r
69  %.elc: %.el $(global_deps)\r
70 -       $(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<\r
71 +       $(call quiet,EMACS) --directory emacs \\r
72 +               --eval "(setq notmuch--version \"$(VERSION)\")" \\r
73 +               -batch -f batch-byte-compile $<\r
74  \r
75  ifeq ($(WITH_EMACS),1)\r
76  ifeq ($(HAVE_EMACS),1)\r
77 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
78 index 147c08c..d97aee3 100644\r
79 --- a/emacs/notmuch-hello.el\r
80 +++ b/emacs/notmuch-hello.el\r
81 @@ -29,6 +29,18 @@\r
82  (declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))\r
83  (declare-function notmuch-poll "notmuch" ())\r
84  \r
85 +;; defconst notmuch-version to a value during build-time byte compilation...\r
86 +;; the compiled output will only contain the defconst definition\r
87 +(eval-when-compile\r
88 +  (defmacro expand-defconst-notmuch-version ()\r
89 +    `(if ,(boundp 'notmuch--version)\r
90 +         (defconst notmuch-version ,notmuch--version\r
91 +           "Version string for this version of Notmuch.")\r
92 +       (defconst notmuch-version "unknown"\r
93 +         "Placeholder for Notmuch version string. Set during build process.")))\r
94 +)\r
95 +(expand-defconst-notmuch-version)\r
96 +\r
97  (defcustom notmuch-hello-recent-searches-max 10\r
98    "The number of recent searches to display."\r
99    :type 'integer\r
100 @@ -762,7 +774,19 @@ following:\r
101  \r
102    (if no-display\r
103        (set-buffer "*notmuch-hello*")\r
104 -    (switch-to-buffer "*notmuch-hello*"))\r
105 +    (switch-to-buffer "*notmuch-hello*")\r
106 +    (if notmuch-hello-first-run\r
107 +       (let ((v (replace-regexp-in-string "^notmuch " ""\r
108 +                                          (car (process-lines notmuch-command\r
109 +                                                              "--version")))))\r
110 +         (unless (string= v notmuch-version)\r
111 +           (save-excursion\r
112 +             (erase-buffer)\r
113 +             (insert "\r
114 +Notmuch CLI version: " v "\r
115 +Notmuch Emacs version: " notmuch-version "\r
116 +\r
117 +XXX") (y-or-n-p "Press y or n to continue"))))))\r
118  \r
119    (let ((target-line (line-number-at-pos))\r
120         (target-column (current-column))\r
121 -- \r
122 1.8.1.4\r
123 \r