1 Return-Path: <jani@nikula.org>
\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 DF0FA429E4D
\r
6 for <notmuch@notmuchmail.org>; Wed, 23 Nov 2011 13:08:46 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"
\r
12 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
13 tests=[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 zk6ktvChI8D4 for <notmuch@notmuchmail.org>;
\r
17 Wed, 23 Nov 2011 13:08:46 -0800 (PST)
\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 296DC429E4B
\r
22 for <notmuch@notmuchmail.org>; Wed, 23 Nov 2011 13:08:46 -0800 (PST)
\r
23 Received: by mail-bw0-f53.google.com with SMTP id q10so2250402bka.26
\r
24 for <notmuch@notmuchmail.org>; Wed, 23 Nov 2011 13:08:45 -0800 (PST)
\r
25 Received: by 10.205.139.11 with SMTP id iu11mr174925bkc.82.1322082525492;
\r
26 Wed, 23 Nov 2011 13:08:45 -0800 (PST)
\r
27 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
29 by mx.google.com with ESMTPS id q16sm23167024fae.6.2011.11.23.13.08.43
\r
30 (version=SSLv3 cipher=OTHER); Wed, 23 Nov 2011 13:08:44 -0800 (PST)
\r
31 From: Jani Nikula <jani@nikula.org>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [RFC PATCH 1/2] emacs: allow functions as saved searches
\r
34 Date: Wed, 23 Nov 2011 23:08:36 +0200
\r
36 <bbb67d241bf5f8575545ecdd2c3cd6cfed3244e8.1322080622.git.jani@nikula.org>
\r
37 X-Mailer: git-send-email 1.7.5.4
\r
38 In-Reply-To: <cover.1322080622.git.jani@nikula.org>
\r
39 References: <cover.1322080622.git.jani@nikula.org>
\r
40 In-Reply-To: <cover.1322080622.git.jani@nikula.org>
\r
41 References: <cover.1322080622.git.jani@nikula.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Wed, 23 Nov 2011 21:08:47 -0000
\r
56 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
58 emacs/notmuch-hello.el | 9 +++++++--
\r
59 emacs/notmuch-lib.el | 8 ++++++--
\r
60 emacs/notmuch.el | 9 +++++++--
\r
61 3 files changed, 20 insertions(+), 6 deletions(-)
\r
63 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
64 index 0582cae..ad3ae74 100644
\r
65 --- a/emacs/notmuch-hello.el
\r
66 +++ b/emacs/notmuch-hello.el
\r
67 @@ -274,7 +274,9 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
68 ;; (not elem) indicates an empty slot in the matrix.
\r
70 (let* ((name (car elem))
\r
71 - (query (cdr elem))
\r
72 + (query (if (functionp (cdr elem))
\r
73 + (funcall (cdr elem) elem)
\r
75 (formatted-name (format "%s " name)))
\r
76 (widget-insert (format "%8s "
\r
77 (notmuch-hello-nice-number
\r
78 @@ -452,7 +454,10 @@ Complete list of currently available key bindings:
\r
79 (if notmuch-show-empty-saved-searches
\r
80 notmuch-saved-searches
\r
81 (loop for elem in notmuch-saved-searches
\r
82 - if (> (string-to-number (notmuch-saved-search-count (cdr elem))) 0)
\r
83 + if (> (string-to-number (notmuch-saved-search-count
\r
84 + (if (functionp (cdr elem))
\r
85 + (funcall (cdr elem) elem)
\r
88 (saved-widest (notmuch-hello-longest-label saved-alist))
\r
89 (alltags-alist (if notmuch-show-all-tags-list (notmuch-hello-generate-tag-alist)))
\r
90 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
91 index 0f856bf..2ecb3fc 100644
\r
92 --- a/emacs/notmuch-lib.el
\r
93 +++ b/emacs/notmuch-lib.el
\r
97 (defcustom notmuch-saved-searches nil
\r
98 - "A list of saved searches to display."
\r
99 - :type '(alist :key-type string :value-type string)
\r
100 + "A list of saved searches to display.
\r
102 +The list of saved searches is a list of key/value pairs, where
\r
103 +the key is the name of the saved search, and value is either a
\r
104 +query string, or a function that should return a query string."
\r
105 + :type '(alist :key-type string :value-type (choice string function))
\r
108 (defvar notmuch-folders nil
\r
109 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
110 index c1827cc..62f33e9 100644
\r
111 --- a/emacs/notmuch.el
\r
112 +++ b/emacs/notmuch.el
\r
113 @@ -854,14 +854,19 @@ characters as well as `_.+-'.
\r
115 (longest-length 0))
\r
116 (loop for tuple in notmuch-saved-searches
\r
117 - if (let ((quoted-query (regexp-quote (cdr tuple))))
\r
118 + if (let ((quoted-query (regexp-quote
\r
119 + (if (functionp (cdr tuple))
\r
120 + (funcall (cdr tuple) tuple)
\r
122 (and (string-match (concat "^" quoted-query) query)
\r
123 (> (length (match-string 0 query))
\r
125 do (setq longest tuple))
\r
127 (saved-search-name (car saved-search))
\r
128 - (saved-search-query (cdr saved-search)))
\r
129 + (saved-search-query (if (functionp (cdr saved-search))
\r
130 + (funcall (cdr saved-search) saved-search)
\r
131 + (cdr saved-search))))
\r
132 (cond ((and saved-search (equal saved-search-query query))
\r
133 ;; Query is the same as saved search (ignoring case)
\r
134 (concat "*notmuch-saved-search-" saved-search-name "*"))
\r