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

Re: cd /u/N/v/ tab expansion



On Sun, Apr 10, 2022 at 19:45:51 +0200, Tomasz Pala wrote:

> ...and THIS doesn't work with SUFFIX="*/d/e/g*" - therefore I did:
> 
> 
> -             compadd "$tmp4[@]" $listopts - "$i"
> +             compadd "$tmp4[@]" -U $listopts - "$i"

This with list-dirs-first has one issue:

$ ls u/s*/ax	-- cursor over 'a', tab menu cycling

[directories]
usr/share/aclocal/ x
usr/share/atever/ x
[files]
usr/sbin/a1
usr/share/a1
usr/share/a2

Note missing ' x' after completing files. Is that -U dropping the SUFFIX?

> 
> -            [[ -n "$compstate[pattern_match]" ]] && SUFFIX="${SUFFIX:s./.*/}*"
> +            [[ -n "$compstate[pattern_match]" ]] && SUFFIX="${SUFFIX:gs./.*/}*"
> 
> 
> The second solution doesn't play well with add-space style:
> 
> $ ls a/b/d/e/g[tab]
> b1/d/e1/g/  b1/d/e2/g/  b2/d/e1/g/  b2/d/e2/g/
> 
> [ctrl-g]
> $ ls a/b/d/e/g[tab]
> $ ls a/b1/d/e1/ /g
>                ^ cursor position
> b1/d/e1/  b1/d/e2/  b2/d/e1/  b2/d/e2/
> 
> [ctrl-g]
> $ ls a/b/d/e/g[tab]
> b1/d/e1/g/  b1/d/e2/g/  b2/d/e1/g/  b2/d/e2/g/
> 
> and so on, over and over again.

This cycling (ctrl-g toggling of behaviour) means something is not being
reset/unset properly and should be fixed.

However the latter case:

> $ zstyle -d :completion:\* add-space
> $ ls a/b/d/e/g[tab]
> $ ls a/b1/d/e1//g
> b1/d/e1/  b1/d/e2/  b2/d/e1/  b2/d/e2/

with cursor over first of "//" also differs from the first run (the
correct one).


This is caused by MBEGIN and MEND variables being set in both cases
(add-space and not). If they are about to be kept between the completion
invocations (even after the ctrl-c), they should not be used in
completion functions. Otherwise they should be cleared not to leak some
bogus state into consecutive invocations.

What is the purpose of MBEGIN and MEND?


> Both of the solutions also seem to fix the list-dirs-first true issue!

-- 
Tomasz Pala <gotar@xxxxxxxxxxxxx>




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