Goto command for existing search windows
authorMark Anderson <MarkR.Anderson@amd.com>
Tue, 27 Mar 2012 20:24:36 +0000 (14:24 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:48 +0000 (09:45 -0800)
18/971bf2a04626f17b96969a779ad8cc4aa57035 [new file with mode: 0644]

diff --git a/18/971bf2a04626f17b96969a779ad8cc4aa57035 b/18/971bf2a04626f17b96969a779ad8cc4aa57035
new file mode 100644 (file)
index 0000000..13c21dd
--- /dev/null
@@ -0,0 +1,143 @@
+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 013BA431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 27 Mar 2012 13:25:02 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3] 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 FPv8uG6I4HHP for <notmuch@notmuchmail.org>;\r
+       Tue, 27 Mar 2012 13:25:02 -0700 (PDT)\r
+Received: from va3outboundpool.messaging.microsoft.com\r
+       (va3ehsobe006.messaging.microsoft.com [216.32.180.16])\r
+       (using TLSv1 with cipher AES128-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 5DEAF431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 27 Mar 2012 13:25:02 -0700 (PDT)\r
+Received: from mail173-va3-R.bigfish.com (10.7.14.251) by\r
+       VA3EHSOBE001.bigfish.com (10.7.40.21) with Microsoft SMTP Server id\r
+       14.1.225.23; Tue, 27 Mar 2012 20:24:48 +0000\r
+Received: from mail173-va3 (localhost [127.0.0.1])     by\r
+       mail173-va3-R.bigfish.com (Postfix) with ESMTP id AF831C038D    for\r
+       <notmuch@notmuchmail.org>; Tue, 27 Mar 2012 20:24:47 +0000 (UTC)\r
+X-SpamScore: 0\r
+X-BigFish: VPS0(zzzz1202hzzz2dh668h839h944hd24h)\r
+X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null);\r
+       IPV:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI\r
+Received: from mail173-va3 (localhost.localdomain [127.0.0.1]) by mail173-va3\r
+       (MessageSwitch) id 1332879885528605_15614;\r
+       Tue, 27 Mar 2012 20:24:45 +0000 (UTC)\r
+Received: from VA3EHSMHS013.bigfish.com (unknown [10.7.14.240])        by\r
+       mail173-va3.bigfish.com (Postfix) with ESMTP id 77510600C0      for\r
+       <notmuch@notmuchmail.org>; Tue, 27 Mar 2012 20:24:45 +0000 (UTC)\r
+Received: from ausb3twp02.amd.com (163.181.249.109) by\r
+       VA3EHSMHS013.bigfish.com (10.7.99.23) with Microsoft SMTP Server id\r
+       14.1.225.23; Tue, 27 Mar 2012 20:24:45 +0000\r
+X-WSS-ID: 0M1K8PG-02-34Z-02\r
+X-M-MSG: \r
+Received: from sausexedgep02.amd.com (sausexedgep02-ext.amd.com\r
+       [163.181.249.73])       (using TLSv1 with cipher AES128-SHA (128/128\r
+       bits))  (No\r
+       client certificate requested)   by ausb3twp02.amd.com (Axway MailGate\r
+       3.8.1)\r
+       with ESMTP id 2B55BC8121        for <notmuch@notmuchmail.org>; Tue, 27 Mar 2012\r
+       15:24:52 -0500 (CDT)\r
+Received: from sausexhtp02.amd.com (163.181.3.152) by sausexedgep02.amd.com\r
+       (163.181.36.59) with Microsoft SMTP Server (TLS) id 8.3.192.1;\r
+       Tue, 27 Mar 2012 15:25:05 -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
+       Tue, 27 Mar 2012 15:24:56 -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 q2RKOolB021084 for\r
+       <notmuch@notmuchmail.org>; Tue, 27 Mar 2012 15:24:52 -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 q2RKOsKc026864      for\r
+       <notmuch@notmuchmail.org>; Tue, 27 Mar 2012 14:24:54 -0600 (MDT)\r
+Received: (from manderso@localhost)    by testarossa.amd.com\r
+       (8.13.8/8.13.8/Submit) id q2RKOcAY010042;\r
+       Tue, 27 Mar 2012 14:24:38 -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: Goto command for existing search windows\r
+User-Agent: Notmuch/0.11.1+251~g1093c24 (http://notmuchmail.org) Emacs/23.2.1\r
+       (i686-pc-linux-gnu)\r
+Date: Tue, 27 Mar 2012 14:24:36 -0600\r
+Message-ID: <3wd1uod7px7.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: Tue, 27 Mar 2012 20:25:03 -0000\r
+\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 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