1 Return-Path: <five9a2@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 AC93140DF1C
\r
6 for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 10:41:34 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.346 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_NONE=-0.0001] autolearn=no
\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 npB9mRO5Ggyq for <notmuch@notmuchmail.org>;
\r
18 Fri, 19 Nov 2010 10:41:24 -0800 (PST)
\r
19 Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com
\r
21 by olra.theworths.org (Postfix) with ESMTP id 43ECD40DF18
\r
22 for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 10:41:24 -0800 (PST)
\r
23 Received: by fxm10 with SMTP id 10so57396fxm.26
\r
24 for <notmuch@notmuchmail.org>; Fri, 19 Nov 2010 10:41:23 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=domainkey-signature:received:received:sender:from:to:cc:subject
\r
27 :date:message-id:x-mailer:in-reply-to:references;
\r
28 bh=ix5jdOaj4b2te6RO/lnNc2oy99I/wD9zMXgTzMFizD0=;
\r
29 b=ekvUijRGBHXDlzRvU8KlVgfztRUlS3f56KW4BnCVJhAKA5sLpK1IzyaoiXYuEs1xd7
\r
30 BZsey+ESv0qsN6xA0Vl9HCtuDWFjye6FGLdD1+41R3xmGONi1F0qNCpCSNObTHkHOx5O
\r
31 M5xf1wap9VC/bMrDX2He+oNRgilRQrbH4LppQ=
\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
33 h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to
\r
35 b=hlMWKiLBKithKvMcqNj1Mi7BY/vyXz+OQcfICM5j07q+OTuADLk6BGbRzUsmB6Mec+
\r
36 lZMM0+skYi5dKYtGanEwqKmphMV6zz5lmR7S/SJLz/0gyhOnbBtnwm/OuDX7SGkHA2U+
\r
37 2idX7i49+SWfedOZIen2DA1RLf07hFvaPRZTI=
\r
38 Received: by 10.223.125.132 with SMTP id y4mr493347far.148.1290192083418;
\r
39 Fri, 19 Nov 2010 10:41:23 -0800 (PST)
\r
40 Received: from localhost.localdomain (vawpc43.ethz.ch [129.132.59.11])
\r
41 by mx.google.com with ESMTPS id n3sm626630faa.5.2010.11.19.10.41.21
\r
42 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
43 Fri, 19 Nov 2010 10:41:22 -0800 (PST)
\r
44 Sender: Jed Brown <five9a2@gmail.com>
\r
45 From: Jed Brown <jed@59A2.org>
\r
47 notmuch@notmuchmail.org
\r
48 Subject: [PATCH] Support function values in notmuch-saved-searches so that
\r
49 searches can be generated dynamically
\r
50 Date: Fri, 19 Nov 2010 19:42:49 +0100
\r
51 Message-Id: <1290192169-2486-1-git-send-email-jed@59A2.org>
\r
52 X-Mailer: git-send-email 1.7.3.2
\r
53 In-Reply-To: <1290188979-7596-1-git-send-email-dme@dme.org>
\r
54 References: <1290188979-7596-1-git-send-email-dme@dme.org>
\r
55 X-BeenThere: notmuch@notmuchmail.org
\r
56 X-Mailman-Version: 2.1.13
\r
58 List-Id: "Use and development of the notmuch mail system."
\r
59 <notmuch.notmuchmail.org>
\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
61 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
63 List-Post: <mailto:notmuch@notmuchmail.org>
\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
66 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
67 X-List-Received-Date: Fri, 19 Nov 2010 18:41:34 -0000
\r
69 This permits saved searches like "today".
\r
71 This is similar functionality to David's patch, but uses an accessor so that queries are always evaluated dynamically.
\r
73 emacs/notmuch-hello.el | 4 ++--
\r
74 emacs/notmuch-lib.el | 11 ++++++++++-
\r
75 emacs/notmuch.el | 2 +-
\r
76 3 files changed, 13 insertions(+), 4 deletions(-)
\r
78 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
79 index e58dd24..15eaafb 100644
\r
80 --- a/emacs/notmuch-hello.el
\r
81 +++ b/emacs/notmuch-hello.el
\r
82 @@ -234,7 +234,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
83 ;; (not elem) indicates an empty slot in the matrix.
\r
85 (let* ((name (car elem))
\r
86 - (query (cdr elem))
\r
87 + (query (notmuch-saved-search-get-query elem))
\r
88 (formatted-name (format "%s " name)))
\r
89 (widget-insert (format "%8s "
\r
90 (notmuch-hello-nice-number
\r
91 @@ -393,7 +393,7 @@ Complete list of currently available key bindings:
\r
92 (if notmuch-show-empty-saved-searches
\r
93 notmuch-saved-searches
\r
94 (loop for elem in notmuch-saved-searches
\r
95 - if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0)
\r
96 + if (> (string-to-number (notmuch-saved-search-count (notmuch-saved-search-get-query elem))) 0)
\r
98 (saved-widest (notmuch-hello-longest-label saved-alist))
\r
99 (alltags-alist (if notmuch-show-all-tags-list
\r
100 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
101 index dd180ee..3fcb837 100644
\r
102 --- a/emacs/notmuch-lib.el
\r
103 +++ b/emacs/notmuch-lib.el
\r
106 (defcustom notmuch-saved-searches nil
\r
107 "A list of saved searches to display."
\r
108 - :type '(alist :key-type string :value-type string)
\r
109 + :type '(alist :key-type (string :tag "Name")
\r
110 + :value-type (choice (string :tag "Search")
\r
111 + (function :tag "Function")))
\r
114 (defvar notmuch-folders nil
\r
115 @@ -56,6 +58,13 @@ the user hasn't set this variable with the old or new value."
\r
116 '(("inbox" . "tag:inbox")
\r
117 ("unread" . "tag:unread")))))
\r
119 +(defun notmuch-saved-search-get-query (tuple)
\r
120 + "Get the query string for a saved tuple."
\r
121 + (let ((q (cdr tuple)))
\r
126 (defun notmuch-version ()
\r
127 "Return a string with the notmuch version number."
\r
129 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
130 index 5933747..5864b21 100644
\r
131 --- a/emacs/notmuch.el
\r
132 +++ b/emacs/notmuch.el
\r
133 @@ -763,7 +763,7 @@ characters as well as `_.+-'.
\r
135 (longest-length 0))
\r
136 (loop for tuple in notmuch-saved-searches
\r
137 - if (let ((quoted-query (regexp-quote (cdr tuple))))
\r
138 + if (let ((quoted-query (regexp-quote (notmuch-saved-search-get-query tuple))))
\r
139 (and (string-match (concat "^" quoted-query) query)
\r
140 (> (length (match-string 0 query))
\r