Re: [PATCH v4 02/16] Move crypto.c into libutil
[notmuch-archives.git] / b3 / dbc659c9b478ba07f2fed288e784860fb2011e
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 295D1431FC2\r
6         for <notmuch@notmuchmail.org>; Sat, 21 Mar 2015 03:16:32 -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.438\r
10 X-Spam-Level: **\r
11 X-Spam-Status: No, score=2.438 tagged_above=-999 required=5\r
12         tests=[DNS_FROM_AHBL_RHSBL=2.438] 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 rO88FvzUAoqU for <notmuch@notmuchmail.org>;\r
16         Sat, 21 Mar 2015 03:16:28 -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 1EE3C431FAE\r
19         for <notmuch@notmuchmail.org>; Sat, 21 Mar 2015 03:16:28 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 81F6410008C; Sat, 21 Mar 2015 12:16:06 +0200 (EET)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: header\r
25 Date: Sat, 21 Mar 2015 12:15:55 +0200\r
26 Message-Id: <1426932955-23174-1-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 2.0.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: Sat, 21 Mar 2015 10:16:32 -0000\r
42 \r
43 Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA\r
44 use that as a part of User-Agent: header to provide more accurate\r
45 version information when sending emails.\r
46 \r
47 In case some incomplete installation of notmuch emacs MUA is used and\r
48 `notmuch-emacs-version' is defined as "unknown" then fall back to ask\r
49 version info from cli (as it used to be) -- the function to do that was\r
50 renamed from `notmuch-version' to `notmuch-cli-version' to make this\r
51 clearer and more consistent.\r
52 \r
53 The hub of getting version information is new `notmuch-versions'\r
54 function. It normally returns cons pair\r
55 (notmuch-emacs-version . notmuch-cli-version).\r
56 This function takes optional argument which makes the cdr of the return\r
57 value work differently; if `notmuch-emacs-version' is "unknown", return\r
58 pair as if the option were not given; otherwise return\r
59 (notmuch-emacs-version . notmuch-emacs-version).\r
60 This special case is useful to simplify setting User-Agent: header\r
61 -- just use the cdr of the returned value.\r
62 ---\r
63 \r
64 This is v2 of id:1407496781-17458-1-git-send-email-tomi.ollila@iki.fi\r
65 \r
66 (NEWS dropped from this one (for now) -- will arrive later)\r
67 \r
68  emacs/notmuch-hello.el | 13 +++++--------\r
69  emacs/notmuch-lib.el   | 20 +++++++++++++++++++-\r
70  emacs/notmuch-mua.el   |  2 +-\r
71  emacs/notmuch.el       |  4 ----\r
72  4 files changed, 25 insertions(+), 14 deletions(-)\r
73 \r
74 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
75 index 65d0627..62345fe 100644\r
76 --- a/emacs/notmuch-hello.el\r
77 +++ b/emacs/notmuch-hello.el\r
78 @@ -622,18 +622,15 @@ (defun notmuch-hello-window-configuration-change ()\r
79        (remove-hook 'window-configuration-change-hook\r
80                    #'notmuch-hello-window-configuration-change))))\r
81  \r
82 -;; the following variable is defined as being defconst in notmuch-version.el\r
83 -(defvar notmuch-emacs-version)\r
84 -\r
85  (defun notmuch-hello-versions ()\r
86    "Display the notmuch version(s)"\r
87    (interactive)\r
88 -  (let ((notmuch-cli-version (notmuch-version)))\r
89 +  (let ((notmuch-versions (notmuch-versions)))\r
90      (message "notmuch version %s"\r
91 -            (if (string= notmuch-emacs-version notmuch-cli-version)\r
92 -                notmuch-cli-version\r
93 -              (concat notmuch-cli-version\r
94 -                      " (emacs mua version " notmuch-emacs-version ")")))))\r
95 +            (if (string= (car notmuch-versions) (cdr notmuch-versions))\r
96 +                (car notmuch-versions)\r
97 +              (concat (cdr notmuch-versions)\r
98 +                      " (emacs mua version " (car notmuch-versions) ")")))))\r
99  \r
100  (defvar notmuch-hello-mode-map\r
101    (let ((map (if (fboundp 'make-composed-keymap)\r
102 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
103 index f8e5165..370b648 100644\r
104 --- a/emacs/notmuch-lib.el\r
105 +++ b/emacs/notmuch-lib.el\r
106 @@ -25,6 +25,10 @@\r
107  (require 'mm-decode)\r
108  (require 'cl)\r
109  \r
110 +(unless (require 'notmuch-version nil t)\r
111 +  (defconst notmuch-emacs-version "unknown"\r
112 +    "Placeholder variable when notmuch-version.el[c] is not available."))\r
113 +\r
114  (autoload 'notmuch-jump-search "notmuch-jump"\r
115    "Jump to a saved search by shortcut key." t)\r
116  \r
117 @@ -192,7 +196,7 @@ (defun notmuch-assert-cli-sane ()\r
118  "Perhaps you haven't run \"notmuch setup\" yet? Try running this\r
119  on the command line, and then retry your notmuch command")))\r
120  \r
121 -(defun notmuch-version ()\r
122 +(defun notmuch-cli-version ()\r
123    "Return a string with the notmuch version number."\r
124    (let ((long-string\r
125          ;; Trim off the trailing newline.\r
126 @@ -202,6 +206,20 @@ (defun notmuch-version ()\r
127         (match-string 2 long-string)\r
128        "unknown")))\r
129  \r
130 +(defun notmuch-versions (&optional cdr-as-emacs-version-unless-unknown)\r
131 +  "Returns cons pair (notmuch-emacs-version . (`notmuch-cli-version'))\r
132 +If optional argument CDR-AS-EMACS-VERSION-UNLESS-UNKNOWN is non-nil\r
133 +and `notmuch-emacs-version' is not \"unknown\" return cons pair\r
134 +(notmuch-emacs-version . notmuch-emacs-version).\r
135 +`notmuch-mua-user-agent-notmuch' utilizes this option, and uses the cdr\r
136 +of this cons pair in User-Agent: header"\r
137 +  (interactive)\r
138 +  (cons notmuch-emacs-version\r
139 +       (if (or (not cdr-as-emacs-version-unless-unknown)\r
140 +               (string= notmuch-emacs-version "unknown"))\r
141 +           (notmuch-cli-version)\r
142 +         notmuch-emacs-version)))\r
143 +\r
144  (defun notmuch-config-get (item)\r
145    "Return a value from the notmuch configuration."\r
146    (let* ((val (notmuch-command-to-string "config" "get" item))\r
147 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
148 index 33f1399..ac067f2 100644\r
149 --- a/emacs/notmuch-mua.el\r
150 +++ b/emacs/notmuch-mua.el\r
151 @@ -118,7 +118,7 @@ (defun notmuch-mua-user-agent-full ()\r
152  \r
153  (defun notmuch-mua-user-agent-notmuch ()\r
154    "Generate a `User-Agent:' string suitable for notmuch."\r
155 -  (concat "Notmuch/" (notmuch-version) " (http://notmuchmail.org)"))\r
156 +  (concat "Notmuch/" (cdr (notmuch-versions t)) " (http://notmuchmail.org)"))\r
157  \r
158  (defun notmuch-mua-user-agent-emacs ()\r
159    "Generate a `User-Agent:' string suitable for notmuch."\r
160 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
161 index ab00454..0cae117 100644\r
162 --- a/emacs/notmuch.el\r
163 +++ b/emacs/notmuch.el\r
164 @@ -61,10 +61,6 @@\r
165  (require 'notmuch-message)\r
166  (require 'notmuch-parser)\r
167  \r
168 -(unless (require 'notmuch-version nil t)\r
169 -  (defconst notmuch-emacs-version "unknown"\r
170 -    "Placeholder variable when notmuch-version.el[c] is not available."))\r
171 -\r
172  (defcustom notmuch-search-result-format\r
173    `(("date" . "%12s ")\r
174      ("count" . "%-7s ")\r
175 -- \r
176 2.1.0\r
177 \r