From: Mark Anderson <MarkR.Anderson@amd.com>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: Goto command for existing search windows
Date: Tue, 27 Mar 2012 14:24:36 -0600 [thread overview]
Message-ID: <3wd1uod7px7.fsf@testarossa.amd.com> (raw)
I was looking for a function which would find a buffer based on one of
my saved searches, and perform the search if it didn't exist.
I've gotten it a bit closer, if I perform the search that matches a
saved search, then this routine will find it because of the magic in
notmuch-search-buffer-title, but perhaps someone else feels up to
searching through the saved searches directly?
(defun notmuch-goto-or-search (&optional query)
"Find a notmuch-search buffer with the given query, or run
\"notmuch search\" with the given `query' and display results.
If `query' is nil, it is read interactively from the minibuffer."
(interactive)
(if (null query)
(setq query (notmuch-read-query "Notmuch goto-or-search: ")))
(let ((buffer-name (notmuch-search-buffer-title query)))
(setq buf (get-buffer buffer-name)))
(if (not buf)
(notmuch-search query)
(switch-to-buffer buf)
)))
I then use it something like this:
(global-set-key [C-f1] (lambda () (interactive) (notmuch-goto-or-search "tag:inbox and tag:unread and not tag:deleted")))
(global-set-key [C-f2] (lambda () (interactive) (notmuch-goto-or-search "tag:inbox and not tag:deleted")))
(global-set-key [C-f3] 'notmuch)
(global-set-key [C-f6] (lambda () (interactive) (notmuch-goto-or-search "tag:todo and not tag:deleted")))
It would be better if I could use my Inbox, INBOX and todo names for the
saved searches, but how to do that without breaking generality of
searching the body of the email? Do I have to define my own ss: (saved
search) prefix or something, as I believe some others have?
This is what I'm willing to do today, and it works for me, I could patch
notmuch.el, but I wondered about answering the other questions.
Also, some elisp master could hint about how to make the binding not so
ugly. ;)
Another appreciated elisp hint would be how to get the buf variable to
go inside the let, I keep getting complaints about buffer-name not being
defined, thus the "ugly" setq, which works.
Enjoy,
-Mark
next reply other threads:[~2012-03-27 20:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 20:24 Mark Anderson [this message]
2012-03-29 15:47 ` Goto command for existing search windows Mark Anderson
2012-03-29 20:27 ` Jameson Graef Rollins
2012-03-29 21:57 ` Jani Nikula
2012-03-30 0:44 ` Jameson Graef Rollins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3wd1uod7px7.fsf@testarossa.amd.com \
--to=markr.anderson@amd.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).