[PATCH v4 5/7] Introduce _notmuch_message_has_term()
[notmuch-archives.git] / 2a / 8bb55864df59ed539605d14e99e4b2aaa544f5
1 Return-Path: <sojkam1@fel.cvut.cz>\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 B7009431FBF\r
6         for <notmuch@notmuchmail.org>; Sat, 27 Sep 2014 07:56:18 -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: -2.3\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_MED=-2.3] 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 saZRygGN6l0l for <notmuch@notmuchmail.org>;\r
16         Sat, 27 Sep 2014 07:56:13 -0700 (PDT)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id A6176431FC0\r
19         for <notmuch@notmuchmail.org>; Sat, 27 Sep 2014 07:56:13 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 0C15B19F36A8;\r
22         Sat, 27 Sep 2014 16:56:13 +0200 (CEST)\r
23 X-Virus-Scanned: IMAP STYX AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.7]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id q7p8h-kshw9z; Sat, 27 Sep 2014 16:56:08 +0200 (CEST)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id C2A3C19F36A9;\r
30         Sat, 27 Sep 2014 16:56:08 +0200 (CEST)\r
31 Received: from wsh by steelpick.2x.cz with local (Exim 4.84)\r
32         (envelope-from <sojkam1@fel.cvut.cz>)\r
33         id 1XXtPn-0005MB-1E; Sat, 27 Sep 2014 16:56:03 +0200\r
34 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
35 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
36 Subject: Re: [PATCH] emacs: prefer notmuch-emacs-version in User-Agent: header\r
37 In-Reply-To: <1407496781-17458-1-git-send-email-tomi.ollila@iki.fi>\r
38 References: <1407496781-17458-1-git-send-email-tomi.ollila@iki.fi>\r
39 User-Agent: Notmuch/0.18.1+101~g56b0ff0 (http://notmuchmail.org) Emacs/24.3.1\r
40         (x86_64-pc-linux-gnu)\r
41 Date: Sat, 27 Sep 2014 16:56:03 +0200\r
42 Message-ID: <87oau1un7g.fsf@steelpick.2x.cz>\r
43 MIME-Version: 1.0\r
44 Content-Type: text/plain\r
45 Cc: tomi.ollila@iki.fi\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Sat, 27 Sep 2014 14:56:18 -0000\r
59 \r
60 Hi Tomi,\r
61 \r
62 On Fri, Aug 08 2014, Tomi Ollila wrote:\r
63 > Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA\r
64 > use that as a part of User-Agent: header to provide more accurate\r
65 > version information when sending emails.\r
66 >\r
67 > In case some incomplete installation of notmuch emacs MUA is used and\r
68 > `notmuch-emacs-version' is defined as "unknown" then fall back to ask\r
69 > version info from cli (as it used to be) -- the function to do that was\r
70 > removed from `notmuch-version' to `notmuch-cli-version' to make things\r
71 > clearer and more consistent.\r
72 > ---\r
73 >  NEWS                   | 14 ++++++++++++++\r
74 >  emacs/notmuch-hello.el |  2 +-\r
75 >  emacs/notmuch-lib.el   |  4 ++--\r
76 >  emacs/notmuch-mua.el   | 11 ++++++++---\r
77 >  4 files changed, 25 insertions(+), 6 deletions(-)\r
78 >\r
79 > diff --git a/NEWS b/NEWS\r
80 > index f7aaedf91d07..9664146768f3 100644\r
81 > --- a/NEWS\r
82 > +++ b/NEWS\r
83 > @@ -7,6 +7,20 @@ Library changes\r
84 >  Add return status to notmuch_database_close and\r
85 >  notmuch_database_destroy\r
86 >  \r
87 > +Emacs Interface\r
88 > +---------------\r
89 > +\r
90 > +`notmuch-emacs-version` is used in `User-Agent` header\r
91 > +\r
92 > +  The value of recently introduced variable `notmuch-emacs-version` is\r
93 > +  now used as a part of `User-Agent` header when sending emails.\r
94 > +\r
95 > +Removed `notmuch-version` function by renaming it to `notmuch-cli-version`\r
96 > +\r
97 > +  With existing variable `notmuch-emacs-version` the accompanied\r
98 > +  function which retrieves the version of `notmuch-command` is\r
99 > +  better named as `notmuch-cli-version`.\r
100 > +\r
101 >  nmbug-status\r
102 >  ------------\r
103 >  \r
104 > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
105 > index 65d062760a71..7bfa752d2a04 100644\r
106 > --- a/emacs/notmuch-hello.el\r
107 > +++ b/emacs/notmuch-hello.el\r
108 > @@ -628,7 +628,7 @@ (defvar notmuch-emacs-version)\r
109 >  (defun notmuch-hello-versions ()\r
110 >    "Display the notmuch version(s)"\r
111 >    (interactive)\r
112 > -  (let ((notmuch-cli-version (notmuch-version)))\r
113 > +  (let ((notmuch-cli-version (notmuch-cli-version)))\r
114 >      (message "notmuch version %s"\r
115 >            (if (string= notmuch-emacs-version notmuch-cli-version)\r
116 >                notmuch-cli-version\r
117 > diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
118 > index 19269e3c469b..ca18ff9d5487 100644\r
119 > --- a/emacs/notmuch-lib.el\r
120 > +++ b/emacs/notmuch-lib.el\r
121 > @@ -192,8 +192,8 @@ (defun notmuch-assert-cli-sane ()\r
122 >  "Perhaps you haven't run \"notmuch setup\" yet? Try running this\r
123 >  on the command line, and then retry your notmuch command")))\r
124 >  \r
125 > -(defun notmuch-version ()\r
126 > -  "Return a string with the notmuch version number."\r
127 > +(defun notmuch-cli-version ()\r
128 > +  "Return a string with the notmuch-command version number."\r
129 >    (let ((long-string\r
130 >        ;; Trim off the trailing newline.\r
131 >        (substring (notmuch-command-to-string "--version") 0 -1)))\r
132 > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
133 > index 2c5888600b6c..dbf5df28669d 100644\r
134 > --- a/emacs/notmuch-mua.el\r
135 > +++ b/emacs/notmuch-mua.el\r
136 > @@ -100,12 +100,17 @@ (defun notmuch-mua-user-agent-full ()\r
137 >         " "\r
138 >         (notmuch-mua-user-agent-emacs)))\r
139 >  \r
140 > +;; the following variable is defined as being defconst in notmuch-version.el\r
141 > +(defvar notmuch-emacs-version)\r
142 \r
143 I don't like this part. It took me quite some time to figure out what's\r
144 happening with notmuch-emacs-version so that we need defvar here. It\r
145 seems that the same piece of code is also in notmuch-hello.el. What\r
146 about introducing a function in notmuch-lib that could be used the get\r
147 the best guess about emacs version? I think that something like the\r
148 following diff would make things clearer.\r
149 \r
150 -Michal\r
151 \r
152 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
153 index 19269e3..b883375 100644\r
154 --- a/emacs/notmuch-lib.el\r
155 +++ b/emacs/notmuch-lib.el\r
156 @@ -192,7 +192,7 @@ Otherwise the output will be returned"\r
157  "Perhaps you haven't run \"notmuch setup\" yet? Try running this\r
158  on the command line, and then retry your notmuch command")))\r
159  \r
160 -(defun notmuch-version ()\r
161 +(defun notmuch-cli-version ()\r
162    "Return a string with the notmuch version number."\r
163    (let ((long-string\r
164          ;; Trim off the trailing newline.\r
165 @@ -202,6 +202,15 @@ on the command line, and then retry your notmuch command")))\r
166         (match-string 2 long-string)\r
167        "unknown")))\r
168  \r
169 +(unless (require 'notmuch-version nil t)\r
170 +  (defconst notmuch-emacs-version "unknown"\r
171 +    "Placeholder variable when notmuch-version.el[c] is not available."))\r
172 +\r
173 +(defun notmuch-guess-emacs-version ()\r
174 +  (if (string= notmuch-emacs-version "unknown")\r
175 +      (notmuch-cli-version)\r
176 +    notmuch-emacs-version))\r
177 +\r
178  (defun notmuch-config-get (item)\r
179    "Return a value from the notmuch configuration."\r
180    (let* ((val (notmuch-command-to-string "config" "get" item))\r
181 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
182 index b44a907..7245b2d 100644\r
183 --- a/emacs/notmuch.el\r
184 +++ b/emacs/notmuch.el\r
185 @@ -61,10 +61,6 @@\r
186  (require 'notmuch-message)\r
187  (require 'notmuch-parser)\r
188  \r
189 -(unless (require 'notmuch-version nil t)\r
190 -  (defconst notmuch-emacs-version "unknown"\r
191 -    "Placeholder variable when notmuch-version.el[c] is not available."))\r
192 -\r
193  (defcustom notmuch-search-result-format\r
194    `(("date" . "%12s ")\r
195      ("count" . "%-7s ")\r
196 \r
197 \r
198 > +\r
199 >  (defun notmuch-mua-user-agent-notmuch ()\r
200 > -  "Generate a `User-Agent:' string suitable for notmuch."\r
201 > -  (concat "Notmuch/" (notmuch-version) " (http://notmuchmail.org)"))\r
202 > +  "Generate notmuch part of `User-Agent:' string suitable for notmuch."\r
203 > +  (concat "Notmuch/" (if (string= notmuch-emacs-version "unknown")\r
204 > +                      (notmuch-cli-version)\r
205 > +                    notmuch-emacs-version) " (http://notmuchmail.org)"))\r
206 >  \r
207 >  (defun notmuch-mua-user-agent-emacs ()\r
208 > -  "Generate a `User-Agent:' string suitable for notmuch."\r
209 > +  "Generate emacs part of `User-Agent:' string suitable for notmuch."\r
210 >    (concat "Emacs/" emacs-version " (" system-configuration ")"))\r
211 >  \r
212 >  (defun notmuch-mua-add-more-hidden-headers ()\r
213 > -- \r
214 > 2.0.0\r
215 >\r
216 > _______________________________________________\r
217 > notmuch mailing list\r
218 > notmuch@notmuchmail.org\r
219 > http://notmuchmail.org/mailman/listinfo/notmuch\r