Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Why does _main_complete not try the next completer when $_comp_mesg is non-zero?



On Sun, Mar 28, 2021 at 9:34 AM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
>
> The following line in _main_complete
>
> [[ -n "$_comp_mesg" ]] && break
>
> has the effect that, whenever _message has been called (with only few
> exceptions), the next completer won't be tried, _even when
> $compstate[nmatches] is zero._

This is documented, though not precisely accurately:

     ... Note that if there
     are no matches at the time this function is called,
     compstate[insert] is cleared, so additional matches generated later
     are not inserted on the command line.

> Why? What is the reason for this?

_message is intended to be called as a last resort when the completion
function believes it is impossible to generate matches.

(FWIW, I think this behavior pre-dates the ability to complete words
from history, which obviously means it's never literally impossible to
generate something.)

> And is there a convenient way to work around this behavior?

What does "convenient" mean here?  More convenient than just invoking
a binding for history-complete when you see the message, so that the
_grep completion is bypassed?

You might be able to do something by specifying a different completion
for the tag :completion::complete:grep:argument-1:




Messages sorted by: Reverse Date, Date, Thread, Author