(emacs) customise key bindings taking text input

Matthew Lear matt at bubblegen.co.uk
Wed Jul 15 01:28:51 PDT 2015


>
> On Tue, 14 Jul 2015, Matthew Lear <matt at bubblegen.co.uk> wrote:
>> Hi all,
>>
>> I was wondering if there was a way to add a new search similar to what
>> pressing s does, but make it use a predefined list of search terms in
>> addition to the text being entered? For example, I have reams of bug
>> notification emails which currently have various tags applied. If I
>> wanted
>> to search a subset of these tags with a number (bug id) in the subject,
>> right now I have to press s and type tag:foo and tag:bar and
>> subject:1234.
>> If I could add a new search option (eg 'B') and after pressing that I
>> simply enter the bug id and hit return, it would save me a lot of
>> typing.
>> I have custom searches set up which do the 'tag:foo and tag:bar' and I
>> can
>> filter on the subject, but that still means pressing f and typing
>> subject:1234.
>>
>> I fear I'm rambling here but hopefully I've conveyed what I'm trying to
>> do.
>> Is this possible?
>> Just trying to cut down on my typing ;-)
>
> I don't think there is anything built in but adding something like this
> snippet
>
> (defun my-search (&optional bug)
>   (interactive)
>   (let* ((bug (or bug (notmuch-read-query "Bug number: ")))
> 	 (query (concat "tag:foo and tag:bar and subject:" bug)))
>     (notmuch-search query)))
>
> to your .emacs file and binding it to B in the notmuch-common-keymap would
> probably
> do what you want.
>
> If people think this would be more generally useful it may be possible
> to add something like this to saved searches (ie a partial saved search)
> and then they would be accessible from notmuch-hello or via notmuch
> jump.

That's a good idea. Hooking into saved searches and then being able to
refine/enhance them via a customisable text input field would be really
nice.
The above lisp-fu works a treat. Thank you very much, and thanks for
fixing the mark read logic in notmuch-tree :-)
Cheers,
--  Matt



More information about the notmuch mailing list