[PATCH 7/9] CLI: add properties to dump output
[notmuch-archives.git] / 4a / e33c569bb4679465157a3a1885ca5579d7e20d
1 Return-Path: <daniel.schoepe@googlemail.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 033D7431FB6\r
6         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 10:57:03 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id K94P4d2C7jBn for <notmuch@notmuchmail.org>;\r
17         Wed, 25 May 2011 10:57:03 -0700 (PDT)\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id E630A431FD0\r
22         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 10:57:02 -0700 (PDT)\r
23 Received: by bwg12 with SMTP id 12so7308818bwg.26\r
24         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 10:57:01 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
26         d=googlemail.com; s=gamma;\r
27         h=domainkey-signature:from:to:cc:subject:in-reply-to:references\r
28         :user-agent:date:message-id:mime-version:content-type;\r
29         bh=YxN5HWEE9xCS6uCdclVmVAC5sPdZqDhPcL6ImBVXxLQ=;\r
30         b=opGxSrmyyjMeYJBtfyD/uYYZ98McAwX6d833am5cXurOUOG5O5GFRRYZ33Jc0EKtpx\r
31         Wp1SG9prr4cRRq3dxWOczVqzJyHaaQ8ovoG4idaFtBfHwgfkwGQsBYTiWDvc+sw3+5PN\r
32         +ivRiKLo8Q+z/4AaJCHCnkHClqKIaJxxr5VDo=\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma;\r
34         h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
35         :message-id:mime-version:content-type;\r
36         b=ni1CHHg3ciE5olPsBl+VjlaefGs3sNtraBT1l2Y9A2ZMGTXy2rCEtijHFKBeQXfzCE\r
37         JVsCTOz7fGJg0Q4kLa5k2HECMHIJ72gGW52Xs31V5XpPpajt6hK8519NlSWdWPke7i6F\r
38         3gndQ3In43JzvaupxtFxRNPg4l47l9gqhy3zo=\r
39 Received: by 10.204.136.217 with SMTP id s25mr221968bkt.13.1306346220917;\r
40         Wed, 25 May 2011 10:57:00 -0700 (PDT)\r
41 Received: from localhost (dslb-178-004-026-109.pools.arcor-ip.net\r
42         [178.4.26.109])\r
43         by mx.google.com with ESMTPS id d25sm5371083bkd.17.2011.05.25.10.56.58\r
44         (version=TLSv1/SSLv3 cipher=OTHER);\r
45         Wed, 25 May 2011 10:56:59 -0700 (PDT)\r
46 From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
47 To: Austin Clements <amdragon@mit.edu>, Carl Worth <cworth@cworth.org>\r
48 Subject: Re: [PATCH] emacs: Make the queries used in the all-tags section\r
49 In-Reply-To: <874o4iwwp5.fsf@gilead.invalid>\r
50 References: <87fwoath2s.fsf@gilead.home.box>\r
51         <BANLkTinKS5LbQsZuK8HyCzj+Lo4xqa2Sfg@mail.gmail.com>\r
52         <871uznqeox.fsf@tredergarh.home.box>\r
53         <BANLkTin0+O=mubHF7JNpw4u3DQDQJQ5zbw@mail.gmail.com>\r
54         <874o4iwwp5.fsf@gilead.invalid>\r
55 User-Agent: Notmuch/0.5-210-g1acc997 (http://notmuchmail.org) Emacs/23.3.1\r
56         (x86_64-pc-linux-gnu)\r
57 Date: Wed, 25 May 2011 19:56:51 +0200\r
58 Message-ID: <871uzmwtng.fsf@gilead.invalid>\r
59 MIME-Version: 1.0\r
60 Content-Type: multipart/signed; boundary="==-=-=";\r
61         micalg=pgp-sha1; protocol="application/pgp-signature"\r
62 Cc: notmuch@notmuchmail.org\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\r
66 List-Id: "Use and development of the notmuch mail system."\r
67         <notmuch.notmuchmail.org>\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
71 List-Post: <mailto:notmuch@notmuchmail.org>\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
75 X-List-Received-Date: Wed, 25 May 2011 17:57:04 -0000\r
76 \r
77 --==-=-=\r
78 Content-Type: multipart/mixed; boundary="=-=-="\r
79 \r
80 --=-=-=\r
81 Content-Type: text/plain\r
82 \r
83 \r
84 I accidentally used `filter' in the previous patch which isn't defined\r
85 by default during runtime, updated version in the attachment.\r
86 \r
87 --=-=-=\r
88 Content-Type: text/x-diff\r
89 Content-Disposition: inline;\r
90  filename=0001-emacs-Make-queries-used-in-the-all-tags-section-conf.patch\r
91 Content-Transfer-Encoding: quoted-printable\r
92 \r
93 From=20e8f5e997b7082a50f75d7329a69fccc126a21e5e Mon Sep 17 00:00:00 2001\r
94 From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
95 Date: Fri, 20 May 2011 00:53:50 +0200\r
96 Subject: [PATCH] emacs: Make queries used in the all-tags section\r
97  configurable\r
98 \r
99 This patch adds a customization variable that controls what queries\r
100 are used to construct the all-tags section in notmuch-hello. It allows\r
101 the user to specify a function to construct the query given a tag or\r
102 a string that is used as a filter for each tag.\r
103 It also adds a variable to hide various tags from the all-tags section.\r
104 \r
105 Signed-off-by: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
106 =2D--\r
107  emacs/notmuch-hello.el |   38 +++++++++++++++++++++++++++++++++++---\r
108  emacs/notmuch-lib.el   |   12 ++++++++++++\r
109  2 files changed, 47 insertions(+), 3 deletions(-)\r
110 \r
111 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
112 index e58dd24..b3f133c 100644\r
113 =2D-- a/emacs/notmuch-hello.el\r
114 +++ b/emacs/notmuch-hello.el\r
115 @@ -55,6 +55,24 @@\r
116    :type 'boolean\r
117    :group 'notmuch)\r
118 =20\r
119 +(defcustom notmuch-hello-tag-list-make-query nil\r
120 +  "Function or string to generate queries for the all tags list.\r
121 +\r
122 +This variable controls which query results are shown for each tag\r
123 +in the \"all tags\" list. It can be nil (for default behaviour,\r
124 +displaying all messages for a tag), a string that is used as a\r
125 +filter for messages having that tag (equivalent to \"tag:TAG\r
126 +and (THIS-VARIABLE)\", or a function that is given a tag and\r
127 +should return the query that is to be used for the tag. If it\r
128 +returns nil, the corresponding tag will be hidden."\r
129 +  :type '(choice (const nil :tag "tag:TAG") string function)\r
130 +  :group 'notmuch)\r
131 +\r
132 +(defcustom notmuch-hello-hide-tags nil\r
133 +  "List of tags to be hidden in the \"all tags\"-section."\r
134 +  :type '(repeat string)\r
135 +  :group 'notmuch)\r
136 +\r
137  (defface notmuch-hello-logo-background\r
138    '((((class color)\r
139        (background dark))\r
140 @@ -318,6 +336,22 @@ Complete list of currently available key bindings:\r
141   ;;(setq buffer-read-only t)\r
142  )\r
143 =20\r
144 +(defun notmuch-hello-generate-tag-alist ()\r
145 +  "Return an alist from tags to queries to display in the all-tags section=\r
146 ."\r
147 +  (notmuch-filter\r
148 +   'cdr\r
149 +   (mapcar '(lambda (tag)\r
150 +             (cons tag\r
151 +                   (cond\r
152 +                    ((functionp notmuch-hello-tag-list-make-query)\r
153 +                     (funcall notmuch-hello-tag-list-make-query tag))\r
154 +                    ((stringp notmuch-hello-tag-list-make-query)\r
155 +                     (concat "tag:" tag " and ("\r
156 +                             notmuch-hello-tag-list-make-query ")"))\r
157 +                    (t (concat "tag:" tag)))))\r
158 +          (notmuch-filter (lambda (tag) (not (member tag notmuch-hello-hide-tags=\r
159 )))\r
160 +                          (process-lines notmuch-command "search-tags")))))\r
161 +\r
162  ;;;###autoload\r
163  (defun notmuch-hello (&optional no-display)\r
164    "Run notmuch and display saved searches, known tags, etc."\r
165 @@ -396,9 +430,7 @@ Complete list of currently available key bindings:\r
166                       if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0)\r
167                       collect elem)))\r
168              (saved-widest (notmuch-hello-longest-label saved-alist))\r
169 =2D          (alltags-alist (if notmuch-show-all-tags-list\r
170 =2D                             (mapcar '(lambda (tag) (cons tag (concat "tag:" tag)))\r
171 =2D                                     (process-lines notmuch-command "search-tags"))))\r
172 +            (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generat=\r
173 e-tag-alist)))\r
174              (alltags-widest (notmuch-hello-longest-label alltags-alist))\r
175              (widest (max saved-widest alltags-widest)))\r
176 =20\r
177 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
178 index cc80fb2..a3195ff 100644\r
179 =2D-- a/emacs/notmuch-lib.el\r
180 +++ b/emacs/notmuch-lib.el\r
181 @@ -120,6 +120,18 @@ within the current window."\r
182        (or (memq prop buffer-invisibility-spec)\r
183           (assq prop buffer-invisibility-spec)))))\r
184 =20\r
185 +;; notmuch- prefix to avoid clashes with user-defined filter-functions:\r
186 +;; For instance, the filter-function suggested in the elisp cookbook\r
187 +;; on the emacswiki always filters out elements that are nil\r
188 +;; even if the predicate returns t for nil; hence this has slightly\r
189 +;; different semantics than what some users have defined for themselves.\r
190 +(defun notmuch-filter (pred lst)\r
191 +  "Return a list containing all elements from LST that satisfy PRED."\r
192 +  (and lst\r
193 +     (if (funcall pred (car lst))\r
194 +        (cons (car lst) (notmuch-filter pred (cdr lst)))\r
195 +       (notmuch-filter pred (cdr lst)))))\r
196 +\r
197  ; This lets us avoid compiling these replacement functions when emacs\r
198  ; is sufficiently new enough to supply them alone. We do the macro\r
199  ; treatment rather than just wrapping our defun calls in a when form\r
200 =2D-=20\r
201 1.7.5.1\r
202 \r
203 \r
204 --=-=-=--\r
205 \r
206 --==-=-=\r
207 Content-Type: application/pgp-signature\r
208 \r
209 -----BEGIN PGP SIGNATURE-----\r
210 Version: GnuPG v1.4.11 (GNU/Linux)\r
211 \r
212 iQIcBAEBAgAGBQJN3ULkAAoJEIaTAtce+Z+JBmAP/jsYuQch+U1Eag4gONSQK5Bq\r
213 Wigvd/Nl3jPaiC/xOZqsD6hNBtuDquv56Viu/ODhSGeeQkUkN948isWc43m2SQEW\r
214 hSgd7GSXur/ZEXaNpHuu9Ai4Pf5IIxJcPKsj1npnLGHccjUTZxiYWnKijdm6vR1p\r
215 S+LTtaP1LY4+bDHSf8Lzi496cBptbZkPUdYXY8/nebcPRvpakw1qEaVh47LFXwzK\r
216 H9uiyzbj8cBMfSXgFwqVN6507bffp5kZNrbP3qAfua18lsI8vVu0RNpg9PO/ChkZ\r
217 2933HN27i+EcVM86DpK5EAfgObQ+xamFLmfKlJpb1sXPa2btbz90rcKxdBockNYD\r
218 W3FvekAmyz/577e52K6roXMKC7h9UqTFxchH8Uaa5EsEzoY7IMfFdWggN6+FhPZx\r
219 2GH1Yo8Veudb8rJ/0fJHLB93plOuZq3Fuqdvlh0I58Og908m5Wag3prZbRLT753G\r
220 Y1/5c1KoSDDCVQ5k9c9GAAUipJquH3vpowJdyLjmnaG7sshfaNNwlzPutMD7x7Xq\r
221 ottzQ8/XjJMX2kkTSymWv7ut9RotJQM6SnXh2YSz4ZL2ZOZA8db9hmvSxqdkvTLI\r
222 1zKHgOCZNyMm1Z0lhqDpOCRnngVXFR6y8Imgm5vRGRiMYFdrC9RgDkCtyadnyuHI\r
223 xX9Q+q3EyIMh3HpZd1sO\r
224 =Jr/h\r
225 -----END PGP SIGNATURE-----\r
226 --==-=-=--\r