mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 16:50:58 +01:00
19767, 19785: store flags for -z and -k options to autoload allowing the
completion system to be used with ksh_autoload set
This commit is contained in:
parent
8c890ebe7f
commit
ca0deae382
13 changed files with 116 additions and 80 deletions
|
|
@ -1,5 +1,13 @@
|
|||
2004-04-20 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 19767, 19785: Src/builtin.c, Src/exec.c, Src/hashtable.c,
|
||||
Src/zsh.h, Completion/compinit, Completion/compdump,
|
||||
Completion/compinstall, Completion/bashcompinit,
|
||||
Completion/Base/Widget/_next_tags, Completion/Zsh/Type/_functions,
|
||||
Completion/Zsh/Command/_typeset, Doc/Zsh/builtins.yo:
|
||||
store flags for -z and -k options to autoload allowing the
|
||||
completion system to be used with ksh_autoload set
|
||||
|
||||
* 19800: Test/B02typeset.ztst: reverse sense of `declare +m' test
|
||||
|
||||
2004-04-19 Clint Adams <clint@zsh.org>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ _next_tags() {
|
|||
(( $#funcstack > _tags_level )) && _comp_tags="${_comp_tags% * }"
|
||||
_tags_level=$#funcstack
|
||||
[[ "$_next_tags_not" = *\ ${__spec}\ * ]] && continue
|
||||
_comp_tags="$_comp_tags $__spec "
|
||||
_comp_tags+=" $__spec "
|
||||
if [[ "$curtag" = *[^\\]:* ]]; then
|
||||
zformat -f __descr "${curtag#*:}" "d:$3"
|
||||
_description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr"
|
||||
|
|
@ -64,7 +64,7 @@ _next_tags() {
|
|||
(( $#funcstack > _tags_level )) && _comp_tags="${_comp_tags% * }"
|
||||
_tags_level=$#funcstack
|
||||
[[ "$_next_tags_not" = *\ ${__spec}\ * ]] && continue
|
||||
_comp_tags="$_comp_tags $__spec "
|
||||
_comp_tags+=" $__spec "
|
||||
if [[ "$curtag" = *[^\\]:* ]]; then
|
||||
zformat -f __descr "${curtag#*:}" "d:$3"
|
||||
_description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr"
|
||||
|
|
@ -92,7 +92,7 @@ _next_tags() {
|
|||
fi
|
||||
fi
|
||||
|
||||
_next_tags_not="$_next_tags_not $_lastcomp[tags]"
|
||||
_next_tags_not+=" $_lastcomp[tags]"
|
||||
_next_tags_pfx="$PREFIX"
|
||||
_next_tags_sfx="$SUFFIX"
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ _next_tags() {
|
|||
compstate[insert]="$ins"
|
||||
compstate[list]='list force'
|
||||
|
||||
compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
|
||||
compprefuncs+=( _next_tags_pre )
|
||||
}
|
||||
|
||||
# Completer, for wrap-around.
|
||||
|
|
@ -132,9 +132,9 @@ _next_tags_pre() {
|
|||
return 0
|
||||
elif [[ ${LBUFFER%${PREFIX}} != ${_next_tags_pre}* ]]; then
|
||||
unfunction _all_labels _next_label
|
||||
autoload -U _all_labels _next_label
|
||||
autoload -Uz _all_labels _next_label
|
||||
else
|
||||
compprefuncs=( "$compprefuncs[@]" _next_tags_pre )
|
||||
compprefuncs+=( _next_tags_pre )
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
#compdef autoload
|
||||
|
||||
local expl
|
||||
|
||||
if (( $words[(I)[-+]*w*] )); then
|
||||
_description files expl 'zwc file'
|
||||
_files "$expl[@]" -g '*.zwc(-.)'
|
||||
else
|
||||
_wanted functions expl 'shell function' compadd - ${^fpath}/*(:t)
|
||||
fi
|
||||
|
|
@ -1,27 +1,31 @@
|
|||
#compdef declare export integer float local readonly typeset
|
||||
#compdef autoload declare export functions integer float local readonly typeset
|
||||
|
||||
local expl state line func i use curcontext="$curcontext"
|
||||
local -A allargs
|
||||
local fopts="-f -k -z"
|
||||
local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x"
|
||||
local -A allargs opt_args
|
||||
local -a args
|
||||
|
||||
allargs=(
|
||||
A '(-E -F -L -R -T -U -Z -a -f -i -m)-A[specify that arguments refer to associative arrays]'
|
||||
E '(-A -F -L -R -T -U -Z -a -f -i -m)-E[floating point, use engineering notation on output]'
|
||||
F '(-A -E -L -R -T -U -Z -a -f -i -m)-F[floating point, use fixed point decimal on output]'
|
||||
L '(-A -E -F -f -i)-L+[left justify and remove leading blanks from value]:width'
|
||||
R '(-A -E -F -f -i)-R+[right justify and fill with leading blanks]:width'
|
||||
T '(-A -E -F -a -f -g -h -i -l -m -t)-T[tie scalar to array]'
|
||||
A "($fopts -E -F -L -R -T -U -Z -a -i -m)-A[specify that arguments refer to associative arrays]"
|
||||
E "($fopts -A -F -L -R -T -U -Z -a -i -m)-E[floating point, use engineering notation on output]"
|
||||
F "($fopts -A -E -L -R -T -U -Z -a -i -m)-F[floating point, use fixed point decimal on output]"
|
||||
L "($fopts -A -E -F -i)-L+[left justify and remove leading blanks from value]:width"
|
||||
R "($fopts -A -E -F -i)-R+[right justify and fill with leading blanks]:width"
|
||||
T "($fopts -A -E -F -a -g -h -i -l -m -t)-T[tie scalar to array]"
|
||||
U '(-A -E -F -i)-U[keep array values unique and suppress alias expansion for functions]'
|
||||
Uf '(-E -F -i)-U[suppress alias expansion for functions]'
|
||||
Up '(-E -F -i)-U[keep array values unique]'
|
||||
Z '(-A -E -F -f -i)-Z+[right justify and fill with leading zeros]:width'
|
||||
a '(-A -E -F -T -f -i)-a[specify that arguments refer to arrays]'
|
||||
f '(-A -E -F -L -R -T -Z -a -g -h -i -l -r -x)-f[specify that arguments refer to functions]'
|
||||
g '(-T -f)-+g[do not restrict parameter to local scope]'
|
||||
h '(-T -f)-+h[hide specialness of parameter]'
|
||||
H '(-T -f)-+H[hide value of parameter in listings]'
|
||||
i '(-A -E -F -T -f)-+i[represent internally as an integer]'
|
||||
l '(-T -f)-l[convert the value to lowercase]'
|
||||
Uf '-U[suppress alias expansion for functions]'
|
||||
Up '(-E -F -i)-+U[keep array values unique]'
|
||||
X '+X[immediately autoload function]'
|
||||
Z "($fopts -A -E -F -i)-Z+[right justify and fill with leading zeros]:width"
|
||||
a "($fopts -A -E -F -T -i)-a[specify that arguments refer to arrays]"
|
||||
f "($popts)-f[specify that arguments refer to functions]"
|
||||
g "($fopts -T)-+g[do not restrict parameter to local scope]"
|
||||
h "($fopts -T)-+h[hide specialness of parameter]"
|
||||
H "($fopts -T)-+H[hide value of parameter in listings]"
|
||||
i "($fopts -A -E -F -T)-+i[represent internally as an integer]"
|
||||
k "($popts -w -z)-+k[mark function for ksh-style autoloading]"
|
||||
l "($popts -T)-l[convert the value to lowercase]"
|
||||
m '(-A -E -F -T -i)-m[treat arguments as patterns]'
|
||||
p '-p[output parameters in form of calls to typeset]'
|
||||
r '(-f)-+r[mark parameters as readonly]'
|
||||
|
|
@ -31,15 +35,21 @@ allargs=(
|
|||
u '-u[convert the value to uppercase or mark function for autoloading]'
|
||||
uf '-u[mark function for autoloadling]'
|
||||
up '-u[convert the value to uppercase]'
|
||||
x '(-f)-+x[export parameter]'
|
||||
w '(-k -z)-w[specify that arguments refer to files compiled with zcompile]'
|
||||
x "($fopts)-+x[export parameter]"
|
||||
z "($popts -k -w)-+z[mark function for zsh-style autoloading]"
|
||||
)
|
||||
|
||||
use="AEFHLRTUZafghilmprtux"
|
||||
use="AEFHLRTUZafghiklmprtuxz"
|
||||
|
||||
case ${service} in
|
||||
autoload)
|
||||
use="UXktwz"
|
||||
func=f
|
||||
;;
|
||||
float) use="EFHghlprtux";;
|
||||
functions)
|
||||
use="Umtu"
|
||||
use="Ukmtuz"
|
||||
func=f
|
||||
;;
|
||||
integer)
|
||||
|
|
@ -47,28 +57,39 @@ case ${service} in
|
|||
allargs[i]='-i[specify arithmetic base for output]' \
|
||||
;;
|
||||
readonly) use="${use/r/}" ;;
|
||||
local) use="${use/f/}" ;&
|
||||
export) use="${${use/g/}/x/}" ;;
|
||||
local) use="${use/[fkz]/}" ;&
|
||||
export) use="${${use//[gkz]/}/x/}" ;;
|
||||
esac
|
||||
|
||||
[[ -z "${words[(r)-*f*]}" ]] || func=f
|
||||
[[ -z "${words[(r)-*[aA]*]}" ]] || func=p
|
||||
[[ -z "${words[(r)-*f*]}" ]] || func=f
|
||||
|
||||
for ((i=1;i<=$#use;++i)); do
|
||||
args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} )
|
||||
done
|
||||
|
||||
_arguments -C -s -A "-*" -S "${args[@]}" '*:vars:->vars_eq'
|
||||
_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq'
|
||||
|
||||
if [[ "$state" = vars_eq ]]; then
|
||||
if [[ $func = f ]]; then
|
||||
if (( $+opt_args[-w] ));then
|
||||
_wanted files expl 'zwc file' _files -g '*.zwc(-.)'
|
||||
elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
|
||||
_wanted functions expl 'shell function' compadd - ${^fpath}/*(:t)
|
||||
else
|
||||
_functions
|
||||
fi
|
||||
elif [[ "$PREFIX" = *\=* ]]; then
|
||||
compstate[parameter]="${PREFIX%%\=*}"
|
||||
compset -P 1 '*='
|
||||
_value
|
||||
elif (( $+opt_args[-a] || $+opt_args[-A] )); then
|
||||
_parameters -q
|
||||
elif (( $+opt_args[-T] )); then
|
||||
_arguments \
|
||||
':scalar parameter:_parameters -g "*scalar*" -q -S "="' \
|
||||
':array parameter:_parameters -g "*array*"' \
|
||||
':separator character'
|
||||
else
|
||||
_parameters -q -S '='
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef functions unfunction
|
||||
#compdef unfunction
|
||||
|
||||
local expl
|
||||
|
||||
|
|
|
|||
|
|
@ -168,5 +168,5 @@ complete() {
|
|||
}
|
||||
|
||||
unfunction bashcompinit
|
||||
autoload -U bashcompinit
|
||||
autoload -Uz bashcompinit
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ zle -lL |
|
|||
d_complist=yes
|
||||
fi
|
||||
print -r - ${_d_line}
|
||||
_d_bks=($_d_bks ${_d_line[3]})
|
||||
_d_bks+=(${_d_line[3]})
|
||||
fi
|
||||
done >> $_d_file
|
||||
bindkey |
|
||||
|
|
@ -108,7 +108,7 @@ _d_als=(${(o)$(typeset +fm '_*')})
|
|||
# print them out: about five to a line looks neat
|
||||
|
||||
_i=5
|
||||
print -n autoload -U >> $_d_file
|
||||
print -n autoload -Uz >> $_d_file
|
||||
while (( $#_d_als )); do
|
||||
if (( ! $+_compautos[$_d_als[1]] )); then
|
||||
print -n " $_d_als[1]"
|
||||
|
|
@ -123,7 +123,7 @@ done >> $_d_file
|
|||
print >> $_d_file
|
||||
|
||||
for _i in "${(ok@)_compautos}"; do
|
||||
print "autoload -U $_compautos[$_i] $_i" >> $_d_file
|
||||
print "autoload -Uz $_compautos[$_i] $_i" >> $_d_file
|
||||
done
|
||||
|
||||
print >> $_d_file
|
||||
|
|
@ -134,4 +134,4 @@ print "_comp_assocs=( ${(q)_comp_assocs} )" >> $_d_file
|
|||
mv $_d_file ${_d_file%.$HOST.$$}
|
||||
|
||||
unfunction compdump
|
||||
autoload -U compdump
|
||||
autoload -Uz compdump
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
# generate matches, but should automatically be loaded
|
||||
# when they are called. The <options> will be given to the
|
||||
# autoload builtin when making the function autoloaded. Note
|
||||
# that this need not include `-U'.
|
||||
# that this need not include `-U' and `-z'.
|
||||
#
|
||||
# Note that no white space is allowed between the `#' and the rest of
|
||||
# the string.
|
||||
|
|
@ -292,7 +292,7 @@ compdef() {
|
|||
# and probably do autoloading.
|
||||
|
||||
func="$1"
|
||||
[[ -n "$autol" ]] && autoload -U "$func"
|
||||
[[ -n "$autol" ]] && autoload -Uz "$func"
|
||||
shift
|
||||
|
||||
case "$type" in
|
||||
|
|
@ -406,7 +406,7 @@ typeset _i_wdirs _i_wfiles
|
|||
_i_wdirs=()
|
||||
_i_wfiles=()
|
||||
|
||||
autoload -U compaudit
|
||||
autoload -Uz compaudit
|
||||
if [[ -n "$_i_check" ]]; then
|
||||
typeset _i_q
|
||||
if ! eval compaudit; then
|
||||
|
|
@ -433,7 +433,7 @@ if [[ -n "$_i_check" ]]; then
|
|||
fi
|
||||
|
||||
# Make sure compdump is available, even if we aren't going to use it.
|
||||
autoload -U compdump compinstall
|
||||
autoload -Uz compdump compinstall
|
||||
|
||||
# If we have a dump file, load it.
|
||||
|
||||
|
|
@ -473,7 +473,7 @@ if [[ -z "$_i_done" ]]; then
|
|||
fi
|
||||
;;
|
||||
(\#autoload)
|
||||
autoload -U "$_i_line[@]" ${_i_name}
|
||||
autoload -Uz "$_i_line[@]" ${_i_name}
|
||||
[[ "$_i_line" != \ # ]] && _compautos[${_i_name}]="$_i_line"
|
||||
;;
|
||||
esac
|
||||
|
|
@ -505,6 +505,6 @@ if [[ ${_i_line[2]} = expand-or-complete ]] &&
|
|||
fi
|
||||
|
||||
unfunction compinit compaudit
|
||||
autoload -U compinit compaudit
|
||||
autoload -Uz compinit compaudit
|
||||
|
||||
return 0
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ local compcontext=-default-
|
|||
__ci_tidyup() {
|
||||
unfunction -m __ci_\* 2>/dev/null
|
||||
unfunction compinstall
|
||||
autoload -U compinstall
|
||||
autoload -Uz compinstall
|
||||
}
|
||||
|
||||
__ci_newline() {
|
||||
|
|
@ -119,7 +119,7 @@ ${match[3]}"
|
|||
then
|
||||
compinit_args=$match[1]
|
||||
elif [[ $line != [[:blank:]]# &&
|
||||
$line != [[:blank:]]#'autoload -U compinit' &&
|
||||
$line != [[:blank:]]#'autoload -Uz compinit' &&
|
||||
$line != [[:blank:]]#compinit &&
|
||||
$line != [[:blank:]]#zstyle[[:blank:]]#:compinstall* ]]; then
|
||||
warn_unknown="${warn_unknown:+$warn_unknown
|
||||
|
|
@ -1886,7 +1886,7 @@ $output"
|
|||
[[ -n $fpath_line ]] && print -r "$fpath_line"
|
||||
|
||||
print -r "
|
||||
autoload -U compinit
|
||||
autoload -Uz compinit
|
||||
compinit${compinit_args:+ $compinit_args}"
|
||||
|
||||
print -r "$endline"
|
||||
|
|
|
|||
|
|
@ -2406,9 +2406,16 @@ bin_functions(char *name, char **argv, Options ops, int func)
|
|||
on |= PM_TAGGED;
|
||||
else if (OPT_PLUS(ops,'t'))
|
||||
off |= PM_TAGGED;
|
||||
if (OPT_MINUS(ops,'z'))
|
||||
on |= PM_ZSHSTORED;
|
||||
else if (OPT_PLUS(ops,'z'))
|
||||
off |= PM_ZSHSTORED;
|
||||
if (OPT_MINUS(ops,'k'))
|
||||
on |= PM_KSHSTORED;
|
||||
else if (OPT_PLUS(ops,'k'))
|
||||
off |= PM_KSHSTORED;
|
||||
|
||||
if ((off & PM_UNDEFINED) || (OPT_ISSET(ops,'k') && OPT_ISSET(ops,'z')) ||
|
||||
(!OPT_PLUS(ops,'X') && (OPT_ISSET(ops,'k') || OPT_ISSET(ops,'z'))) ||
|
||||
(OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || *argv || !scriptname))) {
|
||||
zwarnnam(name, "invalid option(s)", NULL, 0);
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -3398,8 +3398,12 @@ loadautofn(Shfunc shf, int fksh, int autol)
|
|||
prog = getfpfunc(shf->nam, &ksh);
|
||||
noaliases = noalias;
|
||||
|
||||
if (ksh == 1)
|
||||
if (ksh == 1) {
|
||||
ksh = fksh;
|
||||
if (ksh == 1)
|
||||
ksh = (shf->flags & PM_KSHSTORED) ? 2 :
|
||||
(shf->flags & PM_ZSHSTORED) ? 0 : 1;
|
||||
}
|
||||
|
||||
if (prog == &dummy_eprog) {
|
||||
/* We're not actually in the function; decrement locallevel */
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ static void
|
|||
printshfuncnode(HashNode hn, int printflags)
|
||||
{
|
||||
Shfunc f = (Shfunc) hn;
|
||||
char *t;
|
||||
char *t = 0;
|
||||
|
||||
if ((printflags & PRINT_NAMEONLY) ||
|
||||
((printflags & PRINT_WHENCE_SIMPLE) &&
|
||||
|
|
@ -881,32 +881,35 @@ printshfuncnode(HashNode hn, int printflags)
|
|||
return;
|
||||
}
|
||||
|
||||
if (f->flags & PM_UNDEFINED)
|
||||
t = tricat("builtin autoload -X",
|
||||
((f->flags & PM_UNALIASED)? "U" : ""),
|
||||
((f->flags & PM_TAGGED)? "t" : ""));
|
||||
else {
|
||||
if (!f->funcdef)
|
||||
t = 0;
|
||||
else
|
||||
t = getpermtext(f->funcdef, NULL);
|
||||
}
|
||||
|
||||
quotedzputs(f->nam, stdout);
|
||||
if (t) {
|
||||
if (f->funcdef || f->flags & PM_UNDEFINED) {
|
||||
printf(" () {\n\t");
|
||||
if (f->flags & PM_UNDEFINED)
|
||||
printf("%c undefined\n\t", hashchar);
|
||||
else
|
||||
t = getpermtext(f->funcdef, NULL);
|
||||
if (f->flags & PM_TAGGED)
|
||||
printf("%c traced\n\t", hashchar);
|
||||
if (!t) {
|
||||
char *fopt = "Utkz";
|
||||
int flgs[] = {
|
||||
PM_UNALIASED, PM_TAGGED, PM_KSHSTORED, PM_ZSHSTORED, 0
|
||||
};
|
||||
int fl;;
|
||||
|
||||
zputs("builtin autoload -X", stdout);
|
||||
for (fl=0;fopt[fl];fl++)
|
||||
if (f->flags & flgs[fl]) putchar(fopt[fl]);
|
||||
} else {
|
||||
zputs(t, stdout);
|
||||
if (f->funcdef && (f->funcdef->flags & EF_RUN)) {
|
||||
zsfree(t);
|
||||
if (f->funcdef->flags & EF_RUN) {
|
||||
printf("\n\t");
|
||||
quotedzputs(f->nam, stdout);
|
||||
printf(" \"$@\"");
|
||||
}
|
||||
}
|
||||
printf("\n}\n");
|
||||
zsfree(t);
|
||||
} else {
|
||||
printf(" () { }\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1197,6 +1197,9 @@ struct tieddata {
|
|||
#define PM_HIDEVAL (1<<15) /* Value not shown in `typeset' commands */
|
||||
#define PM_TIED (1<<16) /* array tied to colon-path or v.v. */
|
||||
|
||||
#define PM_KSHSTORED (1<<17) /* function stored in ksh form */
|
||||
#define PM_ZSHSTORED (1<<18) /* function stored in zsh form */
|
||||
|
||||
/* Remaining flags do not correspond directly to command line arguments */
|
||||
#define PM_LOCAL (1<<21) /* this parameter will be made local */
|
||||
#define PM_SPECIAL (1<<22) /* special builtin parameter */
|
||||
|
|
@ -1210,7 +1213,7 @@ struct tieddata {
|
|||
#define PM_NAMEDDIR (1<<30) /* has a corresponding nameddirtab entry */
|
||||
|
||||
/* The option string corresponds to the first of the variables above */
|
||||
#define TYPESET_OPTSTR "aiEFALRZlurtxUhHT"
|
||||
#define TYPESET_OPTSTR "aiEFALRZlurtxUhHTkz"
|
||||
|
||||
/* These typeset options take an optional numeric argument */
|
||||
#define TYPESET_OPTNUM "LRZiEF"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue