[PATCH 1/2] completion: more complete completion for zsh.

David Bremner david at tethera.net
Mon Sep 17 05:01:43 PDT 2018


Vincent Breitmoser <look at my.amazin.horse> writes:

> --- /dev/null
> +++ b/completion/zsh/_email-notmuch
> @@ -0,0 +1,9 @@
> +#autoload
> +
> +local expl
> +local -a notmuch_addr
> +
> +notmuch_addr=( ${(f)"$(notmuch address --deduplicate=address --output=address -- $PREFIX'*')"} )
> +
> +_description notmuch-addr expl 'email address (notmuch)'
> +compadd "$expl[@]" -a notmuch_addr

This completion only works on the first word in the email address,
because xapian search is word based.  As an example

to:look<TAB>     completes to look at my.amazin.horse
to:look@<TAB>    lists some odd things like localhost and ip6-loopback,
                 along with look at my.amazin.horse
to:look at m<TAB>   no completions

It's possible it would make sense to use regex search here (only available
with to: and from: prefixes), although I'd be cautious about the
performance impact. Untested, but the search term would then look like

            from:/$PREFIX/

In my unscientific tests,

     % notmuch address --output=address  from:/bremn/

took about 0.2s, while

     % notmuch address --output=address from:bremn\*

took 0.147s

That's not really a fair test, since your current query matches against
the body as well, and is slower

     % notmuch address --output=address bremn\*

takes about 0.5s




More information about the notmuch mailing list