Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 7c / b17ec00db48d49b968970c2dcb5892291e4cd9
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 arlo.cworth.org (Postfix) with ESMTP id E42FD6DE119C\r
6  for <notmuch@notmuchmail.org>; Mon, 28 Dec 2015 03:50:18 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.314\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.314 tagged_above=-999 required=5 tests=[AWL=1.536,\r
12   RCVD_IN_DNSWL_MED=-2.3, RP_MATCHES_RCVD=-0.55] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id gaO_pmHmWPgR for <notmuch@notmuchmail.org>;\r
16  Mon, 28 Dec 2015 03:50:15 -0800 (PST)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18  by arlo.cworth.org (Postfix) with ESMTP id 4DAAB6DE111A\r
19  for <notmuch@notmuchmail.org>; Mon, 28 Dec 2015 03:50:15 -0800 (PST)\r
20 Received: from localhost (unknown [192.168.200.7])\r
21  by max.feld.cvut.cz (Postfix) with ESMTP id 403B819F4819;\r
22  Mon, 28 Dec 2015 12:50:13 +0100 (CET)\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, port 10044)\r
26  with ESMTP id a54nygSRp_w2; Mon, 28 Dec 2015 12:50:11 +0100 (CET)\r
27 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
28  by max.feld.cvut.cz (Postfix) with ESMTP id 1EC6A19F47EA;\r
29  Mon, 28 Dec 2015 12:50:10 +0100 (CET)\r
30 Received: from wsh by steelpick.2x.cz with local (Exim 4.86)\r
31  (envelope-from <sojkam1@fel.cvut.cz>)\r
32  id 1aDWJU-0006IO-HO; Mon, 28 Dec 2015 12:50:08 +0100\r
33 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
34 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
35 Subject: Re: [PATCH] emacs: address completion,\r
36  allow sender/recipient and filters\r
37 In-Reply-To: <1450602453-2623-1-git-send-email-markwalters1009@gmail.com>\r
38 References: <1450602453-2623-1-git-send-email-markwalters1009@gmail.com>\r
39 User-Agent: Notmuch/0.21+30~g55c056a (http://notmuchmail.org) Emacs/24.5.1\r
40  (x86_64-pc-linux-gnu)\r
41 Date: Mon, 28 Dec 2015 12:50:08 +0100\r
42 Message-ID: <874mf2yeq7.fsf@steelpick.2x.cz>\r
43 MIME-Version: 1.0\r
44 Content-Type: text/plain\r
45 X-BeenThere: notmuch@notmuchmail.org\r
46 X-Mailman-Version: 2.1.20\r
47 Precedence: list\r
48 List-Id: "Use and development of the notmuch mail system."\r
49  <notmuch.notmuchmail.org>\r
50 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
51  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
53 List-Post: <mailto:notmuch@notmuchmail.org>\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
55 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
56  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
57 X-List-Received-Date: Mon, 28 Dec 2015 11:50:19 -0000\r
58 \r
59 Hi Mark,\r
60 \r
61 I tried this patch. When I set the variable to 'received, first\r
62 completion candidates are generated incorrectly. The query looked as\r
63 "(to:sojkam1@fel.cvut.cz) and (to:prefix*)". It should be "...\r
64 (from:prefix*)". This "to:" comes from notmuch-address-options or from\r
65 notmuch-company so these should be changes as well.\r
66 \r
67 Other minor comments are below.\r
68 \r
69 Thanks.\r
70 -Michal\r
71 \r
72 On Sun, Dec 20 2015, Mark Walters wrote:\r
73 > This commit lets the user customize the address completion.\r
74 >\r
75 > The first change controls whether to build the address completion list\r
76 > based on messages you have sent or you have received (the latter is\r
77 > much faster).\r
78 >\r
79 > The second change add a possible filter query to limit the messages\r
80 > used -- for example, setting this to date:1y..  would limit the\r
81 > address completions to addresses used in the last year. This speeds up\r
82 > the address harvest and may also make the search less cluttered as old\r
83 > addresses may well no longer be valid.\r
84 > ---\r
85 >\r
86 > There was some discussion on irc about the address completion harvest\r
87 > taking a long time. This patch makes is possible to tune this\r
88 > behaviour. It may be that this complicates the customize variable too\r
89 > much -- but if nothing else its a patch that anyone who experiences\r
90 > problems can try.\r
91 >\r
92 > Best wishes\r
93 >\r
94 > Mark\r
95 >\r
96 > emacs/notmuch-address.el | 64 +++++++++++++++++++++++++++++++++---------------\r
97 >  1 file changed, 44 insertions(+), 20 deletions(-)\r
98 >\r
99 > diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
100 > index 49e2402..8942fe4 100644\r
101 > --- a/emacs/notmuch-address.el\r
102 > +++ b/emacs/notmuch-address.el\r
103 > @@ -26,15 +26,40 @@\r
104 >  ;;\r
105 >  (declare-function company-manual-begin "company")\r
106 >\r
107 > +(defvar notmuch-address-last-harvest 0\r
108 > +  "Time of last address harvest")\r
109 > +\r
110 > +(defvar notmuch-address-completions (make-hash-table :test 'equal)\r
111 > +  "Hash of email addresses for completion during email composition.\r
112 > +  This variable is set by calling `notmuch-address-harvest'.")\r
113 > +\r
114 > +(defvar notmuch-address-full-harvest-finished nil\r
115 > +  "t indicates that full completion address harvesting has been\r
116 > +finished")\r
117 > +\r
118 >  (defcustom notmuch-address-command 'internal\r
119 \r
120 Default value should be changed to something matching the :type. Perhaps\r
121 '(sent nil).\r
122 \r
123 >    "The command which generates possible addresses. It must take a\r
124 >  single argument and output a list of possible matches, one per\r
125 >  line. The default value of `internal' uses built-in address\r
126 >  completion."\r
127 \r
128 Doc text can be updated as well.\r
129 \r
130 >    :type '(radio\r
131 > -       (const :tag "Use internal address completion" internal)\r
132 > +       (list :tag "Use internal address completion"\r
133 > +             (radio\r
134 > +              :tag "Build list based on messages you have"\r
135 > +              :value sent\r
136 > +              (const :tag "sent" sent)\r
137 > +              (const :tag "received" received))\r
138 \r
139 I would mention that received is faster here.\r
140 \r
141 > +             (radio :tag "Filter messages used for completion"\r
142 > +                    (const :tag "Use all messages" nil)\r
143 > +                    (string :tag "Filter query")))\r
144 >         (const :tag "Disable address completion" nil)\r
145 > -       (string :tag "Use external completion command" "notmuch-addresses"))\r
146 > +       (string :tag "Use external completion command"))\r
147 > +  ;; We override set so that we can clear the cache when this changes\r
148 > +  :set (lambda (symbol value)\r
149 > +      (set-default symbol value)\r
150 > +      (setq notmuch-address-last-harvest 0)\r
151 > +      (setq notmuch-address-completions (clrhash notmuch-address-completions))\r
152 > +      (setq notmuch-address-full-harvest-finished nil))\r
153 >    :group 'notmuch-send\r
154 >    :group 'notmuch-external)\r
155 >\r
156 > @@ -49,17 +74,6 @@ to know how address selection is made by default."\r
157 >    :group 'notmuch-send\r
158 >    :group 'notmuch-external)\r
159 >\r
160 > -(defvar notmuch-address-last-harvest 0\r
161 > -  "Time of last address harvest")\r
162 > -\r
163 > -(defvar notmuch-address-completions (make-hash-table :test 'equal)\r
164 > -  "Hash of email addresses for completion during email composition.\r
165 > -  This variable is set by calling `notmuch-address-harvest'.")\r
166 > -\r
167 > -(defvar notmuch-address-full-harvest-finished nil\r
168 > -  "t indicates that full completion address harvesting has been\r
169 > -finished")\r
170 > -\r
171 >  (defun notmuch-address-selection-function (prompt collection initial-input)\r
172 >    "Call (`completing-read'\r
173 >        PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)"\r
174 > @@ -81,7 +95,8 @@ finished")\r
175 >\r
176 >  (defun notmuch-address-setup ()\r
177 >    (let* ((use-company (and notmuch-address-use-company\r
178 > -                        (eq notmuch-address-command 'internal)\r
179 > +                        notmuch-address-command\r
180 > +                        (listp notmuch-address-command)\r
181 >                          (require 'company nil t)))\r
182 >        (pair (cons notmuch-address-completion-headers-regexp\r
183 >                    (if use-company\r
184 > @@ -109,7 +124,7 @@ The candidates are taken from `notmuch-address-completions'."\r
185 >  elisp-based implementation or older implementation requiring\r
186 >  external commands."\r
187 >    (cond\r
188 > -   ((eq notmuch-address-command 'internal)\r
189 > +   ((and notmuch-address-command (listp notmuch-address-command))\r
190 >      (when (not notmuch-address-full-harvest-finished)\r
191 >        ;; First, run quick synchronous harvest based on what the user\r
192 >        ;; entered so far\r
193 > @@ -198,12 +213,21 @@ addresses from those messages and stores them in\r
194 >  time so the address collection runs asynchronously unless\r
195 >  SYNCHRONOUS is t. In case of asynchronous execution, CALLBACK is\r
196 >  called when harvesting finishes."\r
197 > -  (let* ((from-me-query (mapconcat (lambda (x) (concat "from:" x)) (notmuch-user-emails) " or "))\r
198 > -      (query (if filter-query\r
199 > -                 (format "(%s) and (%s)" from-me-query filter-query)\r
200 > -               from-me-query))\r
201 > +  (let* ((sent (eq (car notmuch-address-command) 'sent))\r
202 > +      (user-query (cadr notmuch-address-command))\r
203 > +      (from-or-to-me-query\r
204 > +       (mapconcat (lambda (x)\r
205 > +                    (concat (if sent "from:" "to:") x))\r
206 > +                  (notmuch-user-emails) " or "))\r
207 > +      (query (if (or filter-query user-query)\r
208 > +                 (concat (format "(%s)" from-or-to-me-query)\r
209 > +                         (when filter-query\r
210 > +                           (format " and (%s)" filter-query))\r
211 > +                         (when user-query\r
212 > +                           (format " and (%s)" user-query)))\r
213 > +               from-or-to-me-query))\r
214 >        (args `("address" "--format=sexp" "--format-version=2"\r
215 > -              "--output=recipients"\r
216 > +              ,(if sent "--output=recipients" "--output=sender")\r
217 >                "--deduplicate=address"\r
218 >                ,query)))\r
219 >      (if synchronous\r
220 > --\r
221 > 2.1.4\r
222 >\r
223 > _______________________________________________\r
224 > notmuch mailing list\r
225 > notmuch@notmuchmail.org\r
226 > https://notmuchmail.org/mailman/listinfo/notmuch\r