diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-09-02 09:42:05 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-09-02 09:42:05 +0000 |
commit | 586aaeb0861cce12a22af5bb3288c4e84b1c0bb4 (patch) | |
tree | d2ba4d41714cee418ceb22a50da63bbca6087cf7 | |
parent | b13200b2a367d513c445dcc35e7d35b71990bcc1 (diff) | |
download | zsh-586aaeb0861cce12a22af5bb3288c4e84b1c0bb4.tar.gz zsh-586aaeb0861cce12a22af5bb3288c4e84b1c0bb4.tar.xz zsh-586aaeb0861cce12a22af5bb3288c4e84b1c0bb4.zip |
zsh-workers/7628
-rw-r--r-- | Completion/Core/_parameters | 24 | ||||
-rw-r--r-- | Completion/Core/_path_files | 16 | ||||
-rw-r--r-- | Src/Modules/parameter.c | 3 | ||||
-rw-r--r-- | Src/params.c | 2 |
4 files changed, 37 insertions, 8 deletions
diff --git a/Completion/Core/_parameters b/Completion/Core/_parameters index a6336424c..0fd6585a2 100644 --- a/Completion/Core/_parameters +++ b/Completion/Core/_parameters @@ -27,18 +27,21 @@ fi _description expl parameter -if zmodload -e parameter; then - setopt localoptions extendedglob - pars=( ${(k)parameters[(R)^*local*]} ) -else - pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } ) -fi - if [[ -n "$slash" && -o autoparamslash ]]; then local i dirs nodirs ret=1 dirs=() nodirs=() + + if zmodload -e parameter; then + setopt localoptions extendedglob + nodirs=( ${(k)parameters[(R)undefined]} ) + pars=( ${(k)parameters[(R)^*(local|undefined)*]} ) + else + nodirs=( ${${(M)${(f)"$(typeset +)"}:#undefined *}##* } ) + pars=( ${${${(f)"$(typeset +)"}:#*(local|undefined) *}##* } ) + fi + for i in $pars; do if [[ -d "${(P)i}" ]]; then dirs=( $dirs $i ) @@ -57,6 +60,13 @@ if [[ -n "$slash" && -o autoparamslash ]]; then return ret else + if zmodload -e parameter; then + setopt localoptions extendedglob + pars=( ${(k)parameters[(R)^*local*]} ) + else + pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } ) + fi + if [[ "$slash" = normal ]]; then compadd -S "$suf" -r ' [:' "$expl[@]" "$@" - $pars elif [[ "$slash" = brace ]]; then diff --git a/Completion/Core/_path_files b/Completion/Core/_path_files index 9aebc89d0..b017d78e5 100644 --- a/Completion/Core/_path_files +++ b/Completion/Core/_path_files @@ -173,6 +173,22 @@ if [[ "$pre[1]" = \~ ]]; then orig="${orig#*/}" donepath='' prepaths=( '' ) +elif [[ "$pre" = *\$*/* ]]; then + + # If there is a parameter expansion in the word from the line, we try + # to complete the beast by expanding the prefix and completing anything + # after the first slash after the parameter expansion. + # This fails for things like `f/$foo/b/<TAB>' where the first `f' is + # meant as a partial path. + + linepath="${(M)pre##*\$[^/]##/}" + realpath=${(e)~linepath} + [[ "$realpath" = "$linepath" ]] && return 1 + pre="${pre#${linepath}}" + i="${#linepath//[^\\/]}" + orig="${orig[1,(in:i:)/][1,-2]}" + donepath='' + prepaths=( '' ) else # If the string does not start with a `~' we don't remove a prefix from the # string. diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 08c95c610..2d932ce06 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -83,6 +83,9 @@ paramtypestr(Param pm) int f = pm->flags; if (!(f & PM_UNSET)) { + if (pm->flags & PM_AUTOLOAD) + return dupstring("undefined"); + switch (PM_TYPE(f)) { case PM_SCALAR: val = "scalar"; break; case PM_ARRAY: val = "array"; break; diff --git a/Src/params.c b/Src/params.c index dfa1d1a7f..75c5d915d 100644 --- a/Src/params.c +++ b/Src/params.c @@ -292,7 +292,7 @@ getparamnode(HashTable ht, char *nam) if (!load_module(mn)) return NULL; hn = gethashnode2(ht, nam); - if (((Param) hn) == pm) { + if (((Param) hn) == pm && (pm->flags & PM_AUTOLOAD)) { pm->flags &= ~PM_AUTOLOAD; zwarnnam(nam, "autoload failed", NULL, 0); } |