1 Return-Path: <MarkR.Anderson@amd.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 F1258431FAF
\r
6 for <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 08:47:31 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 3ydh3ENk5T2S for <notmuch@notmuchmail.org>;
\r
16 Thu, 29 Mar 2012 08:47:31 -0700 (PDT)
\r
17 Received: from db3outboundpool.messaging.microsoft.com
\r
18 (db3ehsobe002.messaging.microsoft.com [213.199.154.140])
\r
19 (using TLSv1 with cipher AES128-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 0026A431FAE
\r
22 for <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 08:47:30 -0700 (PDT)
\r
23 Received: from mail3-db3-R.bigfish.com (10.3.81.253) by
\r
24 DB3EHSOBE002.bigfish.com (10.3.84.22) with Microsoft SMTP Server id
\r
25 14.1.225.23; Thu, 29 Mar 2012 15:47:28 +0000
\r
26 Received: from mail3-db3 (localhost [127.0.0.1]) by mail3-db3-R.bigfish.com
\r
27 (Postfix) with ESMTP id 45BA6220CC0 for <notmuch@notmuchmail.org>;
\r
28 Thu, 29 Mar 2012 15:47:28 +0000 (UTC)
\r
30 X-BigFish: VPS-9(zz1432N98dKzz1202hzz8275bhz2dh668h839h944hd24h)
\r
31 X-Forefront-Antispam-Report: CIP:163.181.249.108; KIP:(null); UIP:(null);
\r
32 IPV:NLI; H:ausb3twp01.amd.com; RD:none; EFVD:NLI
\r
33 Received: from mail3-db3 (localhost.localdomain [127.0.0.1]) by mail3-db3
\r
34 (MessageSwitch) id 1333036045508084_5422;
\r
35 Thu, 29 Mar 2012 15:47:25 +0000 (UTC)
\r
36 Received: from DB3EHSMHS019.bigfish.com (unknown [10.3.81.228]) by
\r
37 mail3-db3.bigfish.com (Postfix) with ESMTP id 7942B4E012C for
\r
38 <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 15:47:25 +0000 (UTC)
\r
39 Received: from ausb3twp01.amd.com (163.181.249.108) by
\r
40 DB3EHSMHS019.bigfish.com (10.3.87.119) with Microsoft SMTP Server id
\r
41 14.1.225.23; Thu, 29 Mar 2012 15:47:22 +0000
\r
42 X-WSS-ID: 0M1NL6V-01-0YV-02
\r
44 Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com
\r
45 [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128
\r
47 client certificate requested) by ausb3twp01.amd.com (Axway MailGate
\r
48 3.8.1) with ESMTP id 28CAAD10005 for <notmuch@notmuchmail.org>;
\r
49 Thu, 29 Mar 2012 10:47:19 -0500 (CDT)
\r
50 Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep01.amd.com
\r
51 (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.192.1;
\r
52 Thu, 29 Mar 2012 10:47:35 -0500
\r
53 Received: from adcvmail01.amd.com (163.181.21.78) by sausexhtp02.amd.com
\r
54 (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.3.213.0;
\r
55 Thu, 29 Mar 2012 10:47:19 -0500
\r
56 Received: from mhdc-ns01.amd.com (mhdc-ns01.amd.com [165.204.35.147]) by
\r
57 adcvmail01.amd.com (8.13.8/8.13.8) with ESMTP id q2TFlGX1013600;
\r
58 Thu, 29 Mar 2012 10:47:16 -0500
\r
59 Received: from testarossa.amd.com (testarossa.amd.com [165.204.147.44]) by
\r
60 mhdc-ns01.amd.com (8.13.8+Sun/8.13.8) with ESMTP id q2TFlIHI003604;
\r
61 Thu, 29 Mar 2012 09:47:18 -0600 (MDT)
\r
62 Received: (from manderso@localhost) by testarossa.amd.com
\r
63 (8.13.8/8.13.8/Submit) id q2TFlEPT008760;
\r
64 Thu, 29 Mar 2012 09:47:14 -0600
\r
65 X-Authentication-Warning: testarossa.amd.com: manderso set sender to
\r
66 MarkR.Anderson@amd.com using -f
\r
67 From: Mark Anderson <MarkR.Anderson@amd.com>
\r
68 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
69 Subject: Re: Goto command for existing search windows
\r
70 In-Reply-To: <3wd1uod7px7.fsf@testarossa.amd.com>
\r
71 References: <3wd1uod7px7.fsf@testarossa.amd.com>
\r
72 User-Agent: Notmuch/0.11.1+251~g1093c24 (http://notmuchmail.org) Emacs/23.2.1
\r
74 Date: Thu, 29 Mar 2012 09:47:14 -0600
\r
75 Message-ID: <3wdmx6z5rzx.fsf@testarossa.amd.com>
\r
77 Content-Type: text/plain; charset="us-ascii"
\r
78 X-OriginatorOrg: amd.com
\r
79 X-BeenThere: notmuch@notmuchmail.org
\r
80 X-Mailman-Version: 2.1.13
\r
82 List-Id: "Use and development of the notmuch mail system."
\r
83 <notmuch.notmuchmail.org>
\r
84 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
85 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
86 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
87 List-Post: <mailto:notmuch@notmuchmail.org>
\r
88 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
89 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
90 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
91 X-List-Received-Date: Thu, 29 Mar 2012 15:47:32 -0000
\r
93 On Tue, 27 Mar 2012 14:24:36 -0600, Mark Anderson <MarkR.Anderson@amd.com> wrote:
\r
94 > I was looking for a function which would find a buffer based on one of
\r
95 > my saved searches, and perform the search if it didn't exist.
\r
97 > I've gotten it a bit closer, if I perform the search that matches a
\r
98 > saved search, then this routine will find it because of the magic in
\r
99 > notmuch-search-buffer-title, but perhaps someone else feels up to
\r
100 > searching through the saved searches directly?
\r
104 > (defun notmuch-goto-or-search (&optional query)
\r
105 > "Find a notmuch-search buffer with the given query, or run
\r
106 > \"notmuch search\" with the given `query' and display results.
\r
108 > If `query' is nil, it is read interactively from the minibuffer."
\r
111 > (setq query (notmuch-read-query "Notmuch goto-or-search: ")))
\r
112 > (let ((buffer-name (notmuch-search-buffer-title query)))
\r
113 > (setq buf (get-buffer buffer-name)))
\r
116 > (notmuch-search query)
\r
117 > (switch-to-buffer buf)
\r
120 I have a slightly better-for-me version now:
\r
122 (defun notmuch-goto-or-search (&optional query)
\r
123 "Find a notmuch saved-search query with the given name, or a
\r
124 search with the given query, switching to an existing buffer
\r
125 without changes in preference to automatically refreshing or
\r
126 creating the search buffer.
\r
128 If `query' is nil, it is read interactively from the minibuffer."
\r
131 (setq query (notmuch-read-query "Notmuch goto-or-search: ")))
\r
132 (let ((saved-search-tuple (assoc query notmuch-saved-searches)))
\r
133 (setq expanded-query
\r
134 (if (null saved-search-tuple)
\r
136 (cdr saved-search-tuple))))
\r
137 (let ((buffer-name (notmuch-search-buffer-title expanded-query)))
\r
138 (setq buf (get-buffer buffer-name)))
\r
140 (notmuch-search expanded-query)
\r
141 (switch-to-buffer buf)
\r
144 This does search the saved searches to see if you entered a saved search
\r
145 name. With this I don't have to duplicate my query for saved searches
\r
148 (global-set-key [f8] (lambda () (interactive) (notmuch-goto-or-search "Inbox")))
\r
149 (global-set-key [f9] (lambda () (interactive) (notmuch-goto-or-search "INBOX")))
\r
150 (global-set-key [f10] (lambda () (interactive) (notmuch-goto-or-search "todo")))
\r
153 > I then use it something like this:
\r
155 > (global-set-key [C-f1] (lambda () (interactive) (notmuch-goto-or-search "tag:inbox and tag:unread and not tag:deleted")))
\r
156 > (global-set-key [C-f2] (lambda () (interactive) (notmuch-goto-or-search "tag:inbox and not tag:deleted")))
\r
157 > (global-set-key [C-f3] 'notmuch)
\r
158 > (global-set-key [C-f6] (lambda () (interactive) (notmuch-goto-or-search "tag:todo and not tag:deleted")))
\r
160 > It would be better if I could use my Inbox, INBOX and todo names for the
\r
161 > saved searches, but how to do that without breaking generality of
\r
162 > searching the body of the email? Do I have to define my own ss: (saved
\r
163 > search) prefix or something, as I believe some others have?
\r
165 > This is what I'm willing to do today, and it works for me, I could patch
\r
166 > notmuch.el, but I wondered about answering the other questions.
\r
168 > Also, some elisp master could hint about how to make the binding not so
\r
171 > Another appreciated elisp hint would be how to get the buf variable to
\r
172 > go inside the let, I keep getting complaints about buffer-name not being
\r
173 > defined, thus the "ugly" setq, which works.
\r