1 Return-Path: <markwalters1009@gmail.com>
\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 arlo.cworth.org (Postfix) with ESMTP id 6BBBD6DE0281
\r
6 for <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:26 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.182 tagged_above=-999 required=5 tests=[AWL=-0.248,
\r
12 DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1,
\r
14 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01,
\r
15 SPF_PASS=-0.001] autolearn=disabled
\r
16 Received: from arlo.cworth.org ([127.0.0.1])
\r
17 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
18 with ESMTP id 0FBO0F28V99r for <notmuch@notmuchmail.org>;
\r
19 Fri, 20 May 2016 13:13:18 -0700 (PDT)
\r
20 Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com
\r
21 [74.125.82.48]) by arlo.cworth.org (Postfix) with ESMTPS id 0F6E66DE01CE for
\r
22 <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:18 -0700 (PDT)
\r
23 Received: by mail-wm0-f48.google.com with SMTP id v200so2818136wmv.0
\r
24 for <notmuch@notmuchmail.org>; Fri, 20 May 2016 13:13:17 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=from:to:cc:subject:date:message-id;
\r
27 bh=di1RZqcqxyYRh+BASsJS1UDdmRgJtVtovHAKBWtI60E=;
\r
28 b=yTjJ75N1BpirPdvPp0Pz+mtEawM9CuVH1cNpia3bDGVHmKlzkgcu2BjuJwWgfFYLUe
\r
29 Y/tgL7Hb2Rk9o4NxEdMg9mbP8dbNpKONhuOLLrwGcWpkgCHiH5UfqkQqeH1ob9OPdf9w
\r
30 DsyL/4IHyMSvmCz+7zplRmckGFQ8q23NyZs1Aq0FzbykkClAQItZWnNVCWN1qDVUafyH
\r
31 PWNM2/OqJ7a3OnfbS+pj8eNHfLSE2TJUg5MeKcevZPJdntm1TUpXPa+nSYrJEGaXW+V9
\r
32 JgZJUtfsK50He2Th8RD5V5HZFkZ/SA2ezttjIiwavpO4Hvt57FCxwhDMfPmVvGz8ZyjU
\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
35 d=1e100.net; s=20130820;
\r
36 h=x-gm-message-state:from:to:cc:subject:date:message-id;
\r
37 bh=di1RZqcqxyYRh+BASsJS1UDdmRgJtVtovHAKBWtI60E=;
\r
38 b=c3iZYCTtS/hzQfbblY2ckf+9E/SFSNfpGh8aK6khySiThyjWvDcQxkOseI4PUUcMV3
\r
39 VO5bZxSkTV94trQi3NvGGFzHNEoOD/fFbIaGn71pkqX+14SV01RjSQaOHEsF5cBX1ilY
\r
40 PqnUdFCg1axjQ28q5FNEnW4AsiZMnvkePU6An0D2znQYB1WknNEOJdWFr85Z+v+anP0J
\r
41 etFTXF+kcg5CMK8N88FoXBra/sQBSdzoz2S4BTwcjaFnZgM33iusHevnsGNrjsA7HSNT
\r
42 cQFRa/a64LUch0nZvQat+AHl/WWqqy9Ca4+KGmka8wlxuh5ezEXCdoaeTS66AlYdslOW
\r
45 AOPr4FVQgfNV6IhgDom9MGhFxzMRJUozYUAs5FgvIJwYzBSP53n0838LkXlW/jcGkmaG0A==
\r
46 X-Received: by 10.28.56.4 with SMTP id f4mr5289227wma.70.1463775196014;
\r
47 Fri, 20 May 2016 13:13:16 -0700 (PDT)
\r
48 Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])
\r
49 by smtp.gmail.com with ESMTPSA id ug8sm21346747wjc.42.2016.05.20.13.13.13
\r
50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
51 Fri, 20 May 2016 13:13:13 -0700 (PDT)
\r
52 From: Mark Walters <markwalters1009@gmail.com>
\r
53 To: notmuch@notmuchmail.org
\r
54 Subject: [PATCH 0/2] Address completion configuration
\r
55 Date: Fri, 20 May 2016 21:13:01 +0100
\r
56 Message-Id: <1463775183-16234-1-git-send-email-markwalters1009@gmail.com>
\r
57 X-Mailer: git-send-email 2.1.4
\r
58 X-BeenThere: notmuch@notmuchmail.org
\r
59 X-Mailman-Version: 2.1.20
\r
61 List-Id: "Use and development of the notmuch mail system."
\r
62 <notmuch.notmuchmail.org>
\r
63 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
66 List-Post: <mailto:notmuch@notmuchmail.org>
\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
68 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
69 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
70 X-List-Received-Date: Fri, 20 May 2016 20:13:26 -0000
\r
72 These two patches allow some customization of the notmuch-address
\r
75 The first patch is very similar to the patch at
\r
76 id:1463558813-23603-1-git-send-email-markwalters1009@gmail.com
\r
78 The second allows the user to use the internal completion on a case by
\r
79 case basis. Typically this would be useful for users who normally use
\r
80 some external command for completion, but would like to use the
\r
81 internal completion when that fails.
\r
83 This necessitated some changes to the first patch: it made sense to
\r
84 separate the customisation of the internal address (as this will be
\r
85 also used for the case by case uses of the internal completion) from
\r
86 the choice of whether to use internal or external completion by
\r
87 default. I include the inter-diff of the first patch and the previous
\r
89 id:1463558813-23603-1-git-send-email-markwalters1009@gmail.com at the
\r
92 The downside is that it does mean there is an extra defcustom, but the
\r
93 code is slightly cleaner.
\r
95 It might make sense to have a keybinding for company-complete
\r
96 and/or notmuch-address-toggle-internal-completion in
\r
97 notmuch-mesage-mode but I had no idea what bindings would make sense.
\r
99 I don't know how many people still use external completion -- but the
\r
100 extra complexity on top of the previous version is fairly small. Also,
\r
101 I haven't tested this heavily -- and there are quite a lot of cases.
\r
111 emacs: address completion, allow sender/recipient and filters
\r
112 emacs: address: allow internal completion on an individual basis
\r
114 emacs/notmuch-address.el | 154 ++++++++++++++++++++++++++++++++++-------------
\r
115 emacs/notmuch-company.el | 10 ++-
\r
116 emacs/notmuch-mua.el | 3 +-
\r
117 3 files changed, 121 insertions(+), 46 deletions(-)
\r
120 inter-diff from id:1463558813-23603-1-git-send-email-markwalters1009@gmail.com
\r
122 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
\r
123 index 62df8ba..3e7bdab 100644
\r
124 --- a/emacs/notmuch-address.el
\r
125 +++ b/emacs/notmuch-address.el
\r
126 @@ -39,34 +39,45 @@
\r
127 "t indicates that full completion address harvesting has been
\r
130 -(defcustom notmuch-address-command '(sent nil)
\r
131 - "Determines how to generate address completion candidates.
\r
132 +(defcustom notmuch-address-command 'internal
\r
133 + "Determines how address completion candidates are generated.
\r
135 If it is a string then that string should be an external program
\r
136 which must take a single argument (searched string) and output a
\r
137 list of completion candidates, one per line.
\r
139 -Alternatively, it can be a (non-nil) list, in which case internal
\r
140 -completion is used; in this case the list should have form
\r
141 -'(DIRECTION FILTER), where DIRECTION is either sent or received
\r
142 -and specifies whether the candidates are searched in messages
\r
143 -sent by the user or received by the user (note received by is
\r
144 -much faster), and FILTER is either nil or a filter-string, such
\r
145 -as \"date:1y..\" to append to the query.
\r
146 +Alternatively, it can be the symbol 'internal, in which case
\r
147 +internal completion is used; the variable
\r
148 +`notmuch-address-internal-completion` can be used to customize
\r
151 -If this variable is nil then address completion is disabled."
\r
152 +Finally, if this variable is nil then address completion is
\r
155 - (list :tag "Use internal address completion"
\r
157 - :tag "Base completion on messages you have"
\r
159 - (const :tag "sent (more accurate)" sent)
\r
160 - (const :tag "received (faster)" received))
\r
161 - (radio :tag "Filter messages used for completion"
\r
162 - (const :tag "Use all messages" nil)
\r
163 - (string :tag "Filter query")))
\r
164 + (const :tag "Use internal address completion" internal)
\r
165 (const :tag "Disable address completion" nil)
\r
166 (string :tag "Use external completion command"))
\r
167 + :group 'notmuch-send
\r
168 + :group 'notmuch-external)
\r
170 +(defcustom notmuch-address-internal-completion '(sent nil)
\r
171 + "Determines how internal address completion generates candidates.
\r
173 +This should be a list of the form '(DIRECTION FILTER), where
\r
174 + DIRECTION is either sent or received and specifies whether the
\r
175 + candidates are searched in messages sent by the user or received
\r
176 + by the user (note received by is much faster), and FILTER is
\r
177 + either nil or a filter-string, such as \"date:1y..\" to append
\r
179 + :type '(list :tag "Use internal address completion"
\r
181 + :tag "Base completion on messages you have"
\r
183 + (const :tag "sent (more accurate)" sent)
\r
184 + (const :tag "received (faster)" received))
\r
185 + (radio :tag "Filter messages used for completion"
\r
186 + (const :tag "Use all messages" nil)
\r
187 + (string :tag "Filter query")))
\r
188 ;; We override set so that we can clear the cache when this changes
\r
189 :set (lambda (symbol value)
\r
190 (set-default symbol value)
\r
191 @@ -108,13 +119,10 @@ to know how address selection is made by default."
\r
193 (defun notmuch-address-setup ()
\r
194 (let* ((use-company (and notmuch-address-use-company
\r
195 - notmuch-address-command
\r
196 - (listp notmuch-address-command)
\r
197 + (eq notmuch-address-command 'internal)
\r
198 (require 'company nil t)))
\r
199 (pair (cons notmuch-address-completion-headers-regexp
\r
201 - #'company-manual-begin
\r
202 - #'notmuch-address-expand-name))))
\r
203 + #'notmuch-address-expand-name)))
\r
205 (notmuch-company-setup))
\r
206 (unless (memq pair message-completion-alist)
\r
207 @@ -137,7 +145,7 @@ The candidates are taken from `notmuch-address-completions'."
\r
208 elisp-based implementation or older implementation requiring
\r
209 external commands."
\r
211 - ((and notmuch-address-command (listp notmuch-address-command))
\r
212 + ((eq notmuch-address-command 'internal)
\r
213 (when (not notmuch-address-full-harvest-finished)
\r
214 ;; First, run quick synchronous harvest based on what the user
\r
216 @@ -149,7 +157,12 @@ external commands."
\r
217 (process-lines notmuch-address-command original))))
\r
219 (defun notmuch-address-expand-name ()
\r
220 - (when notmuch-address-command
\r
222 + ((and (eq notmuch-address-command 'internal)
\r
223 + notmuch-address-use-company
\r
224 + (bound-and-true-p company-mode))
\r
225 + (company-manual-begin))
\r
226 + (notmuch-address-command
\r
227 (let* ((end (point))
\r
228 (beg (save-excursion
\r
229 (re-search-backward "\\(\\`\\|[\n:,]\\)[ \t]*")
\r
230 @@ -175,7 +188,8 @@ external commands."
\r
231 (delete-region beg end)
\r
233 (message "No matches.")
\r
238 ;; Copied from `w3m-which-command'.
\r
239 (defun notmuch-address-locate-command (command)
\r
240 @@ -232,8 +246,8 @@ Address harvesting may take some time so the address collection runs
\r
241 asynchronously unless SYNCHRONOUS is t. In case of asynchronous
\r
242 execution, CALLBACK is called when harvesting finishes."
\r
244 - (let* ((sent (eq (car notmuch-address-command) 'sent))
\r
245 - (config-query (cadr notmuch-address-command))
\r
246 + (let* ((sent (eq (car notmuch-address-internal-completion) 'sent))
\r
247 + (config-query (cadr notmuch-address-internal-completion))
\r
248 (prefix-query (when addr-prefix
\r
249 (format "%s:%s*" (if sent "to" "from") addr-prefix)))
\r
250 (from-or-to-me-query
\r
251 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
\r
252 index 399e138..93a4d4b 100644
\r
253 --- a/emacs/notmuch-mua.el
\r
254 +++ b/emacs/notmuch-mua.el
\r
255 @@ -276,8 +276,7 @@ mutiple parts get a header."
\r
257 (define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"
\r
258 "Notmuch message composition mode. Mostly like `message-mode'"
\r
259 - (when notmuch-address-command
\r
260 - (notmuch-address-setup)))
\r
261 + (notmuch-address-setup))
\r
263 (put 'notmuch-message-mode 'flyspell-mode-predicate 'mail-mode-flyspell-verify)
\r