--- /dev/null
+Return-Path: <MarkR.Anderson@amd.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id F1258431FAF\r
+ for <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 08:47:31 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 3ydh3ENk5T2S for <notmuch@notmuchmail.org>;\r
+ Thu, 29 Mar 2012 08:47:31 -0700 (PDT)\r
+Received: from db3outboundpool.messaging.microsoft.com\r
+ (db3ehsobe002.messaging.microsoft.com [213.199.154.140])\r
+ (using TLSv1 with cipher AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 0026A431FAE\r
+ for <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 08:47:30 -0700 (PDT)\r
+Received: from mail3-db3-R.bigfish.com (10.3.81.253) by\r
+ DB3EHSOBE002.bigfish.com (10.3.84.22) with Microsoft SMTP Server id\r
+ 14.1.225.23; Thu, 29 Mar 2012 15:47:28 +0000\r
+Received: from mail3-db3 (localhost [127.0.0.1]) by mail3-db3-R.bigfish.com\r
+ (Postfix) with ESMTP id 45BA6220CC0 for <notmuch@notmuchmail.org>;\r
+ Thu, 29 Mar 2012 15:47:28 +0000 (UTC)\r
+X-SpamScore: -9\r
+X-BigFish: VPS-9(zz1432N98dKzz1202hzz8275bhz2dh668h839h944hd24h)\r
+X-Forefront-Antispam-Report: CIP:163.181.249.108; KIP:(null); UIP:(null);\r
+ IPV:NLI; H:ausb3twp01.amd.com; RD:none; EFVD:NLI\r
+Received: from mail3-db3 (localhost.localdomain [127.0.0.1]) by mail3-db3\r
+ (MessageSwitch) id 1333036045508084_5422;\r
+ Thu, 29 Mar 2012 15:47:25 +0000 (UTC)\r
+Received: from DB3EHSMHS019.bigfish.com (unknown [10.3.81.228]) by\r
+ mail3-db3.bigfish.com (Postfix) with ESMTP id 7942B4E012C for\r
+ <notmuch@notmuchmail.org>; Thu, 29 Mar 2012 15:47:25 +0000 (UTC)\r
+Received: from ausb3twp01.amd.com (163.181.249.108) by\r
+ DB3EHSMHS019.bigfish.com (10.3.87.119) with Microsoft SMTP Server id\r
+ 14.1.225.23; Thu, 29 Mar 2012 15:47:22 +0000\r
+X-WSS-ID: 0M1NL6V-01-0YV-02\r
+X-M-MSG: \r
+Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com\r
+ [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128\r
+ bits)) (No\r
+ client certificate requested) by ausb3twp01.amd.com (Axway MailGate\r
+ 3.8.1) with ESMTP id 28CAAD10005 for <notmuch@notmuchmail.org>;\r
+ Thu, 29 Mar 2012 10:47:19 -0500 (CDT)\r
+Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep01.amd.com\r
+ (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.192.1;\r
+ Thu, 29 Mar 2012 10:47:35 -0500\r
+Received: from adcvmail01.amd.com (163.181.21.78) by sausexhtp02.amd.com\r
+ (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.3.213.0;\r
+ Thu, 29 Mar 2012 10:47:19 -0500\r
+Received: from mhdc-ns01.amd.com (mhdc-ns01.amd.com [165.204.35.147]) by\r
+ adcvmail01.amd.com (8.13.8/8.13.8) with ESMTP id q2TFlGX1013600;\r
+ Thu, 29 Mar 2012 10:47:16 -0500\r
+Received: from testarossa.amd.com (testarossa.amd.com [165.204.147.44]) by\r
+ mhdc-ns01.amd.com (8.13.8+Sun/8.13.8) with ESMTP id q2TFlIHI003604;\r
+ Thu, 29 Mar 2012 09:47:18 -0600 (MDT)\r
+Received: (from manderso@localhost) by testarossa.amd.com\r
+ (8.13.8/8.13.8/Submit) id q2TFlEPT008760;\r
+ Thu, 29 Mar 2012 09:47:14 -0600\r
+X-Authentication-Warning: testarossa.amd.com: manderso set sender to\r
+ MarkR.Anderson@amd.com using -f\r
+From: Mark Anderson <MarkR.Anderson@amd.com>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: Re: Goto command for existing search windows\r
+In-Reply-To: <3wd1uod7px7.fsf@testarossa.amd.com>\r
+References: <3wd1uod7px7.fsf@testarossa.amd.com>\r
+User-Agent: Notmuch/0.11.1+251~g1093c24 (http://notmuchmail.org) Emacs/23.2.1\r
+ (i686-pc-linux-gnu)\r
+Date: Thu, 29 Mar 2012 09:47:14 -0600\r
+Message-ID: <3wdmx6z5rzx.fsf@testarossa.amd.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset="us-ascii"\r
+X-OriginatorOrg: amd.com\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 29 Mar 2012 15:47:32 -0000\r
+\r
+On Tue, 27 Mar 2012 14:24:36 -0600, Mark Anderson <MarkR.Anderson@amd.com> wrote:\r
+> I was looking for a function which would find a buffer based on one of\r
+> my saved searches, and perform the search if it didn't exist.\r
+> \r
+> I've gotten it a bit closer, if I perform the search that matches a\r
+> saved search, then this routine will find it because of the magic in\r
+> notmuch-search-buffer-title, but perhaps someone else feels up to\r
+> searching through the saved searches directly?\r
+> \r
+> \r
+> \r
+> (defun notmuch-goto-or-search (&optional query)\r
+> "Find a notmuch-search buffer with the given query, or run \r
+> \"notmuch search\" with the given `query' and display results.\r
+> \r
+> If `query' is nil, it is read interactively from the minibuffer."\r
+> (interactive)\r
+> (if (null query)\r
+> (setq query (notmuch-read-query "Notmuch goto-or-search: ")))\r
+> (let ((buffer-name (notmuch-search-buffer-title query)))\r
+> (setq buf (get-buffer buffer-name)))\r
+> \r
+> (if (not buf)\r
+> (notmuch-search query)\r
+> (switch-to-buffer buf)\r
+> )))\r
+\r
+I have a slightly better-for-me version now:\r
+\r
+(defun notmuch-goto-or-search (&optional query)\r
+ "Find a notmuch saved-search query with the given name, or a\r
+search with the given query, switching to an existing buffer\r
+without changes in preference to automatically refreshing or\r
+creating the search buffer.\r
+\r
+If `query' is nil, it is read interactively from the minibuffer."\r
+ (interactive)\r
+ (if (null query)\r
+ (setq query (notmuch-read-query "Notmuch goto-or-search: ")))\r
+ (let ((saved-search-tuple (assoc query notmuch-saved-searches)))\r
+ (setq expanded-query\r
+ (if (null saved-search-tuple)\r
+ query\r
+ (cdr saved-search-tuple))))\r
+ (let ((buffer-name (notmuch-search-buffer-title expanded-query)))\r
+ (setq buf (get-buffer buffer-name)))\r
+ (if (not buf)\r
+ (notmuch-search expanded-query)\r
+ (switch-to-buffer buf)\r
+ ))\r
+\r
+This does search the saved searches to see if you entered a saved search\r
+name. With this I don't have to duplicate my query for saved searches\r
+in key bindings.\r
+\r
+(global-set-key [f8] (lambda () (interactive) (notmuch-goto-or-search "Inbox")))\r
+(global-set-key [f9] (lambda () (interactive) (notmuch-goto-or-search "INBOX")))\r
+(global-set-key [f10] (lambda () (interactive) (notmuch-goto-or-search "todo")))\r
+\r
+\r
+> I then use it something like this:\r
+> \r
+> (global-set-key [C-f1] (lambda () (interactive) (notmuch-goto-or-search "tag:inbox and tag:unread and not tag:deleted")))\r
+> (global-set-key [C-f2] (lambda () (interactive) (notmuch-goto-or-search "tag:inbox and not tag:deleted")))\r
+> (global-set-key [C-f3] 'notmuch)\r
+> (global-set-key [C-f6] (lambda () (interactive) (notmuch-goto-or-search "tag:todo and not tag:deleted")))\r
+> \r
+> It would be better if I could use my Inbox, INBOX and todo names for the\r
+> saved searches, but how to do that without breaking generality of\r
+> searching the body of the email? Do I have to define my own ss: (saved\r
+> search) prefix or something, as I believe some others have?\r
+> \r
+> This is what I'm willing to do today, and it works for me, I could patch\r
+> notmuch.el, but I wondered about answering the other questions.\r
+> \r
+> Also, some elisp master could hint about how to make the binding not so\r
+> ugly. ;)\r
+> \r
+> Another appreciated elisp hint would be how to get the buf variable to\r
+> go inside the let, I keep getting complaints about buffer-name not being\r
+> defined, thus the "ugly" setq, which works.\r
+> \r
+> Enjoy,\r
+> \r
+> -Mark\r
+\r