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

Re: Conditionally complete on space.



On 08/17/2017 07:07 PM, Daniel Shahaf wrote:
> Define a custom widget:
> 
>     maybe-complete-on-space() {
>       if [[ $LBUFFER[-1] == ' ' ]]; then
>         zle self-insert
>       else
>         zle expand-or-complete
>       fi
>     }
>     zle -N maybe-complete-on-space
> 
> and bind it:
> 
>     bindkey ' ' maybe-complete-on-space

Thank you Daniel!

That does seem very close to what I want.

> This implements the behaviour you specified, but I suspect you meant the
> 'if' and the 'else' behaviours to be the other way around.

Nope, you got what I wanted the first time.

> You aren't changing the behaviour of completion, you are just changing
> the method of invoking it, so the solution was in zshzle(1)'s domain,
> not in zshcompsys(1)'s.

Good to know.

I did find a couple of oddities when I was testing as you provided:

1)  I need to hit space an extra time after completion.  I.e. "sip   "
results in "sipcalc  ".  -  It seems as if the second space is
swallowed.  (I do not consider this a problem and am happy to live with it.

2)  I seem to be stuck in a loop if I try to complete "kil" into "kill"
because "killall" is also matched.

I tried playing with recexact to allow the exact match, "kill", to be
accepted.  But I'm obviously missing something.

I will play with it more as time permits tomorrow.

Thank you again Daniel.



-- 
Grant. . . .
unix || die

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



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