Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / f7 / 6020d143d11bc29ddc3e4cbbd2a00e4bebbb14
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 olra.theworths.org (Postfix) with ESMTP id 4824D431FAE\r
6         for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 14:22:12 -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.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id 3QEg4dbMyX7i for <notmuch@notmuchmail.org>;\r
18         Wed, 16 Apr 2014 14:22:06 -0700 (PDT)\r
19 Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com\r
20  [74.125.83.51])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
21  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
22  6FF00431FBD    for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 14:22:06 -0700\r
23  (PDT)\r
24 Received: by mail-ee0-f51.google.com with SMTP id c13so9305363eek.38\r
25         for <notmuch@notmuchmail.org>; Wed, 16 Apr 2014 14:22:05 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
28         bh=ogfNeT/6I436Njxbadw6FF11sp30sY+nXYVTsfgFkyk=;\r
29         b=a1z+I3G9v1MQ56tptaZVv4V1g+OoWXmTXEWXtejmu0co+xuT3V0Rvs22S5iHxbYzOm\r
30         5CsXteteEZcesEdI9Bl22wNS3SU0kjsvBtqOvtCHjjXbExpXLG0BDoi6yhNj/cWo4U8/\r
31         QGvTum+pD9Nl39OY2v82Wxf6W8gXV2Oo3WNF2EiOcyEQmKyX8fB+5hM43SqhQeXLTZzS\r
32         m70gf0YLufJnFZsQz07IfxfPk4ukXZZRylx6fW1VztPgBjQZlDg/omG2vlM5qPWXml3r\r
33         2sJ04QCHEpNvcc6m1AxA7g87EEP1VIQct/8reokUD3T9JBR+gHVVjcsFN6J6tGq09vL+\r
34         zdwQ==\r
35 X-Received: by 10.14.194.133 with SMTP id m5mr8020242een.38.1397683324120;\r
36         Wed, 16 Apr 2014 14:22:04 -0700 (PDT)\r
37 Received: from localhost ([217.17.137.178])\r
38         by mx.google.com with ESMTPSA id o4sm61326273eef.20.2014.04.16.14.22.03\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Wed, 16 Apr 2014 14:22:03 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 1/1] emacs: hello: bugfix for saved searches defcustom\r
45 Date: Wed, 16 Apr 2014 22:21:53 +0100\r
46 Message-Id: <1397683313-28268-2-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.10.4\r
48 In-Reply-To: <1397683313-28268-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1397683313-28268-1-git-send-email-markwalters1009@gmail.com>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Wed, 16 Apr 2014 21:22:12 -0000\r
63 \r
64 The recent changes for saved searches introduced a bug when notmuch\r
65 was loaded after the saved search was defined. This was caused by a\r
66 utility function not being defined when the defcustom was loaded.\r
67 \r
68 Fix this by moving some code around: the defcustom is moved into\r
69 notmuch-hello (which is a more natural place anyway), and the utility\r
70 functions are moved before the defcustom in notmuch-hello. We are\r
71 rather constrained as the defcustom for saved searches is the first\r
72 variable in the notmuch-hello customize window; to avoid moving this\r
73 customize the defcustom needs to be the first defcustom in\r
74 notmuch-hello, and the utility functions come before that.\r
75 \r
76 This patch also renames one of the utility functions from\r
77 notmuch--saved-searches-to-plist to\r
78 notmuch-hello--saved-searches-to-plist (as it is purely local to\r
79 notmuch-hello) and corrects a couple of typo/spelling mistakes pointed\r
80 out by Tomi.\r
81 ---\r
82  emacs/notmuch-hello.el |  128 ++++++++++++++++++++++++++++++++++--------------\r
83  emacs/notmuch-lib.el   |   52 --------------------\r
84  2 files changed, 90 insertions(+), 90 deletions(-)\r
85 \r
86 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
87 index 4900a24..a7a8e20 100644\r
88 --- a/emacs/notmuch-hello.el\r
89 +++ b/emacs/notmuch-hello.el\r
90 @@ -29,6 +29,96 @@\r
91  (declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))\r
92  (declare-function notmuch-poll "notmuch" ())\r
93  \r
94 +(defun notmuch-saved-search-get (saved-search field)\r
95 +  "Get FIELD from SAVED-SEARCH.\r
96 +\r
97 +If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
98 +backwards compatibility, this also deals with the two other\r
99 +possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and\r
100 +lists (NAME QUERY COUNT-QUERY)."\r
101 +  (cond\r
102 +   ((keywordp (car saved-search))\r
103 +    (plist-get saved-search field))\r
104 +   ;; It is not a plist so it is an old-style entry.\r
105 +   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)\r
106 +    (case field\r
107 +      (:name (first saved-search))\r
108 +      (:query (second saved-search))\r
109 +      (:count-query (third saved-search))\r
110 +      (t nil)))\r
111 +   (t  ;; It is a cons-cell (NAME . QUERY)\r
112 +    (case field\r
113 +      (:name (car saved-search))\r
114 +      (:query (cdr saved-search))\r
115 +      (t nil)))))\r
116 +\r
117 +(defun notmuch-hello-saved-search-to-plist (saved-search)\r
118 +  "Return a copy of SAVED-SEARCH in plist form.\r
119 +\r
120 +If saved search is a plist then just return a copy. In other\r
121 +cases, for backwards compatibility, convert to plist form and\r
122 +return that."\r
123 +  (if (keywordp (car saved-search))\r
124 +      (copy-seq saved-search)\r
125 +    (let ((fields (list :name :query :count-query))\r
126 +         plist-search)\r
127 +      (dolist (field fields plist-search)\r
128 +       (let ((string (notmuch-saved-search-get saved-search field)))\r
129 +         (when string\r
130 +           (setq plist-search (append plist-search (list field string)))))))))\r
131 +\r
132 +(defun notmuch-hello--saved-searches-to-plist (symbol)\r
133 +  "Extract a saved-search variable into plist form.\r
134 +\r
135 +The new style saved search is just a plist, but for backwards\r
136 +compatibility we use this function to extract old style saved\r
137 +searches so they still work in customize."\r
138 +  (let ((saved-searches (default-value symbol)))\r
139 +    (mapcar #'notmuch-hello-saved-search-to-plist saved-searches)))\r
140 +\r
141 +(define-widget 'notmuch-saved-search-plist 'list\r
142 +  "A single saved search property list."\r
143 +  :tag "Saved Search"\r
144 +  :args '((list :inline t\r
145 +               :format "%v"\r
146 +               (group :format "%v" :inline t (const :format "   Name: " :name) (string :format "%v"))\r
147 +               (group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))\r
148 +         (checklist :inline t\r
149 +                    :format "%v"\r
150 +                    (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
151 +                    (group :format "%v" :inline t (const :format "" :sort-order)\r
152 +                           (choice :tag " Sort Order"\r
153 +                                   (const :tag "Default" nil)\r
154 +                                   (const :tag "Oldest-first" oldest-first)\r
155 +                                   (const :tag "Newest-first" newest-first))))))\r
156 +\r
157 +(defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
158 +                                   (:name "unread" :query "tag:unread"))\r
159 +  "A list of saved searches to display.\r
160 +\r
161 +The saved search can be given in 3 forms. The preferred way is as\r
162 +a plist. Supported properties are\r
163 +\r
164 +  :name            Name of the search (required).\r
165 +  :query           Search to run (required).\r
166 +  :count-query     Optional extra query to generate the count\r
167 +                   shown. If not present then the :query property\r
168 +                   is used.\r
169 +  :sort-order      Specify the sort order to be used for the search.\r
170 +                   Possible values are 'oldest-first 'newest-first or\r
171 +                   nil. Nil means use the default sort order.\r
172 +\r
173 +Other accepted forms are a cons cell of the form (NAME . QUERY)\r
174 +or a list of the form (NAME QUERY COUNT-QUERY)."\r
175 +;; The saved-search format is also used by the all-tags notmuch-hello\r
176 +;; section. This section generates its own saved-search list in one of\r
177 +;; the latter two forms.\r
178 +\r
179 +  :get 'notmuch-hello--saved-searches-to-plist\r
180 +  :type '(repeat notmuch-saved-search-plist)\r
181 +  :tag "List of Saved Searches"\r
182 +  :group 'notmuch-hello)\r
183 +\r
184  (defcustom notmuch-hello-recent-searches-max 10\r
185    "The number of recent searches to display."\r
186    :type 'integer\r
187 @@ -269,44 +359,6 @@ afterwards.")\r
188        (add-to-history 'notmuch-search-history search)))\r
189    (notmuch-search search notmuch-search-oldest-first))\r
190  \r
191 -(defun notmuch-saved-search-get (saved-search field)\r
192 -  "Get FIELD from SAVED-SEARCH.\r
193 -\r
194 -If SAVED-SEARCH is a plist, this is just `plist-get', but for\r
195 -backwards compatibility, this also deals with the two other\r
196 -possible formats for SAVED-SEARCH: cons cells (NAME . QUERY) and\r
197 -lists (NAME QUERY COUNT-QUERY)."\r
198 -  (cond\r
199 -   ((keywordp (car saved-search))\r
200 -    (plist-get saved-search field))\r
201 -   ;; It is not a plist so it is an old-style entry.\r
202 -   ((consp (cdr saved-search)) ;; It is a list (NAME QUERY COUNT-QUERY)\r
203 -    (case field\r
204 -      (:name (first saved-search))\r
205 -      (:query (second saved-search))\r
206 -      (:count-query (third saved-search))\r
207 -      (t nil)))\r
208 -   (t  ;; It is a cons-cell (NAME . QUERY)\r
209 -    (case field\r
210 -      (:name (car saved-search))\r
211 -      (:query (cdr saved-search))\r
212 -      (t nil)))))\r
213 -\r
214 -(defun notmuch-hello-saved-search-to-plist (saved-search)\r
215 -  "Return a copy of SAVED-SEARCH in plist form.\r
216 -\r
217 -If saved search is a plist then just return a copy. In other\r
218 -cases, for backwards compatability, convert to plist form and\r
219 -return that."\r
220 -  (if (keywordp (car saved-search))\r
221 -      (copy-seq saved-search)\r
222 -    (let ((fields (list :name :query :count-query))\r
223 -         plist-search)\r
224 -      (dolist (field fields plist-search)\r
225 -       (let ((string (notmuch-saved-search-get saved-search field)))\r
226 -         (when string\r
227 -           (setq plist-search (append plist-search (list field string)))))))))\r
228 -\r
229  (defun notmuch-hello-add-saved-search (widget)\r
230    (interactive)\r
231    (let ((search (widget-value\r
232 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
233 index 3a3c69d..2941da3 100644\r
234 --- a/emacs/notmuch-lib.el\r
235 +++ b/emacs/notmuch-lib.el\r
236 @@ -107,58 +107,6 @@ Note that the recommended way of achieving the same is using\r
237  (defvar notmuch-search-history nil\r
238    "Variable to store notmuch searches history.")\r
239  \r
240 -(defun notmuch--saved-searches-to-plist (symbol)\r
241 -  "Extract a saved-search variable into plist form.\r
242 -\r
243 -The new style saved search is just a plist, but for backwards\r
244 -compatatibility we use this function to extract old style saved\r
245 -searches so they still work in customize."\r
246 -  (let ((saved-searches (default-value symbol)))\r
247 -    (mapcar #'notmuch-hello-saved-search-to-plist saved-searches)))\r
248 -\r
249 -(define-widget 'notmuch-saved-search-plist 'list\r
250 -  "A single saved search property list."\r
251 -  :tag "Saved Search"\r
252 -  :args '((list :inline t\r
253 -               :format "%v"\r
254 -               (group :format "%v" :inline t (const :format "   Name: " :name) (string :format "%v"))\r
255 -               (group :format "%v" :inline t (const :format "  Query: " :query) (string :format "%v")))\r
256 -         (checklist :inline t\r
257 -                    :format "%v"\r
258 -                    (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))\r
259 -                    (group :format "%v" :inline t (const :format "" :sort-order)\r
260 -                           (choice :tag " Sort Order"\r
261 -                                   (const :tag "Default" nil)\r
262 -                                   (const :tag "Oldest-first" oldest-first)\r
263 -                                   (const :tag "Newest-first" newest-first))))))\r
264 -\r
265 -(defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
266 -                                   (:name "unread" :query "tag:unread"))\r
267 -  "A list of saved searches to display.\r
268 -\r
269 -The saved search can be given in 3 forms. The preferred way is as\r
270 -a plist. Supported properties are\r
271 -\r
272 -  :name            Name of the search (required).\r
273 -  :query           Search to run (required).\r
274 -  :count-query     Optional extra query to generate the count\r
275 -                   shown. If not present then the :query property\r
276 -                   is used.\r
277 -  :sort-order      Specify the sort order to be used for the search.\r
278 -                   Possible values are 'oldest-first 'newest-first or\r
279 -                   nil. Nil means use the default sort order.\r
280 -\r
281 -Other accepted forms are a cons cell of the form (NAME . QUERY)\r
282 -or a list of the form (NAME QUERY COUNT-QUERY)."\r
283 -;; The saved-search format is also used by the all-tags notmuch-hello\r
284 -;; section. This section generates its own saved-search list in one of\r
285 -;; the latter two forms.\r
286 -\r
287 -  :get 'notmuch--saved-searches-to-plist\r
288 -  :type '(repeat notmuch-saved-search-plist)\r
289 -  :tag "List of Saved Searches"\r
290 -  :group 'notmuch-hello)\r
291 -\r
292  (defcustom notmuch-archive-tags '("-inbox")\r
293    "List of tag changes to apply to a message or a thread when it is archived.\r
294  \r
295 -- \r
296 1.7.10.4\r
297 \r