[PATCH 08/11] cli: add thread recipients to search output
[notmuch-archives.git] / 7d / 988cbd2dc88f2d2cf00961053e337b9aa8a44e
1 Return-Path: <amdragon@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 DFC1E429E28\r
6         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 12:11:17 -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.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
13         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 UY1FvdPx9HtU for <notmuch@notmuchmail.org>;\r
17         Wed, 25 May 2011 12:11:17 -0700 (PDT)\r
18 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
19         [209.85.216.181]) (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 0163B431FB6\r
22         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 12:11:16 -0700 (PDT)\r
23 Received: by qyg14 with SMTP id 14so5371640qyg.5\r
24         for <notmuch@notmuchmail.org>; Wed, 25 May 2011 12:11:16 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:mime-version:sender:in-reply-to:references:date\r
27         :x-google-sender-auth:message-id:subject:from:to:cc:content-type;\r
28         bh=7Em65kfv/9LhXtAJ+KDLDDTFE4F2kkINzuPkYVK9RTo=;\r
29         b=vMtzlFf3HNqptmhak3jO0/wShc1kfEJemC8Ss0bqsL3DUHvUCjCfJWCVetcFZIX8Sm\r
30         f+8x7Z9TS1myay7aWU7ltPmBDhRhuNDLKj43b5DXJ3G1X4qdERhUk4DLj1RakYLDJHpo\r
31         xEbWOP7M9e+1hJdbqG0EQWO+ZmjM1QmVJZ7Io=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=mime-version:sender:in-reply-to:references:date\r
34         :x-google-sender-auth:message-id:subject:from:to:cc:content-type;\r
35         b=HH9kCuE/rNTBVy3hUy1SywVh3gLBkpXQCo4DMr5dT+Clyxn7oowUypUxH3ON+5/4xf\r
36         CVOfZO6DXGCkl1zXQqizoChzlzzv4fwI0cRje5ym9mCh7gmqqYvtnRi/D9OI8Hky10+J\r
37         X2pyBigRIyZY5aaFhtcI/y7EFlg4PEAk+692w=\r
38 MIME-Version: 1.0\r
39 Received: by 10.229.118.69 with SMTP id u5mr4118927qcq.122.1306350676121; Wed,\r
40         25 May 2011 12:11:16 -0700 (PDT)\r
41 Sender: amdragon@gmail.com\r
42 Received: by 10.229.188.68 with HTTP; Wed, 25 May 2011 12:11:16 -0700 (PDT)\r
43 In-Reply-To: <871uzmwtng.fsf@gilead.invalid>\r
44 References: <87fwoath2s.fsf@gilead.home.box>\r
45         <BANLkTinKS5LbQsZuK8HyCzj+Lo4xqa2Sfg@mail.gmail.com>\r
46         <871uznqeox.fsf@tredergarh.home.box>\r
47         <BANLkTin0+O=mubHF7JNpw4u3DQDQJQ5zbw@mail.gmail.com>\r
48         <874o4iwwp5.fsf@gilead.invalid> <871uzmwtng.fsf@gilead.invalid>\r
49 Date: Wed, 25 May 2011 15:11:16 -0400\r
50 X-Google-Sender-Auth: sAR1FF-HsKVVS1bqkAxLFzAFq_c\r
51 Message-ID: <BANLkTikAB0mogUuS-nT_-i51LBdUBHCz3g@mail.gmail.com>\r
52 Subject: Re: [PATCH] emacs: Make the queries used in the all-tags section\r
53 From: Austin Clements <amdragon@mit.edu>\r
54 To: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
55 Content-Type: text/plain; charset=ISO-8859-1\r
56 Cc: notmuch@notmuchmail.org\r
57 X-BeenThere: notmuch@notmuchmail.org\r
58 X-Mailman-Version: 2.1.13\r
59 Precedence: list\r
60 List-Id: "Use and development of the notmuch mail system."\r
61         <notmuch.notmuchmail.org>\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
63         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
65 List-Post: <mailto:notmuch@notmuchmail.org>\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
69 X-List-Received-Date: Wed, 25 May 2011 19:11:18 -0000\r
70 \r
71 On Wed, May 25, 2011 at 1:56 PM, Daniel Schoepe\r
72 <daniel.schoepe@googlemail.com> wrote:\r
73 > I accidentally used `filter' in the previous patch which isn't defined\r
74 > by default during runtime, updated version in the attachment.\r
75 \r
76 Cool.  My inner parser is happy.\r
77 \r
78 A few comments on the code:\r
79 \r
80 > +(defcustom notmuch-hello-tag-list-make-query nil\r
81 > +  "Function or string to generate queries for the all tags list.\r
82 > +\r
83 > +This variable controls which query results are shown for each tag\r
84 > +in the \"all tags\" list. It can be nil (for default behaviour,\r
85 > +displaying all messages for a tag), a string that is used as a\r
86 > +filter for messages having that tag (equivalent to \"tag:TAG\r
87 > +and (THIS-VARIABLE)\", or a function that is given a tag and\r
88 > +should return the query that is to be used for the tag. If it\r
89 > +returns nil, the corresponding tag will be hidden."\r
90 > +  :type '(choice (const nil :tag "tag:TAG") string function)\r
91 > +  :group 'notmuch)\r
92 \r
93 At least in Emacs 23.3.1, it has to be (const :tag "tag:TAG" nil).  I\r
94 didn't think the order mattered, but the tag didn't display otherwise.\r
95  It would also be good to give descriptive tags to the other choices.\r
96 \r
97 It would be more consistent if the function form of this also returned\r
98 a filter expression, rather than a whole expression.  This also\r
99 simplifies the documentation.\r
100 \r
101 So, perhaps something like\r
102 \r
103 (defcustom notmuch-hello-tag-list-counts nil\r
104   "Method for generating counts displayed in the all tags list.\r
105 \r
106 This variable controls the query used to generate counts for each\r
107 tag in the \"all tags\" list.  If nil, the tag list will count\r
108 all messages with each tag.  This can be a query string that will\r
109 filter the messages counted for each tag.  Finally, this can be a\r
110 function that will be called for each tag and should return a\r
111 filter query for that tag, or nil to hide the tag."\r
112   :type '(choice (const :tag "Count all messages" nil)\r
113                  (const :tag "Count unread messages" "tag:unread")\r
114                  (const :tag "Custom filter" string)\r
115                  (const :tag "Custom filter function" function))\r
116   :group 'notmuch)\r
117 \r
118 > +(defun notmuch-hello-generate-tag-alist ()\r
119 > +  "Return an alist from tags to queries to display in the all-tags section."\r
120 > +  (notmuch-filter\r
121 > +   'cdr\r
122 > +   (mapcar '(lambda (tag)\r
123 \r
124 You don't need the quote before a lambda form.  (You can also change\r
125 'cdr to #'cdr to further hint the compiler, though it appears to not\r
126 matter in this case.)\r
127 \r
128 > +(defun notmuch-filter (pred lst)\r
129 > +  "Return a list containing all elements from LST that satisfy PRED."\r
130 \r
131 notmuch-remove-if-not would be more canonical (yeah, it's unwieldy,\r
132 blame Common Lisp).  Also, since Elisp doesn't do tail-recursion, the\r
133 standard way to define a remove-if-not function is\r
134 \r
135 (defun notmuch-remove-if-not (predicate list)\r
136   "Return a copy of LIST with all items not satisfying PREDICATE removed."\r
137   (let (out)\r
138     (while list\r
139       (when (funcall predicate (car list))\r
140         (push (car list) out))\r
141       (setq list (cdr list)))\r
142     (nreverse out)))\r
143 \r
144 (Why oh why Elisp hasn't just made remove-if and remove-if-not\r
145 standard I don't know; they're redefined all over the Elisp code base.\r
146  Any everybody's afraid to use cl-seq's remove-if-not because it's so\r
147 ridiculously complicated.)\r