Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / e5 / c4fd9d5e7e296a8e1a1f7fc5df803c6c3ba03c
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 DC8C6431FD7\r
6         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 14:24:57 -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 40x7qX-qgyHX for <notmuch@notmuchmail.org>;\r
18         Sat,  5 Apr 2014 14:24:52 -0700 (PDT)\r
19 Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com\r
20         [209.85.212.177]) (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 C85F3431FC2\r
23         for <notmuch@notmuchmail.org>; Sat,  5 Apr 2014 14:24:47 -0700 (PDT)\r
24 Received: by mail-wi0-f177.google.com with SMTP id cc10so3059425wib.10\r
25         for <notmuch@notmuchmail.org>; Sat, 05 Apr 2014 14:24:46 -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=r3ODfphJoiR2U84CiwW/8hyOZI2OF05FAWAYQ/iAtHs=;\r
29         b=cTkx7NCSBP8vGZMtBNB84mEMoyrDFQJ0kVP7bYZMDcBFf1Ga2J0qxzwkStotdZY39m\r
30         O5AuoieHiPjZLJWuHdv5q1Unjszukq5CVA2LdYL4HUW4uHVNsmOc0NkQIS9kxMNK0ft7\r
31         wgUclP2RSXAEZnrJYsTucsb+rcZart6gLXm/c9ot6KrMcftD58qWq3hz+5dG9blFjYpS\r
32         T2gTbZ+GGQ1dMFCBex4qcdrk2whDosg0wRSKUKmz6qCQq12NVlhrB5tPP2jgx8hKaUwb\r
33         7aIwLUAhC+vTLdt4Oin9HzGDc0BbdH9e3KBkO8WYXXB/l76KA66IpFplgtVMv++v7gw+\r
34         XcIA==\r
35 X-Received: by 10.180.96.225 with SMTP id dv1mr14319177wib.37.1396733086709;\r
36         Sat, 05 Apr 2014 14:24:46 -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 be3sm18587893wjc.5.2014.04.05.14.24.45\r
39         for <multiple recipients>\r
40         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
41         Sat, 05 Apr 2014 14:24:46 -0700 (PDT)\r
42 From: Mark Walters <markwalters1009@gmail.com>\r
43 To: notmuch@notmuchmail.org\r
44 Subject: [PATCH 2/5] emacs: hello: use the saved-search helper functions\r
45 Date: Sat,  5 Apr 2014 22:24:22 +0100\r
46 Message-Id: <1396733065-32602-3-git-send-email-markwalters1009@gmail.com>\r
47 X-Mailer: git-send-email 1.7.10.4\r
48 In-Reply-To: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com>\r
49 References: <1396733065-32602-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: Sat, 05 Apr 2014 21:24:58 -0000\r
63 \r
64 This uses the helper functions: the saved searches format has not\r
65 changed yet but backwards compatibility means everything still works.\r
66 ---\r
67  emacs/notmuch-hello.el |   48 ++++++++++++++++++++++--------------------------\r
68  emacs/notmuch.el       |    6 +++---\r
69  2 files changed, 25 insertions(+), 29 deletions(-)\r
70 \r
71 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
72 index 0b9ed16..733208b 100644\r
73 --- a/emacs/notmuch-hello.el\r
74 +++ b/emacs/notmuch-hello.el\r
75 @@ -319,7 +319,7 @@ (defun notmuch-hello-add-saved-search (widget)\r
76      (setq notmuch-saved-searches\r
77           (loop for elem in notmuch-saved-searches\r
78                 if (not (equal name\r
79 -                              (car elem)))\r
80 +                              (notmuch-saved-search-get elem :name)))\r
81                 collect elem))\r
82      ;; Add the new one.\r
83      (customize-save-variable 'notmuch-saved-searches\r
84 @@ -339,7 +339,7 @@ (defun notmuch-hello-delete-search-from-history (widget)\r
85  \r
86  (defun notmuch-hello-longest-label (searches-alist)\r
87    (or (loop for elem in searches-alist\r
88 -           maximize (length (car elem)))\r
89 +           maximize (length (notmuch-saved-search-get elem :name)))\r
90        0))\r
91  \r
92  (defun notmuch-hello-reflect-generate-row (ncols nrows row list)\r
93 @@ -418,13 +418,12 @@ (defun notmuch-hello-filtered-query (query filter)\r
94      (concat "(" query ") and (" filter ")"))\r
95     (t query)))\r
96  \r
97 -(defun notmuch-hello-query-counts (query-alist &rest options)\r
98 -  "Compute list of counts of matched messages from QUERY-ALIST.\r
99 +(defun notmuch-hello-query-counts (query-list &rest options)\r
100 +  "Compute list of counts of matched messages from QUERY-LIST.\r
101  \r
102 -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
103 -or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
104 -COUNT-QUERY specifies an alternate query to be used to generate\r
105 -the count for the associated query.\r
106 +QUERY-LIST must be a list of saved-searches. Ideally each of\r
107 +these is a plist but other options are available for backwards\r
108 +compatibility: see notmuch-saved-search-get for details.\r
109  \r
110  The result is the list of elements of the form (NAME QUERY COUNT).\r
111  \r
112 @@ -432,11 +431,9 @@ (defun notmuch-hello-query-counts (query-alist &rest options)\r
113  options will be handled as specified for\r
114  `notmuch-hello-insert-searches'."\r
115    (with-temp-buffer\r
116 -    (dolist (elem query-alist nil)\r
117 -      (let ((count-query (if (consp (cdr elem))\r
118 -                            ;; do we have a different query for the message count?\r
119 -                            (third elem)\r
120 -                          (cdr elem))))\r
121 +    (dolist (elem query-list nil)\r
122 +      (let ((count-query (or (notmuch-saved-search-get elem :count-query)\r
123 +                            (notmuch-saved-search-get elem :query))))\r
124         (insert\r
125          (replace-regexp-in-string\r
126           "\n" " "\r
127 @@ -458,18 +455,15 @@ (defun notmuch-hello-query-counts (query-alist &rest options)\r
128       #'identity\r
129       (mapcar\r
130        (lambda (elem)\r
131 -       (let ((name (car elem))\r
132 -             (search-query (if (consp (cdr elem))\r
133 -                                ;; do we have a different query for the message count?\r
134 -                                (second elem)\r
135 -                             (cdr elem)))\r
136 +       (let ((name (notmuch-saved-search-get elem :name))\r
137 +             (search-query (notmuch-saved-search-get elem :query))\r
138               (message-count (prog1 (read (current-buffer))\r
139                                 (forward-line 1))))\r
140           (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
141                (list name (notmuch-hello-filtered-query\r
142                            search-query (plist-get options :filter))\r
143                      message-count))))\r
144 -      query-alist))))\r
145 +      query-list))))\r
146  \r
147  (defun notmuch-hello-insert-buttons (searches)\r
148    "Insert buttons for SEARCHES.\r
149 @@ -728,13 +722,15 @@ (defun notmuch-hello-insert-recent-searches ()\r
150        (indent-rigidly start (point) notmuch-hello-indent))\r
151      nil))\r
152  \r
153 -(defun notmuch-hello-insert-searches (title query-alist &rest options)\r
154 -  "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST.\r
155 +(defun notmuch-hello-insert-searches (title query-list &rest options)\r
156 +  "Insert a section with TITLE showing a list of buttons made from QUERY-LIST.\r
157  \r
158 -QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
159 -or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
160 -COUNT-QUERY specifies an alternate query to be used to generate\r
161 -the count for the associated item.\r
162 +QUERY-LIST should ideally be a plist but for backwards\r
163 +compatibility other forms are also accepted (see\r
164 +`notmuch-saved-search-get' for details).  The plist should\r
165 +contain keys :name and :query; if :count-query is also present\r
166 +then it specifies an alternate query to be used to generate the\r
167 +count for the associated search.\r
168  \r
169  Supports the following entries in OPTIONS as a plist:\r
170  :initially-hidden - if non-nil, section will be hidden on startup\r
171 @@ -768,7 +764,7 @@ (defun notmuch-hello-insert-searches (title query-alist &rest options)\r
172                      "hide"))\r
173      (widget-insert "\n")\r
174      (when (not is-hidden)\r
175 -      (let ((searches (apply 'notmuch-hello-query-counts query-alist options)))\r
176 +      (let ((searches (apply 'notmuch-hello-query-counts query-list options)))\r
177         (when (or (not (plist-get options :hide-if-empty))\r
178                   searches)\r
179           (widget-insert "\n")\r
180 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
181 index 233c784..1346b90 100644\r
182 --- a/emacs/notmuch.el\r
183 +++ b/emacs/notmuch.el\r
184 @@ -823,14 +823,14 @@ (defun notmuch-search-buffer-title (query)\r
185           (let (longest\r
186                 (longest-length 0))\r
187             (loop for tuple in notmuch-saved-searches\r
188 -                 if (let ((quoted-query (regexp-quote (cdr tuple))))\r
189 +                 if (let ((quoted-query (regexp-quote (notmuch-saved-search-get tuple :query))))\r
190                        (and (string-match (concat "^" quoted-query) query)\r
191                             (> (length (match-string 0 query))\r
192                                longest-length)))\r
193                   do (setq longest tuple))\r
194             longest))\r
195 -        (saved-search-name (car saved-search))\r
196 -        (saved-search-query (cdr saved-search)))\r
197 +        (saved-search-name (notmuch-saved-search-get saved-search :name))\r
198 +        (saved-search-query (notmuch-saved-search-get saved-search :query)))\r
199      (cond ((and saved-search (equal saved-search-query query))\r
200            ;; Query is the same as saved search (ignoring case)\r
201            (concat "*notmuch-saved-search-" saved-search-name "*"))\r
202 -- \r
203 1.7.10.4\r
204 \r