Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: cd /u/N/v/ tab expansion
Apparently compadd uses the $SUFFIX env behind the scene...
compadd -Qf -J argument-rest -X %Bfiles%b -J globbed-files \
-M m:{a-z}={A-Z} -M m:{a-z}={A-Z} -p a/ -W a/ \
-M r:|/=* r:|=* - b1/d/e2/g
...and THIS doesn't work with SUFFIX="*/d/e/g*" - therefore I did:
- compadd "$tmp4[@]" $listopts - "$i"
+ compadd "$tmp4[@]" -U $listopts - "$i"
Actually I might have an idea why the original code doesn't work - see,
the "*/d/e/g*" is a pattern... that doesn't assume "e*" for "e2" part.
My original invocation wasn't a pattern, but "a/b/d/e/g" that was about
to be completed with the list-suffixes style as "containing multiple
partially typed pathname components"; however, the glob_complete sets
the compstate[pattern_match] which results in: "wildcard '*' is assumed at
the cursor position".
So, the correct solutions seem to be one of two (or maybe both):
1. either use the compadd -U flag as above or
2. properly mangle the SUFFIX (the 'g' global flag for substitution)
- [[ -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.
$ 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/
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