Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 71 / 566c1b9d372fc4d83a88e216d2db9646834f77
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 15C38431FD4\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:16 -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 WmMQ3Q+gLWlH for <notmuch@notmuchmail.org>;\r
18         Sat,  5 Apr 2014 22:45:10 -0700 (PDT)\r
19 Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com\r
20         [209.85.212.182]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id A799A431FBF\r
23         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 22:45:07 -0700 (PDT)\r
24 Received: by mail-wi0-f182.google.com with SMTP id d1so3311314wiv.9\r
25         for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 22:45:06 -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=NGRfCsBSC5wLIhMeVkPiijOAySG24U1BPVgFCyJv/7o=;\r
29         b=itN0RKcPs6fT1puvKhLoB5a+XkGHEWH4ylt/nkSl22fKpGahm8F2aGrje+Z0NiI5Fc\r
30         +q4b8XtIDy1k7urNuw5Ye5ZbFostGYTLnj6Vkc7FP9w7czZPxyGvaO7qZc5Qex6fJWhb\r
31         9YEFgl3hRsMqDPQQeQmKwXbJEnc1jcL+CVvsFQINDBeX3mkTgQjhHSgUmlKUfJ4tZaIW\r
32         8rlKxUQaY3hj41cCT2ipSW8F1dUhQapPNZwuvufNKw3bxlmMb3ns+cDHxTzqAiNcFlKZ\r
33         Soy0naGw0jlwfX/iFFVjIoCX1NJV1J6lgQIYzBx/GfP/e2zPtvUj+wgkg0MJI2ECOPDk\r
34         FsdQ==\r
35 X-Received: by 10.180.188.130 with SMTP id ga2mr16741265wic.18.1396763106564; \r
36         Sat, 05 Apr 2014 22:45:06 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id\r
39         rx9sm20131441wjb.20.2014.04.05.22.45.05 for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 05 Apr 2014 22:45:05 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org,\r
44         amdragon@MIT.EDU\r
45 Subject: [PATCH v2 2/5] emacs: hello: use the saved-search helper functions\r
46 Date: Sun,  6 Apr 2014 06:44:46 +0100\r
47 Message-Id: <1396763089-32452-3-git-send-email-markwalters1009@gmail.com>\r
48 X-Mailer: git-send-email 1.7.10.4\r
49 In-Reply-To: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
50 References: <1396763089-32452-1-git-send-email-markwalters1009@gmail.com>\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Sun, 06 Apr 2014 05:45:16 -0000\r
64 \r
65 This uses the helper functions: the saved searches format has not\r
66 changed yet but backwards compatibility means everything still works.\r
67 ---\r
68  emacs/notmuch-hello.el |   48 ++++++++++++++++++++++--------------------------\r
69  emacs/notmuch.el       |    6 +++---\r
70  2 files changed, 25 insertions(+), 29 deletions(-)\r
71 \r
72 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
73 index f81ec27..568ae47 100644\r
74 --- a/emacs/notmuch-hello.el\r
75 +++ b/emacs/notmuch-hello.el\r
76 @@ -318,7 +318,7 @@ (defun notmuch-hello-add-saved-search (widget)\r
77      (setq notmuch-saved-searches\r
78           (loop for elem in notmuch-saved-searches\r
79                 if (not (equal name\r
80 -                              (car elem)))\r
81 +                              (notmuch-saved-search-get elem :name)))\r
82                 collect elem))\r
83      ;; Add the new one.\r
84      (customize-save-variable 'notmuch-saved-searches\r
85 @@ -338,7 +338,7 @@ (defun notmuch-hello-delete-search-from-history (widget)\r
86  \r
87  (defun notmuch-hello-longest-label (searches-alist)\r
88    (or (loop for elem in searches-alist\r
89 -           maximize (length (car elem)))\r
90 +           maximize (length (notmuch-saved-search-get elem :name)))\r
91        0))\r
92  \r
93  (defun notmuch-hello-reflect-generate-row (ncols nrows row list)\r
94 @@ -417,13 +417,12 @@ (defun notmuch-hello-filtered-query (query filter)\r
95      (concat "(" query ") and (" filter ")"))\r
96     (t query)))\r
97  \r
98 -(defun notmuch-hello-query-counts (query-alist &rest options)\r
99 -  "Compute list of counts of matched messages from QUERY-ALIST.\r
100 +(defun notmuch-hello-query-counts (query-list &rest options)\r
101 +  "Compute list of counts of matched messages from QUERY-LIST.\r
102  \r
103 -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
104 -or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
105 -COUNT-QUERY specifies an alternate query to be used to generate\r
106 -the count for the associated query.\r
107 +QUERY-LIST must be a list of saved-searches. Ideally each of\r
108 +these is a plist but other options are available for backwards\r
109 +compatibility: see `notmuch-saved-searches' for details.\r
110  \r
111  The result is the list of elements of the form (NAME QUERY COUNT).\r
112  \r
113 @@ -431,11 +430,9 @@ (defun notmuch-hello-query-counts (query-alist &rest options)\r
114  options will be handled as specified for\r
115  `notmuch-hello-insert-searches'."\r
116    (with-temp-buffer\r
117 -    (dolist (elem query-alist nil)\r
118 -      (let ((count-query (if (consp (cdr elem))\r
119 -                            ;; do we have a different query for the message count?\r
120 -                            (third elem)\r
121 -                          (cdr elem))))\r
122 +    (dolist (elem query-list nil)\r
123 +      (let ((count-query (or (notmuch-saved-search-get elem :count-query)\r
124 +                            (notmuch-saved-search-get elem :query))))\r
125         (insert\r
126          (replace-regexp-in-string\r
127           "\n" " "\r
128 @@ -457,18 +454,15 @@ (defun notmuch-hello-query-counts (query-alist &rest options)\r
129       #'identity\r
130       (mapcar\r
131        (lambda (elem)\r
132 -       (let ((name (car elem))\r
133 -             (search-query (if (consp (cdr elem))\r
134 -                                ;; do we have a different query for the message count?\r
135 -                                (second elem)\r
136 -                             (cdr elem)))\r
137 +       (let ((name (notmuch-saved-search-get elem :name))\r
138 +             (search-query (notmuch-saved-search-get elem :query))\r
139               (message-count (prog1 (read (current-buffer))\r
140                                 (forward-line 1))))\r
141           (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
142                (list name (notmuch-hello-filtered-query\r
143                            search-query (plist-get options :filter))\r
144                      message-count))))\r
145 -      query-alist))))\r
146 +      query-list))))\r
147  \r
148  (defun notmuch-hello-insert-buttons (searches)\r
149    "Insert buttons for SEARCHES.\r
150 @@ -727,13 +721,15 @@ (defun notmuch-hello-insert-recent-searches ()\r
151        (indent-rigidly start (point) notmuch-hello-indent))\r
152      nil))\r
153  \r
154 -(defun notmuch-hello-insert-searches (title query-alist &rest options)\r
155 -  "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST.\r
156 +(defun notmuch-hello-insert-searches (title query-list &rest options)\r
157 +  "Insert a section with TITLE showing a list of buttons made from QUERY-LIST.\r
158  \r
159 -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
160 -or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
161 -COUNT-QUERY specifies an alternate query to be used to generate\r
162 -the count for the associated item.\r
163 +QUERY-LIST should ideally be a plist but for backwards\r
164 +compatibility other forms are also accepted (see\r
165 +`notmuch-saved-searches' for details).  The plist should\r
166 +contain keys :name and :query; if :count-query is also present\r
167 +then it specifies an alternate query to be used to generate the\r
168 +count for the associated search.\r
169  \r
170  Supports the following entries in OPTIONS as a plist:\r
171  :initially-hidden - if non-nil, section will be hidden on startup\r
172 @@ -767,7 +763,7 @@ (defun notmuch-hello-insert-searches (title query-alist &rest options)\r
173                      "hide"))\r
174      (widget-insert "\n")\r
175      (when (not is-hidden)\r
176 -      (let ((searches (apply 'notmuch-hello-query-counts query-alist options)))\r
177 +      (let ((searches (apply 'notmuch-hello-query-counts query-list options)))\r
178         (when (or (not (plist-get options :hide-if-empty))\r
179                   searches)\r
180           (widget-insert "\n")\r
181 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
182 index 233c784..1346b90 100644\r
183 --- a/emacs/notmuch.el\r
184 +++ b/emacs/notmuch.el\r
185 @@ -823,14 +823,14 @@ (defun notmuch-search-buffer-title (query)\r
186           (let (longest\r
187                 (longest-length 0))\r
188             (loop for tuple in notmuch-saved-searches\r
189 -                 if (let ((quoted-query (regexp-quote (cdr tuple))))\r
190 +                 if (let ((quoted-query (regexp-quote (notmuch-saved-search-get tuple :query))))\r
191                        (and (string-match (concat "^" quoted-query) query)\r
192                             (> (length (match-string 0 query))\r
193                                longest-length)))\r
194                   do (setq longest tuple))\r
195             longest))\r
196 -        (saved-search-name (car saved-search))\r
197 -        (saved-search-query (cdr saved-search)))\r
198 +        (saved-search-name (notmuch-saved-search-get saved-search :name))\r
199 +        (saved-search-query (notmuch-saved-search-get saved-search :query)))\r
200      (cond ((and saved-search (equal saved-search-query query))\r
201            ;; Query is the same as saved search (ignoring case)\r
202            (concat "*notmuch-saved-search-" saved-search-name "*"))\r
203 -- \r
204 1.7.10.4\r
205 \r