1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2026-01-04 09:01:06 +01:00

manual/8424

This commit is contained in:
Tanaka Akira 1999-10-26 15:36:10 +00:00
parent 56f338eb8b
commit e0b26186f1
96 changed files with 5922 additions and 4024 deletions

View file

@ -3,8 +3,6 @@
# Complete the arguments of the current command according to the
# descriptions given as arguments to this function.
setopt localoptions extendedglob
local long cmd="$words[1]" descr mesg
long=$argv[(I)--]

View file

@ -6,8 +6,6 @@ _parameters -e
# Without the `-e' option, we would use the following (see the file
# Core/_parameters for more enlightenment).
# setopt localoptions extendedglob
# local lp ls n q
# if [[ "$SUFFIX" = *\}* ]]; then

View file

@ -4,24 +4,34 @@
# complete only external commands and executable files. This and a
# `-' as the first argument is then removed from the arguments.
local nm=$compstate[nmatches] ret=1 expl type=-c
local nm=$compstate[nmatches] ret=1 expl ext
if [[ "$1" = -e ]]; then
type=-m
ext=yes
shift
elif [[ "$1" = - ]]; then
shift
fi
# Complete jobs in implicit fg and bg
if [[ $type = -c && "$PREFIX[1]" = "%" ]]; then
_description expl job
compgen "$expl[@]" "$@" -j -P '%'
if [[ -z "$ext" && "$PREFIX[1]" = "%" ]]; then
_job -P '%'
[[ nm -ne compstate[nmatches] ]] && return
fi
_description expl command
compgen "$expl[@]" "$@" $type && ret=0
_description expl 'external command'
compadd "$expl[@]" "$@" - "${(k@)commands}" && ret=0
if [[ -z "$ext" ]]; then
_description expl 'builtin command'
compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0
_description expl 'shell function'
compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0
_description expl 'alias'
compadd "$expl[@]" "$@" - "${(k@)raliases[(R)^?disabled*]}" && ret=0
_description expl 'reserved word'
compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0
fi
if [[ nm -eq compstate[nmatches] ]]; then
_description expl 'executable file or directory'

View file

@ -2,8 +2,6 @@
# This can be used to add options or values with descriptions as matches.
setopt localoptions extendedglob
local isopt cmd opt expl tmps tmpd tmpmd tmpms ret=1 showd _nm hide
cmd="$words[1]"

View file

@ -3,6 +3,6 @@
local expl
_description expl alias
compgen "$expl[@]" -a
compadd "$@" "$expl[@]" - "${(@k)aliases[(R)^?disabled*]}"
_description expl command
compgen "$expl[@]" -m
compadd "$@" "$expl[@]" - "${(k@)commands}"

View file

@ -55,7 +55,7 @@
# else
# _description -V expl "history ($n)"
# fi
# if compgen "$expl[@]" -Q -H $(( i*10 )) ''; then
# if compadd "$expl[@]" -Q - "${(@)historywords:#[\$'\"]*}"; then
# # We have found at least one matching word, so we switch
# # on menu-completion and make sure that no other
# # completion function is called by setting _compskip.

26
Completion/Base/_job Normal file
View file

@ -0,0 +1,26 @@
#autoload
local expl disp jobs job jids
if [[ "$1" = -r ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
shift
_description expl 'running job'
elif [[ "$1" = -s ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
shift
_description expl 'suspended job'
else
[[ "$1" = - ]] && shift
jids=( "${(@k)jobtexts}" )
_description expl job
fi
disp=()
jobs=()
for job in "$jids[@]"; do
disp=( "$disp[@]" "[${(l:2:: :)job}] ${jobtexts[$job]}" )
jobs=( "$jobs[@]" "$job" )
done
compadd "$@" "$expl[@]" -ld disp - "$jobs[@]"

View file

@ -206,7 +206,6 @@ _ra_gen_func () {
print -lr - \
"$funcname () {" \
'setopt localoptions extendedglob' \
'local _ra_state _ra_left _ra_right _ra_actions' \
"_ra_state=$start" \
'_ra_left=' \
@ -323,8 +322,6 @@ _ra_gen_parse_state () {
}
_regex_arguments () {
setopt localoptions extendedglob
local funcname="_regex_arguments_tmp"
local funcdef

View file

@ -2,12 +2,7 @@
# We use all named directories and user names here. If this is too slow
# for you or if there are too many of them, you may want to use
# `compgen -k friends -qS/' or something like that. To get all user names
# if there are no matches in the `friends' array, add
# `(( compstate[nmatches] )) || compgen -nu -qS/'
# below that.
setopt localoptions extendedglob
# `compadd -qS/ - "$friends[@]"' or something like that.
local d s dirs list lines revlines i
@ -20,21 +15,20 @@ else
fi
if [[ -prefix [-+] ]]; then
lines=(${(f)"$(dirs -v)"})
lines=("$PWD" "$dirstack[@]")
integer i
if [[ ( -prefix - && ! -o pushdminus ) ||
( -prefix + && -o pushdminus ) ]]; then
revlines=( $lines )
for (( i = 1; i <= $#lines; i++ )); do
lines[$i]="$((i-1)) -- ${revlines[-$i]##[0-9]#[ ]#}"
lines[$i]="$((i-1)) -- ${revlines[-$i]}"
done
else
for (( i = 1; i <= $#lines; i++ )); do
lines[$i]="$((i-1)) -- ${lines[$i]##[0-9]#[ ]#}"
lines[$i]="$((i-1)) -- ${lines[$i]}"
done
fi
list=(${lines%% *})
compset -P '[-+]'
_description d 'directory stack'
compadd "$d[@]" -V dirs -S/ -ld lines -Q - "$list[@]"
@ -45,6 +39,5 @@ else
else
_description d 'named directory'
fi
compgen "$d[@]" -n "$s[@]"
compadd "$d[@]" "$s[@]" - "${(@k)nameddirs}"
fi

View file

@ -1,7 +1,5 @@
#autoload
setopt localoptions extendedglob
if compvalues -i "$@"; then
local noargs args opts descr action expl sep

View file

@ -2,5 +2,7 @@
local expl
_description expl alias
compgen "$expl[@]" -a
_description expl 'regular alias'
compadd "$expl[@]" - "${(@k)raliases[(R)^?disabled*]}"
_description expl 'global alias'
compadd "$expl[@]" - "${(@k)galiases[(R)^?disabled*]}"

View file

@ -3,4 +3,4 @@
local expl
_description expl array
compgen "$expl[@]" -A
compadd "$expl[@]" - "${(@k)parameters[(R)*array*]}"

View file

@ -1,6 +1,3 @@
#compdef bg
local expl
_description expl 'suspended job'
compgen "$expl[@]" -z -P '%'
_job -s -P '%'

View file

@ -3,7 +3,7 @@
# Normally, this completes names of zle widgets, whether the builtin ones
# or ones defined by the user. Note that a - allows a wildcard before it,
# so h-b-s-b will complete to history-beginning-search-backward. You
# can alter this by removing the -M ... from the second compgen.
# can alter this by removing the -M ... from the second compadd.
#
# Where appropriate, will complete keymaps instead of widgets.
@ -11,8 +11,8 @@ local expl
if [[ "$words[2]" = -*[DAN]* || "$words[CURRENT-1]" = -*M ]]; then
_description expl keymap
compadd "$expl[@]" - $(bindkey -l)
compadd "$expl[@]" - "$zlekeymaps[@]"
else
_description expl widget
compgen "$expl[@]" -b -M 'r:|-=* r:|=*'
compadd "$expl[@]" -M 'r:|-=* r:|=*' - "${(@k)zlewidgets}"
fi

View file

@ -8,5 +8,5 @@ else
local expl
_description expl 'builtin command'
compgen "$expl[@]" -eB
compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}"
fi

View file

@ -11,8 +11,7 @@
# it's not a lot of use. If you don't type the + or - it will
# complete directories as normal.
emulate -L zsh
setopt extendedglob nonomatch
setopt localoptions nonomatch
local expl

View file

@ -6,6 +6,6 @@ if [[ CURRENT -ge 3 ]]; then
else
local expl
_description expl command
compgen "$expl[@]" -em
_description expl 'external command'
compadd "$expl[@]" "$@" - "${(k@)commands}"
fi

View file

@ -1,6 +1,6 @@
#compdef compdef
local func base=2
local expl func base=2
while [[ $words[base] = -* ]]; do
case $words[base] in
@ -12,11 +12,13 @@ while [[ $words[base] = -* ]]; do
done
if [ "$delete" ]; then
compadd ${(k)_comps}
_description expl 'completed command'
compadd "$expl[@]" - ${(k)_comps}
else
if [[ CURRENT -eq base ]]; then
for func in ${^~fpath:/.}/_(|*[^~])(N:t); compadd -P_ - ${func#_}
if [[ CURRENT -eq base ]]; then
_description expl 'completion function'
compadd "$expl[@]" - ${^fpath:/.}/_(|*[^~])(N:t)
else
compgen -c
_command_names
fi
fi

View file

@ -4,19 +4,19 @@ local prev="$words[CURRENT-1]" ret=1 expl
if [[ "$prev" = -*a* ]]; then
_description expl alias
compgen "$expl[@]" -ea && ret=0
compadd "$expl[@]" "$@" - "${(k@)aliases[(R)^?disabled*]}" && ret=0
fi
if [[ "$prev" = -*f* ]]; then
_description expl 'shell function'
compgen "$expl[@]" -eF && ret=0
compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0
fi
if [[ "$prev" = -*r* ]]; then
_description expl 'reserved word'
compgen "$expl[@]" -ew && ret=0
compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0
fi
if [[ "$prev" != -* ]]; then
_description expl 'builtin command'
compgen "$expl[@]" -eB && ret=0
compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0
fi
return ret

View file

@ -4,19 +4,19 @@ local prev="$words[CURRENT-1]" ret=1 expl
if [[ "$prev" = -*a* ]]; then
_description expl alias
compgen "$expl[@]" -da && ret=0
compadd "$expl[@]" "$@" - "${(k@)aliases[(R)?disabled*]}" && ret=0
fi
if [[ "$prev" = -*f* ]]; then
_description expl 'shell function'
compgen "$expl[@]" -dF && ret=0
compadd "$expl[@]" "$@" - "${(k@)functions[(R)?disabled*]}" && ret=0
fi
if [[ "$prev" = -*r* ]]; then
_description expl 'reserved word'
compgen "$expl[@]" -dw && ret=0
compadd "$expl[@]" "$@" - "${(k@)reswords[(R)?disabled*]}" && ret=0
fi
if [[ "$prev" != -* ]]; then
_description expl 'builtin command'
compgen "$expl[@]" -dB && ret=0
compadd "$expl[@]" "$@" - "${(k@)builtins[(R)?disabled*]}" && ret=0
fi
return ret

View file

@ -1,10 +1,9 @@
#compdef fc
local prev="$words[CURRENT-1]" expl
local prev="$words[CURRENT-1]"
if [[ "$prev" = -*e ]]; then
_description expl command
compgen "$expl[@]" -c
_command_names -e
elif [[ "$prev" = -[ARWI]## ]]; then
_files
fi

View file

@ -3,4 +3,4 @@
local expl
_description expl 'shell function'
compgen "$expl[@]" -F
compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}"

View file

@ -7,11 +7,11 @@ if [[ "$words[2]" = -*d* ]]; then
_path_files -g '*(-/)'
else
_description expl 'named directory'
compgen "$expl[@]" -n -q -S '='
compadd "$expl[@]" -q -S '=' - "${(@k)nameddirs}"
fi
elif compset -P 1 '*\='; then
_files -/g '*(*)'
else
_description expl command
compgen "$expl[@]" -m -q -S '='
compadd "$expl[@]" -q -S '=' - "${(@k)commands}"
fi

View file

@ -1,6 +1,3 @@
#compdef disown fg jobs
local expl
_description expl job
compgen "$expl[@]" -j -P '%'
_job -P '%'

View file

@ -8,9 +8,9 @@ if compset -P 1 -; then
else
local ret=1
_description expl job
compgen "$expl[@]" -P '%' -j && ret=0
list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}")
_job && ret=0
list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}")
_description expl 'process ID'
compadd "$expl[@]" -ld list - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} &&
ret=0

View file

@ -5,6 +5,45 @@
# way round if pushdminus is set). Note that this function is also called
# from _cd for cd and pushd.
setopt localoptions nonomatch
[[ $PREFIX = [-+]* ]] || return 1
local expl list lines revlines ret=1 i
IPREFIX=$PREFIX[1]
PREFIX=$PREFIX[2,-1]
# get the list of directories with their canonical number
# and turn the lines into an array, removing the current directory
lines=( "$dirstack[@]" )
if [[ ( $IPREFIX = - && ! -o pushdminus ) ||
( $IPREFIX = + && -o pushdminus ) ]]; then
integer i
revlines=( $lines )
for (( i = 1; i <= $#lines; i++ )); do
lines[$i]="$((i-1)) -- ${revlines[-$i]}"
done
else
for (( i = 1; i <= $#lines; i++ )); do
lines[$i]="$i -- ${lines[$i]}"
done
fi
# get the array of numbers only
list=(${lines%% *})
_description expl 'directory stack index'
compadd "$expl[@]" -ld lines -V dirs -Q - "$list[@]" && ret=0
[[ -z $compstate[list] ]] && compstate[list]=list && ret=0
[[ -n $compstate[insert] ]] && compstate[insert]=menu && ret=0
return ret
#compdef popd
# This just completes the numbers after +, showing the full directory list
# with numbers. For - we do the same thing, but reverse the numbering (other
# way round if pushdminus is set). Note that this function is also called
# from _cd for cd and pushd.
emulate -L zsh
setopt extendedglob nonomatch

View file

@ -1,11 +1,9 @@
#compdef set
local prev="$words[CURRENT-1]" expl
local prev="$words[CURRENT-1]"
if [[ "$prev" = [-+]o ]]; then
_description expl 'zsh option'
compgen "$expl[@]" -o
_options
elif [[ "$prev" = -A ]]; then
_description expl array
compgen "$expl[@]" -A
_arrays
fi

View file

@ -3,8 +3,7 @@
local expl
if [[ "$words[CURRENT-1]" = -[AH] ]]; then
_description expl array
compgen "$expl[@]" -A
_arrays
else
_description expl 'inode element'
[[ "$PREFIX[1]" = + ]] &&

View file

@ -3,9 +3,9 @@
local expl
if [[ CURRENT -eq 2 ]]; then
_description expl command
compgen "$expl[@]" -c
compset -q
_normal
else
_description expl signal
compgen "$expl[@]" -k signals
compadd "$expl[@]" - "$signals[@]"
fi

View file

@ -4,19 +4,18 @@ local fl="$words[2]" ret=1 expl
if [[ "$fl" = -*d* ]]; then
_description expl 'named directory'
compgen "$expl[@]" -n && ret=0
compadd "$expl[@]" - "${(@k)nameddirs}" && ret=0
fi
if [[ "$fl" = -*a* ]]; then
_description expl alias
compgen "$expl[@]" -a && ret=0
compadd "$expl[@]" - "${(@k)aliases}" && ret=0
fi
if [[ "$fl" = -*f* ]]; then
_description expl 'shell function'
compgen "$expl[@]" -F && ret=0
compadd "$expl[@]" - "${(@k)functions}" && ret=0
fi
if [[ "$fl" != -* ]]; then
_description expl command
compgen "$expl[@]" -m && ret=0
_command_names -e && ret=0
fi
return ret

View file

@ -1,21 +1,10 @@
#compdef wait
# This uses two configuration keys:
#
# ps_args
# This can be set to options of the ps(1) command that should be
# used when invoking it to get the pids to complete.
#
# ps_listargs
# This defaults to the value of the `ps_args' key and defines
# options for the ps command that are to be used when creating
# the list to display during completion.
local list ret=1 expl
_description expl job
compgen "$expl[@]" -P '%' -j && ret=0
list=("${(@Mr:COLUMNS-1:)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}")
_job -P '%' && ret=0
list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}")
_description expl 'process ID'
compadd "$expl[@]" -ld list - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && ret=0

View file

@ -2,9 +2,13 @@
local expl
_description expl command
compgen "$expl[@]" -c
_description expl alias
compgen "$expl[@]" -a
_description expl 'external command'
compadd "$expl[@]" "$@" - "${(k@)commands}" && ret=0
_description expl 'builtin command'
compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0
_description expl 'shell function'
compgen "$expl[@]" -F
compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0
_description expl 'alias'
compadd "$expl[@]" "$@" - "${(k@)raliases[(R)^?disabled*]}" && ret=0
_description expl 'reserved word'
compadd "$expl[@]" "$@" - "${(k@)reswords[(R)^?disabled*]}" && ret=0

View file

@ -4,8 +4,8 @@ local expl
if [[ "$words[2]" = -N && CURRENT -eq 3 ]]; then
_description expl 'widget shell function'
compgen "$expl[@]" -F
compadd "$expl[@]" "$@" - "${(k@)functions[(R)^?disabled*]}" && ret=0
else
_description expl widget
compgen "$expl[@]" -b
compadd "$expl[@]" - "${(@k)zlewidgets}"
fi

View file

@ -4,10 +4,10 @@ local fl="$words[2]" expl
if [[ "$fl" = -*(a*u|u*a)* || "$fl" = -*a* && CURRENT -ge 4 ]]; then
_description expl 'builtin command'
compgen "$expl[@]" -B
compadd "$expl[@]" "$@" - "${(k@)builtins[(R)^?disabled*]}" && ret=0
elif [[ "$fl" = -*u* ]]; then
_description expl module
compadd "$expl[@]" - $(zmodload)
compadd "$expl[@]" - "${(@k)modules}"
else
_description expl 'module file'
compadd "$expl[@]" - ${^module_path}/*.s[ol](N:t:r)

View file

@ -30,7 +30,7 @@ local key=$KEYS[-1]
case $key in
'!') _main_complete _command_names
;;
'$') compgen -E
'$') compadd - "${(@k)parameters[(R)*export*]}"
;;
'@') _main_complete _hosts
;;

View file

@ -1,31 +1,108 @@
#compdef -k complete-word \e/
#compdef -K _history-complete-older complete-word \e/ _history-complete-newer complete-word \e,
#
# Complete words from the history
#
# by Adam Spiers, with help gratefully received from
# Sven Wischnowsky and Bart Schaefer
#
# Available configuration keys:
#
# history_list -- display lists of available matches
# history_stop -- prevent looping at beginning and end of matches
# during menu-completion
# history_sort -- sort matches lexically (default is to sort by age)
# history_remove_all_dups --
# remove /all/ duplicate matches rather than just
# consecutives
#
local expl
_history_complete_word () {
local expl direction
if [[ -n "$compstate[old_list]" && -n "$compconfig[history_stop]" ]]; then
if [[ -z "$_hist_menu_end" &&
compstate[old_insert] -lt _hist_menu_length ]]; then
compstate[old_list]=keep
compstate[insert]=$((compstate[old_insert]+1))
if [[ $WIDGET = *newer ]]; then
direction=older
else
_hist_menu_end=yes
if [[ "$compconfig[history_stop]" = verbose ]]; then
_message 'end of history reached'
direction=newer
fi
[[ -z "$compconfig[history_list]" ]] && compstate[list]=''
if [[ -n "$compstate[old_list]" &&
( -n "$compconfig[history_stop]" || "$compstate[insert]" = menu ) ]]; then
# array of matches is newest -> oldest (reverse of history order)
if [[ "$direction" == 'older' ]]; then
if [[ compstate[old_insert] -eq $_hist_menu_length ||
"$_hist_stop" == 'oldest' ]]; then
_hist_stop='oldest'
[[ "$compconfig[history_stop]" = verbose ]] &&
_message 'beginning of history reached'
elif [[ "$_hist_stop" == 'newest' ]]; then
zle -Rc
_history_complete_word_gen_matches
else
compstate[old_list]=keep
(( compstate[insert] = compstate[old_insert] + 1 ))
fi
elif [[ "$direction" == 'newer' ]]; then
if [[ compstate[old_insert] -eq 1 || "$_hist_stop" == 'newest' ]]; then
_hist_stop='newest'
[[ "$compconfig[history_stop]" = verbose ]] &&
_message 'end of history reached'
elif [[ "$_hist_stop" == 'oldest' ]]; then
zle -Rc
_history_complete_word_gen_matches
else
compstate[old_list]=keep
(( compstate[insert] = compstate[old_insert] - 1 ))
fi
fi
else
_hist_stop=''
_hist_old_prefix="$PREFIX"
_history_complete_word_gen_matches
fi
[[ -n "$compstate[nmatches]" ]]
}
_history_complete_word_gen_matches () {
if [[ -n "$compconfig[history_list]" ]]; then
if [[ -n "$compconfig[history_sort]" ]]; then
_description expl 'history word'
else
compstate[old_list]=keep
compstate[insert]=_hist_menu_length
_description -V expl 'history word'
fi
else
if [[ -n "$compconfig[history_sort]" ]]; then
expl=()
else
expl=('-V' '')
fi
fi
else
if [[ -n "$compconfig[history_sort]" ]]; then
_description expl 'history word'
[[ -n "$_hist_stop" ]] && PREFIX="$_hist_old_prefix"
local rem_dups
if [[ -n "$compconfig[history_remove_all_dups]" ]]; then
rem_dups=''
else
_description -V expl 'history word'
rem_dups='-1'
fi
compgen "$expl[@]" -Q -H 0 ''
if [[ -n "$compconfig[history_stop]" ]]; then
compstate[insert]=1
_hist_menu_length="$compstate[nmatches]"
_hist_menu_end=''
fi
fi
compadd "$expl[@]" $rem_dups -Q - "${(@)historywords:#[\$'\"]*}"
_hist_menu_length="$compstate[nmatches]"
case "$direction" in
newer) compstate[insert]=$_hist_menu_length
[[ -n "$_hist_stop" ]] && (( compstate[insert]-- ))
;;
older) compstate[insert]=1
[[ -n "$_hist_stop" ]] && (( compstate[insert]++ ))
;;
esac
[[ -n "$_hist_stop" ]] && _hist_stop=''
}
_history_complete_word "$@"

View file

@ -6,9 +6,9 @@
# evaluate to generate the completions; unambiguous strings in the function
# name are automatically completed.
#
# Else it is taken to be a set of arguments for compgen to generate a list
# Else it is taken to be a set of arguments for compadd to generate a list
# of choices. The possibilities are the same as the flags for generating
# completions given in the zshcompctl manual page. Note the arguments are
# completions given in the zshcompwid manual page. Note the arguments are
# verbatim: include minus signs, spaces, quotes, etc.
#
# On subsequent calls, the same completion will be re-performed. To
@ -37,7 +37,7 @@ if [[ compstate[matcher] -gt 1 ||
if [[ $_read_comp = _* ]]; then
eval $_read_comp
else
eval "compgen $_read_comp"
eval "compadd $_read_comp"
fi
return
fi
@ -154,5 +154,5 @@ zle -cR ''
if [[ $str = _* ]]; then
eval $str
else
eval "compgen $str"
eval "compadd $str"
fi

View file

@ -70,22 +70,6 @@ compadd() {
fi
}
compgen() {
[[ "$*" != *-([a-zA-Z/]#|)U* &&
"${#:-$PREFIX$SUFFIX}" -le _comp_correct ]] && return
if [[ "$PREFIX" = \~*/* ]]; then
PREFIX="${PREFIX%%/*}/(#a${_comp_correct})${PREFIX#*/}"
else
PREFIX="(#a${_comp_correct})$PREFIX"
fi
if [[ -n "$_correct_prompt" ]]; then
builtin compgen "$@" -X "$_correct_prompt" -J _correct
else
builtin compgen "$@" -J _correct
fi
}
# Now initialise our counter. We also set `compstate[matcher]'
# to `-1'. This allows completion functions to use the simple
# `[[ compstate[matcher] -gt 1 ]] && return' to avoid being
@ -99,11 +83,6 @@ compstate[matcher]=-1
_correct_prompt="${cfgps//\\%e/1}"
# We also need to set `extendedglob' and make the completion
# code behave as if globcomplete were set.
setopt extendedglob
[[ -z "$compstate[pattern_match]" ]] && compstate[pattern_match]='*'
while [[ _comp_correct -le comax ]]; do
@ -135,7 +114,7 @@ while [[ _comp_correct -le comax ]]; do
compstate[force_list]=list
fi
compstate[matcher]="$compstate[total_matchers]"
unfunction compadd compgen
unfunction compadd
return 0
fi
@ -147,6 +126,6 @@ while [[ _comp_correct -le comax ]]; do
done
compstate[matcher]="$compstate[total_matchers]"
unfunction compadd compgen
unfunction compadd
return 1

View file

@ -9,13 +9,8 @@
#
# local _set_options _unset_options
#
# if zmodload -e parameter; then
# _set_options=(${(k)options[(R)on]})
# _unset_options=(${(k)options[(R)off]})
# else
# _set_options=("${(@f)$({ unsetopt kshoptionprint; setopt } 2>/dev/null)}")
# _unset_options=("${(@f)$({ unsetopt kshoptionprint; unsetopt } 2>/dev/null)}")
# fi
# _set_options=(${(k)options[(R)on]})
# _unset_options=(${(k)options[(R)off]})
#
# This is needed because completion functions may set options locally
# which makes the output of setopt and unsetopt reflect a different
@ -26,7 +21,7 @@ local comp post ret=1 _compskip
typeset -U _lastdescr
setopt localoptions nullglob rcexpandparam
setopt localoptions nullglob rcexpandparam extendedglob
unsetopt markdirs globsubst shwordsplit nounset ksharrays
# Special completion contexts after `~' and `='.

View file

@ -27,11 +27,7 @@ elif [[ "$command" == */* ]]; then
cmd2="${command:t}"
else
cmd1="$command"
if zmodload -e parameter; then
cmd2="$commands[$command]"
else
cmd2=$(whence -p - $command)
fi
cmd2="$commands[$command]"
fi
# See if there are any matching pattern completions.

View file

@ -5,4 +5,5 @@
local expl
_description expl 'zsh option'
compgen "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' -o
compadd "$expl[@]" "$@" -M 'L:|[nN][oO]= M:_= M:{A-Z}={a-z}' - \
"${(@k)options}"

View file

@ -3,17 +3,11 @@
# This should be used to complete parameter names if you need some of the
# extra options of compadd. It completes only non-local parameters.
setopt localoptions extendedglob
local pars expl
_description expl parameter
if zmodload -e parameter; then
pars=( ${(k)parameters[(R)^*local*]} )
else
pars=( ${${${(f)"$(typeset +)"}:#*local *}##* } )
fi
pars=( ${(k)parameters[(R)^*local*]} )
compadd "$expl[@]" "$@" - $pars

View file

@ -10,7 +10,7 @@ local nm=$compstate[nmatches] menu match matcher
typeset -U prepaths exppaths
setopt localoptions nullglob rcexpandparam extendedglob
setopt localoptions nullglob rcexpandparam
unsetopt markdirs globsubst shwordsplit nounset
local sopt='-' gopt='' opt
@ -110,36 +110,6 @@ orig="${PREFIX}${SUFFIX}"
( $#compstate[pattern_match] -ne 0 &&
"${orig#\~}" != "${${orig#\~}:q}" ) ]] && menu=yes
# We will first try normal completion called with `compgen', but only if we
# weren't given a `-F', `-r', or `-R' option or we are in the string.
if [[ -z "$suf" && $#ignore -eq 0 && $#remsfx -eq 0 &&
-z "$_comp_correct" ]]; then
# First build an array containing the `-W' option, if there is any and we
# want to use it. We don't want to use it if the string from the command line
# is a absolute path or relative to the current directory.
if [[ -z "$prepaths[1]" || "$pre[1]" = [~/] || "$pre" = (.|..)/* ]]; then
tmp1=()
else
tmp1=(-W "( $prepaths )")
fi
# Now call compgen.
if [[ -z "$gopt" ]]; then
compgen "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \
"$tmp1[@]" "$matcher[@]" $sopt
else
compgen "$addpfx[@]" "$addsfx[@]" "$group[@]" "$expl[@]" \
"$tmp1[@]" "$matcher[@]" $sopt -g "$pats"
fi
# If this generated any matches, we don't want to do in-path completion.
[[ compstate[nmatches] -eq nm ]] || return 0
fi
# If given no `-F' option, we want to use `fignore'.
(( $#ignore )) || ignore=(-F fignore)

View file

@ -78,6 +78,10 @@ while [[ $# -gt 0 && $1 = -[dDf] ]]; do
fi
done
# We need the parameter modules.
zmodload -i parameter zleparameter
# The associative array containing the definitions for the commands.
# Definitions for patterns will be stored in the normal arrays `_patcomps'
# and `_postpatcomps'.

View file

@ -473,7 +473,7 @@ _apt-config () {
-- \
/$'shell\0'/ \
\( \
/$'[^\0]#\0'/ :'compgen "$expl_shell_var[@]" -v' \
/$'[^\0]#\0'/ :'compadd "$expl_shell_var[@]" - "${(@k)parameters}' \
/$'[^\0]#\0'/ :'compadd "$expl_config_key[@]" - ${${(f)"$(apt-config dump 2>&1)"}% *}' \
\) \# \| \
/$'dump\0'/ \| \

View file

@ -514,7 +514,7 @@ builtin functions _cvs_directories >&- ||
_cvs_directories () {
if [[ -d ${pref}CVS ]]; then
_cvs_setup_direntries
(( $#entries )) && compgen "$@" -g "${(j:|:)${(@)entries:q}}"
(( $#entries )) && _files "$@" -g "${(j:|:)${(@)entries:q}}"
else
_files "$@"
fi
@ -526,7 +526,7 @@ _cvs_files () {
_cvs_setup_prefix
if [[ -d ${pref}CVS ]]; then
_cvs_setup_allentries
(( $#entries )) && compgen "$@" -g "${(j:|:)${(@)entries:q}}"
(( $#entries )) && _files "$@" -g "${(j:|:)${(@)entries:q}}"
else
_files "$@"
fi
@ -538,7 +538,7 @@ _cvs_files_modified () {
_cvs_setup_prefix
if [[ -d ${pref}CVS ]]; then
_cvs_setup_modentries
(( $#entries )) && compgen "$@" -g "${(j:|:)${(@)entries:q}}"
(( $#entries )) && _files "$@" -g "${(j:|:)${(@)entries:q}}"
else
_files "$@"
fi
@ -572,8 +572,8 @@ _cvs_files_unmaintained () {
omit=($_cvs_ignore_default ${entries:q} ${=cvsignore})
[[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore))
[[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore))
compgen "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
compgen "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
_files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
_files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
_cvs_directories "$@"
else
_files "$@"

View file

@ -47,8 +47,7 @@ else
if [[ $#w -gt 1 ]]; then
_files && ret=0
_description expl 'process ID'
list=("${(F)${(@Mr:COLUMNS-1:)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${w[1]:t}}}
")
list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${w[1]:t}*}")
compadd "$expl[@]" -ld list - ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0
return ret

View file

@ -1,6 +1,6 @@
#compdef man apropos whatis
setopt localoptions rcexpandparam extendedglob
setopt localoptions rcexpandparam
local rep expl star approx

View file

@ -39,8 +39,7 @@ elif compset -P 1 '[+@]' || [[ "$prev" = -draftfolder ]]; then
_description expl 'MH folder'
_path_files "$expl[@]" -W mhpath -/
elif [[ "$prev" = -(editor|(whatnow|rmm|show|more)proc) ]]; then
_description expl command
compgen "$expl[@]" -c
_command_names -e
elif [[ "$prev" = -file ]]; then
_files
elif [[ "$prev" = -(form|audit|filter) ]]; then
@ -52,7 +51,7 @@ elif [[ "$prev" = -(form|audit|filter) ]]; then
mhfpath=($mymhdir $mhlib)
_description expl 'MH template file'
compgen "$expl[@]" -W mhfpath -g '*(.)'
_files "$expl[@]" -W mhfpath -g '*(.)'
elif [[ "$prev" = -(no|)cc ]]; then
_description expl 'CC address'
compadd "$expl[@]" all to cc me
@ -79,7 +78,7 @@ else
compadd "$expl[@]" $(mark $foldnam 2>/dev/null | awk -F: '{ print $1 }') &&
ret=0
compadd "$expl[@]" reply next cur prev first last all unseen && ret=0
compgen "$expl[@]" -W folddir -g '<->' && ret=0
_files "$expl[@]" -W folddir -g '<->' && ret=0
return ret
fi

View file

@ -19,8 +19,6 @@
# other characters than lower case letters, we try to call the function
# `_nslookup_host'.
setopt localoptions extendedglob
local state expl ret=1 setopts
setopts=(

View file

@ -13,9 +13,6 @@
# tar itself (GNU tar)
# - Things like --directory=... are also completed correctly.
emulate -LR zsh
setopt extendedglob
local _tar_cmd tf tmp del
# First we collect in `_tar_cmd' single letter options describing what

View file

@ -37,8 +37,6 @@
# name used by a user placing web pages within their home area.
# e.g. compconf urls_localhttp=www:/usr/local/apache/htdocs:public_html
setopt localoptions extendedglob
local ipre scheme host user hosts ret=1 expl
local urls_path="${compconfig[urls_path]:-${ZDOTDIR:-$HOME}/.zsh/urls}"
local localhttp_servername="${${(@s.:.)compconfig[urls_localhttp]}[1]}"

View file

@ -10,4 +10,4 @@ _description expl user
[[ "${(t)users}" = *array* ]] &&
compadd "$expl[@]" "$@" - "$users[@]" && return 0
compgen "$@" "$expl[@]" -u
compadd "$@" "$expl[@]" - "${(@k)userdirs}"

View file

@ -1,6 +1,3 @@
#compdef whereis
local expl
_description expl command
compgen "$expl[@]" -m
_command_names -e

View file

@ -1,7 +1,6 @@
#compdef whois
_whois () {
setopt localoptions extendedglob
_whois_setup
$_whois_comp
}

View file

@ -11,4 +11,4 @@ if (( ! $+_font_cache )); then
fi
_description expl font
compgen -M 'r:|-=* r:|=*' "$expl[@]" "$@" -S '' -k _font_cache
compadd -M 'r:|-=* r:|=*' "$expl[@]" "$@" -S '' - "$_font_cache[@]"

View file

@ -1,7 +1,5 @@
#autoload
setopt localoptions extendedglob
local list expl
list=( "${(@)${(M@)${(@f)$(xwininfo -root -tree)}:#[ ]#0x[0-9a-f]# \"*}##[ ]#}" )

View file

@ -1,7 +1,5 @@
#compdef xmodmap
setopt localoptions extendedglob
local state line ret=1
typeset -A opt_args

View file

@ -57,11 +57,11 @@ Zsh/exec.yo Zsh/expn.yo \
Zsh/filelist.yo Zsh/files.yo Zsh/func.yo Zsh/grammar.yo Zsh/manual.yo \
Zsh/index.yo Zsh/intro.yo Zsh/invoke.yo Zsh/jobs.yo Zsh/metafaq.yo \
Zsh/modules.yo Zsh/mod_cap.yo \
Zsh/mod_clone.yo Zsh/mod_comp1.yo Zsh/mod_compctl.yo Zsh/mod_complist.yo \
Zsh/mod_clone.yo Zsh/mod_complete.yo Zsh/mod_compctl.yo Zsh/mod_complist.yo \
Zsh/mod_deltochar.yo Zsh/mod_example.yo Zsh/mod_files.yo \
Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_parameter.yo Zsh/mod_sched.yo \
Zsh/mod_stat.yo Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/options.yo \
Zsh/params.yo Zsh/prompt.yo Zsh/redirect.yo Zsh/restricted.yo \
Zsh/mod_stat.yo Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \
Zsh/options.yo Zsh/params.yo Zsh/prompt.yo Zsh/redirect.yo Zsh/restricted.yo \
Zsh/seealso.yo Zsh/zftpsys.yo Zsh/zle.yo
# ========== DEPENDENCIES FOR BUILDING ==========

View file

@ -141,7 +141,7 @@ startlist()
list([ tt(-fcFBdeaRGovNAIOPZEnbjrzu/12) ])
list([ tt(-k) var(array) ] [ tt(-g) var(globstring) ] \
[ tt(-s) var(subststring) ])
list([ tt(-K) var(function) ] [ tt(-i) var(function) ])
list([ tt(-K) var(function) ])
list([ tt(-Q) ] [ tt(-P) var(prefix) ] [ tt(-S) var(suffix) ])
list([ tt(-W) var(file-prefix) ] [ tt(-H) var(num pattern) ])
list([ tt(-q) ] [ tt(-X) var(explanation) ] [ tt(-Y) var(explanation) ])
@ -314,13 +314,6 @@ compctl -K whoson talk)
completes only logged-on users after `tt(talk)'. Note that `tt(whoson)' must
return an array, so `tt(reply=`users`)' would be incorrect.
)
item(tt(-i) var(function))(
Like tt(-K), but the function is invoked in a context like that for
completion widgets, see
ifzman(zmanref(zshzle))\
ifnzman(noderef(The zle Module))
for more information.
)
item(tt(-H) var(num pattern))(
The possible completions are taken from the last var(num) history
lines. Only words matching var(pattern) are taken. If var(num) is

View file

@ -13,7 +13,7 @@ completion behaviour and which may be bound to keystrokes, are referred to
as `widgets'.
Note that with the function-based completions described here, it
is also possible to use the `tt(compctl -M ...)' mechanism and the
is also possible to use the
tt(compmatchers) special array to specify
global matching control, such as case-insensitivity (`tt(abc)' will complete
to a string beginning `tt(ABC)'), or wildcard behaviour on
@ -21,10 +21,11 @@ certain anchors (`tt(a-d)' will complete to abc-def as if there were a
`tt(*)' after the `a'). See
ifzman(the section `Matching Control' in zmanref(zshcompctl))\
ifnzman(noderef(Matching Control))
for further details. Note that it is recommended to use the the
tt(compmatchers) array instead of tt(compctl) to define global
matchers when using the function based completion system, although
using tt(compctl -M) still works.
for further details.
Also note that this completion system requires the tt(parameter) and
tt(zleparameter) modules to be linked into the shell or to be
dynamically loadable.
startmenu()
menu(Initialization)
@ -595,7 +596,7 @@ item(tt(_description))(
This function gets two arguments: the name of an array and a
string. It tests if the configuration key tt(description_format) is
set and if it is, it stores some options in the array that can then be
given to the tt(compadd) and tt(compgen) builtin commands to make the
given to the tt(compadd) builtin command to make the
value of the tt(description_format) key (with the sequence `tt(%d)'
replaced by the string given as the second argument) be displayed
above the matches added. These options also will make sure that the
@ -704,7 +705,7 @@ completion functions is that it allows completion of partial paths. For
example, the string `tt(/u/i/s/sig)' may be completed to
`tt(/usr/include/sys/signal.h)'. The options `tt(-/)', `tt(-f)', `tt(-g)',
and `tt(-W)' are available as for the tt(compctl)
and tt(compgen) builtins; tt(-f) is the default. Additionally, the `tt(-F)'
and builtin command; tt(-f) is the default. Additionally, the `tt(-F)'
option from the tt(compadd) builtin is supported, giving direct control
over which filenames should be ignored as done by the tt(fignore)
parameter in normal completion.
@ -744,12 +745,11 @@ extra options of tt(compadd). All arguments are passed unchanged to
the tt(compadd) builtin.
)
item(tt(_options))(
This can be used to complete option names. The difference to the
`tt(-o)' option of tt(compgen) is that this function uses a matching
This can be used to complete option names. It uses a matching
specification that ignores a leading `tt(no)', ignores underscores and
allows the user to type upper-case letters, making them match their
lower-case counterparts. All arguments passed to this function are
propagated unchanged to the tt(compgen) builtin.
propagated unchanged to the tt(compadd) builtin.
)
item(tt(_set_options) and tt(_unset_options))(
These functions complete only set or unset options, with the same
@ -897,8 +897,8 @@ var(action) does not begin with an opening parentheses or brace, it
will be split into separate words and executed. If the var(action)
starts with a space, this list of words will be invoked unchanged,
otherwise it will be invoked with some extra string placed after the
first word which can be given as arguments to the tt(compadd) and
tt(compgen) builtins and which make sure that the var(message) given
first word which can be given as arguments to the tt(compadd) builtin
command and which make sure that the var(message) given
in the description will be shown above the matches. These arguments
are taken from the array parameter tt(expl) which will be set up
before executing the var(action) and hence may be used in it (normally
@ -1273,9 +1273,9 @@ completions. Unambiguous parts of the function name will be completed
automatically (normal completion is not available at this point) until a
space is typed.
Otherwise, any other string, for example `tt(-b)', will be passed as
arguments to tt(compgen) and should hence be a set of flags specifying the
type of completion.
Otherwise, any other string, will be passed as
arguments to tt(compadd) and should hence be an expression specifying
what should be completed.
A very restricted set of editing commands is available when reading the
string: `tt(DEL)' and `tt(^H)' delete the last character; `tt(^U)' deletes

View file

@ -199,7 +199,7 @@ item(tt(matcher))(
When completion is performed with a global match specification as defined
by
indent(tt(compctl -M) var(spec1 ... specN ...))
indent(tt(compmatchers=)tt(LPAR()) var(spec1 ... specN ...) tt(RPAR()))
this gives the number of the specification string currently in use.
In this case, matching is performed with each specification in turn.
@ -358,32 +358,6 @@ enditem()
texinode(Builtin Commands)(Condition Codes)(Special Parameters)(Completion Widgets)
sect(Builtin Commands)
startitem()
cindex(completion widgets, generating matches with flags)
findex(compgen)
item(tt(compgen) var(flags ...))(
Generate matches according to the given var(flags). These can be any of
the normal option flags (not those for extended completion) supported by
the tt(compctl) builtin command (see
ifzman(zmanref(zshcompctl))\
ifnzman(noderef(Programmable Completion Using compctl))\
) except for the tt(-t) and tt(-l) flags. However, when using the tt(-K)
flag, the function given as argument to it cannot access the command
line with the tt(read) builtin command.
The matches will be generated in the same way as if the completion code
generated them directly from a tt(compctl)-definition with the same
flags. The completion code will consider only those matches as
possible completions that match the prefix and suffix from the special
parameters described above. These strings will be compared with the
generated matches using the normal matching rules and any matching
specifications given with the tt(-M) flag to tt(compgen) and the
global matching specifications given via the tt(compctl -M )var(spec1 ...)
builtin command.
The return value is zero if at least one match was added and non-zero
otherwise.
)
findex(compadd)
cindex(completion widgets, adding specified matches)
xitem(tt(compadd) [ tt(-qQfenUaml12) ] [ tt(-F) var(array) ])
@ -425,8 +399,7 @@ The supported flags are:
startitem()
item(tt(-P) var(prefix))(
As for tt(compctl) and tt(compgen), it gives a string to
be inserted before the given var(words). The
This gives a string to be inserted before the given var(words). The
string given is not considered as part of the match.
)
item(tt(-S) var(suffix))(
@ -450,12 +423,6 @@ match.
item(tt(-I) var(ignored-suffix))(
Like tt(-i), but gives an ignored suffix.
)
item(tt(-y) var(array))(
This gives a number of strings to display instead of the matches. This
is like the tt(-y) option of the tt(compctl) builtin command but the
var(array) argument may only be the name of an array parameter or a
literal array in parentheses containing the strings to display.
)
item(tt(-d) var(array))(
This adds per-match display strings. The var(array) should contain one
element per var(word) given. The completion code will then display the
@ -474,8 +441,7 @@ options. If it is given, the display strings are listed one per line,
not arrayed in columns.
)
item(tt(-J) var(name))(
As for tt(compctl) and tt(compgen), this gives the name of the group
of matches the words should be stored in.
Gives the name of the group of matches the words should be stored in.
)
item(tt(-V) var(name))(
Like tt(-J) but naming a unsorted group.
@ -491,12 +457,10 @@ duplicates be kept. Again, groups with and without this flag are in
different name spaces.
)
item(tt(-X) var(explanation))(
As for tt(compctl) and tt(compgen), the var(explanation) string will be
printed with the list of matches.
The var(explanation) string will be printed with the list of matches.
)
item(tt(-q))(
As for tt(compctl) and tt(compgen),
the suffix given with tt(-S) will be automatically removed if
The suffix given with tt(-S) will be automatically removed if
the next character typed is a blank or does not insert anything, or if
the suffix consists of only one character and the next character typed
is the same character.
@ -540,17 +504,15 @@ the tt(AUTO_PARAM_SLASH) and tt(AUTO_PARAM_KEYS) options be used for
the matches.
)
item(tt(-W) var(file-prefix))(
This option has the same meaning as for the tt(compctl) and
tt(compgen) builtin commands. Here, however, only one string may be
given, not an array. This string is a pathname that will be
This string is a pathname that will be
prepended to each of the matches formed by the given var(words) together
with any prefix specified by the tt(-p) option to form a complete filename
for testing. Hence it is only useful if combined with the tt(-f) flag, as
the tests will not otherwise be performed.
)
item(tt(-a))(
In the tt(compctl) or tt(compgen) commands, the completion code normally
builds two sets of matches: the normal one where words with one of the
The completion code may
build two sets of matches: the normal one where words with one of the
suffixes in the array parameter tt(fignore) are not considered
possible matches, and the alternate set where the words excluded
from the first set are stored. Normally only the matches in the first
@ -574,12 +536,12 @@ literal suffixes enclosed in parentheses and quoted, as in `tt(-F "(.o
taken as the suffixes.
)
item(tt(-Q))(
As for tt(compctl) and tt(compgen), this flag instructs the completion
This flag instructs the completion
code not to quote any metacharacters in the words when inserting them
into the command line.
)
item(tt(-M) var(match-spec))(
As for tt(compctl) and tt(compgen), this gives local match specifications.
This gives local match specifications.
Note that they will only be used if the tt(-U) option is not given.
)
item(tt(-n))(
@ -593,7 +555,7 @@ functions that do the matching themselves.
Note that with tt(compadd) this option does not automatically turn on
menu completion if tt(AUTO_LIST) is set, unlike the corresponding option of
tt(compctl) and tt(compgen) commands.
tt(compctl).
)
item(tt(-O) var(array))(
If this option is given, the var(words) are em(not) added to the set of
@ -714,7 +676,6 @@ This forces anything up to and including the last equal sign to be
ignored by the completion code.
)
item(tt(compcall) [ tt(-TD) ])(
This allows the use of completions defined with the tt(compctl) builtin
from within completion widgets. The list of matches will be generated as
if one of the non-widget completion function (tt(complete-word), etc.)
@ -727,6 +688,8 @@ tt(-T) and/or tt(-D) flags can be passed to tt(compcall).
The return value can be used to test if a matching tt(compctl)
definition was found. It is non-zero if a tt(compctl) was found and
zero otherwise.
Note that this builtin is defined by the tt(compctl) module.
)
enditem()
@ -773,7 +736,7 @@ After that the shell function tt(complete-history) will be invoked
after typing control-X and TAB. The function should then generate the
matches, e.g.:
example(complete-history LPAR()RPAR() { compgen -H 0 '' })
example(complete-history LPAR()RPAR() { compadd - $historywords })
This function will complete words from the history matching the
current word.

View file

@ -706,6 +706,12 @@ for exported parameters
item(tt(unique))(
for arrays which keep only the first occurrence of duplicated values
)
item(tt(hide))(
for parameters with the `hide' flag
)
item(tt(special))(
for special parameters defined by the shell
)
enditem()
)
enditem()

View file

@ -117,7 +117,7 @@ Zsh Modules
menu(The cap Module)
menu(The clone Module)
menu(The comp1 Module)
menu(The complete Module)
menu(The compctl Module)
menu(The complist Module)
menu(The deltochar Module)
@ -130,6 +130,7 @@ menu(The sched Module)
menu(The stat Module)
menu(The zftp Module)
menu(The zle Module)
menu(The zleparameter Module)
endmenu()
texinode(The Z Shell Manual)(Introduction)(Top)(Top)
chapter(The Z Shell Manual)

View file

@ -1,4 +1,4 @@
texinode(The clone Module)(The comp1 Module)(The cap Module)(Zsh Modules)
texinode(The clone Module)(The complete Module)(The cap Module)(Zsh Modules)
sect(The clone Module)
The tt(clone) module makes available one builtin command:

View file

@ -1,12 +1,12 @@
texinode(The compctl Module)(The complist Module)(The comp1 Module)(Zsh Modules)
texinode(The compctl Module)(The complist Module)(The complete Module)(Zsh Modules)
sect(The compctl Module)
The tt(compctl) module makes available several builtin commands. tt(compctl),
is the standard way to control completions for ZLE. See
The tt(compctl) module makes available two builtin commands. tt(compctl),
is the old, deprecated way to control completions for ZLE. See
ifzman(zmanref(zshcompctl))\
ifnzman(noderef(Programmable Completion Using compctl))\
.
The other builtin commands can be used in user-defined completion widgets,
see
The other builtin command, tt(compcall) can be used in user-defined
completion widgets, see
ifzman(zmanref(zshcompwid))\
ifnzman(noderef(Completion Widgets))\
.

7
Doc/Zsh/mod_complete.yo Normal file
View file

@ -0,0 +1,7 @@
texinode(The complete Module)(The compctl Module)(The clone Module)(Zsh Modules)
sect(The complete Module)
The tt(compctl) module makes available several builtin commands which
can be used in user-defined completion widgets, see
ifzman(zmanref(zshcompwid))\
ifnzman(noderef(Completion Widgets))\
.

View file

@ -12,7 +12,7 @@ completion functions. In short, these builtin commands are:
startitem()
item(tt(compdisplay) var(name) var(string) var(defs) ...)(
The var(defs) are strings should be of the form
The var(defs) are strings which should be of the form
`var(str)tt(:)var(descr)' (the intended use is that the var(descr)
describes the var(str)) and tt(compdisplay) will convert them to
strings in which the colon is replaced by the var(string) given as the

View file

@ -2,7 +2,7 @@ texinode(The parameter Module)(The sched Module)(The mathfunc Module)(Zsh Module
sect(The parameter Module)
cindex(parameters, special)
The tt(parameter) module gives access to some of the internal hash
tables used by the shell, by defining four special associative arrays.
tables used by the shell by defining some special parameters.
startitem()
vindex(options)
@ -32,6 +32,31 @@ key in it is like defining a function with the name given by the key
and the body given by the value. Unsetting a key removes the
definition for the function named by the key.
)
vindex(builtins)
item(tt(builtins))(
This association gives information about the builtin commands
currently known. The keys are the names of the builtin commands and
the values are either `tt(undefined)' for builtin commands that will
automatically be loaded from a module if invoked or `tt(defined)' for
builtin commands that are already loaded. Also, the string
`tt(<disabled> )' will be prepended to the value if the builtin
command is currently disabled.
)
vindex(reswords)
item(tt(reswords))(
This association maps the reserved words to one of `tt(<enabled>)' or
`tt(<disabled>)' for enabled and disabled reserved words, respectively.
)
vindex(raliases)
item(tt(raliases))(
This maps the names of the regular aliases currently defined to their
expansions. For disabled aliases the string `tt(<disabled>)' is
prepended to their value.
)
vindex(galiases)
item(tt(galiases))(
Like tt(raliases), but for global aliases.
)
vindex(parameters)
item(tt(parameters))(
The keys in this associative array are the names of the parameters
@ -61,4 +86,39 @@ A normal array holding the elements of the directory stack. Note that
the output of the tt(dirs) builtin command includes one more
directory, the current working directory.
)
vindex(history)
item(tt(history))(
This association maps history event numbers to the full history lines.
)
vindex(historywords)
item(tt(historywords))(
A special array containing the words stored in the history.
)
vindex(jobtexts)
item(tt(jobtexts))(
This association maps job numbers to the texts of the command lines
that were used to start the jobs.
)
vindex(jobstates)
item(tt(jobstates))(
This association gives information about the states of the jobs
currently known. The keys are the job numbers and the values are
strings of the form
`var(job-state):var(pid)tt(=)var(state)tt(...)'. The var(job-state)
gives the state the whole job is currently in, one of `tt(running)',
`tt(suspended)', or `tt(done)'. This is follwed by one
`var(pid)tt(=)var(state)' for every process in the job. The var(pid)s
are, of course, the process IDs and the var(state) describes the state
of that process.
)
vindex(nameddirs)
item(tt(nameddirs))(
This association maps the names of named directories to the pathnames
they stand for.
)
vindex(userdirs)
item(tt(userdirs))(
This association maps user names to the pathnames of their home
directories.
)
enditem()

View file

@ -1,4 +1,4 @@
texinode(The zle Module)()(The zftp Module)(Zsh Modules)
texinode(The zle Module)(The zleparameter Module)(The zftp Module)(Zsh Modules)
sect(The zle Module)
The tt(zle) module contains the Zsh Line Editor. See
ifzman(zmanref(zshzle))\

View file

@ -0,0 +1,28 @@
texinode(The zleparameter Module)()(The zle Module)(Zsh Modules)
sect(The zleparameter Module)
cindex(parameters, special)
The tt(zleparameter) module defines two special parameters that can be
used to access internal information of the Zsh Line Editor (see
ifzman(zmanref(zshzle))\
ifnzman(noderef(Zsh Line Editor))\
).
startitem()
vindex(zlekeymaps)
item(tt(zlekeymaps))(
This array contains the names of the keymaps currently defined.
)
vindex(zlewidgets)
item(tt(zlewidgets))(
This associative array contains one entry per widget defined. The name
of the widget is the key and the value gives information about the
widget. It is either the string `tt(builtin)' for builtin widgets, a
string of the form `tt(user:)var(name)' for user-defined widgets,
where var(name) is the name of the shell function implementing the
widget, or it is a string of the form
`tt(completion:)var(type)tt(:)var(name)', for completion widgets. In
the last case var(type) is the name of the builtin widgets the
completion widget imitates in its behavior and var(name) is the name
of the shell function implementing the completion widget.
)
enditem()

View file

@ -15,9 +15,6 @@ Builtins for manipulating POSIX.1e (POSIX.6) capability (privilege) sets.
item(tt(clone))(
A builtin that can clone a running shell onto another terminal.
)
item(tt(comp1))(
Base of the completion system. Used by the tt(compctl) and tt(zle) modules.
)
item(tt(compctl))(
The tt(compctl) builtin for controlling completion and the builtins for
completion widgets.
@ -59,11 +56,14 @@ A builtin FTP client.
item(tt(zle))(
The Zsh Line Editor, including the tt(bindkey) and tt(vared) builtins.
)
item(tt(zleparameter))(
Access to internals of the Zsh Line Editor via parameters.
)
enditem()
startmenu()
menu(The cap Module)
menu(The clone Module)
menu(The comp1 Module)
menu(The complete Module)
menu(The compctl Module)
menu(The complist Module)
menu(The computil Module)
@ -77,10 +77,11 @@ menu(The sched Module)
menu(The stat Module)
menu(The zftp Module)
menu(The zle Module)
menu(The zleparameter Module)
endmenu()
includefile(Zsh/mod_cap.yo)
includefile(Zsh/mod_clone.yo)
includefile(Zsh/mod_comp1.yo)
includefile(Zsh/mod_complete.yo)
includefile(Zsh/mod_compctl.yo)
includefile(Zsh/mod_complist.yo)
includefile(Zsh/mod_computil.yo)
@ -94,3 +95,4 @@ includefile(Zsh/mod_sched.yo)
includefile(Zsh/mod_stat.yo)
includefile(Zsh/mod_zftp.yo)
includefile(Zsh/mod_zle.yo)
includefile(Zsh/mod_zleparameter.yo)

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,3 @@
autoparams="parameters commands functions options modules dirstack"
autoparams="parameters commands functions builtins reswords options modules dirstack history historywords jobtexts jobstates nameddirs userdirs raliases galiases"
objects="parameter.o"

View file

@ -1,5 +1,5 @@
/*
* comp.h - header file for completion
* complete.h - header file for completion
*
* This file is part of zsh, the Z shell.
*
@ -27,143 +27,10 @@
*
*/
#undef compctlread
typedef struct compctlp *Compctlp;
typedef struct compctl *Compctl;
typedef struct compcond *Compcond;
typedef struct patcomp *Patcomp;
typedef struct cmatcher *Cmatcher;
typedef struct cmlist *Cmlist;
typedef struct cpattern *Cpattern;
typedef struct menuinfo *Menuinfo;
/* node for compctl hash table (compctltab) */
struct compctlp {
HashNode next; /* next in hash chain */
char *nam; /* command name */
int flags; /* CURRENTLY UNUSED */
Compctl cc; /* pointer to the compctl desc. */
};
/* for the list of pattern compctls */
struct patcomp {
Patcomp next;
char *pat;
Compctl cc;
};
/* compctl -x condition */
struct compcond {
Compcond and, or; /* the next or'ed/and'ed conditions */
int type; /* the type (CCT_*) */
int n; /* the array length */
union { /* these structs hold the data used to */
struct { /* test this condition */
int *a, *b; /* CCT_POS, CCT_NUMWORDS */
}
r;
struct { /* CCT_CURSTR, CCT_CURPAT,... */
int *p;
char **s;
}
s;
struct { /* CCT_RANGESTR,... */
char **a, **b;
}
l;
}
u;
};
#define CCT_UNUSED 0
#define CCT_POS 1
#define CCT_CURSTR 2
#define CCT_CURPAT 3
#define CCT_WORDSTR 4
#define CCT_WORDPAT 5
#define CCT_CURSUF 6
#define CCT_CURPRE 7
#define CCT_CURSUB 8
#define CCT_CURSUBC 9
#define CCT_NUMWORDS 10
#define CCT_RANGESTR 11
#define CCT_RANGEPAT 12
#define CCT_QUOTE 13
/* Contains the real description for compctls */
struct compctl {
int refc; /* reference count */
Compctl next; /* next compctl for -x */
unsigned long mask, mask2; /* masks of things to complete (CC_*) */
char *keyvar; /* for -k (variable) */
char *glob; /* for -g (globbing) */
char *str; /* for -s (expansion) */
char *func; /* for -K (function) */
char *widget; /* for -i (function) */
char *explain; /* for -X (explanation) */
char *ylist; /* for -y (user-defined desc. for listing) */
char *prefix, *suffix; /* for -P and -S (prefix, suffix) */
char *subcmd; /* for -l (command name to use) */
char *substr; /* for -1 (command name to use) */
char *withd; /* for -w (with directory */
char *hpat; /* for -H (history pattern) */
int hnum; /* for -H (number of events to search) */
char *gname; /* for -J and -V (group name) */
Compctl ext; /* for -x (first of the compctls after -x) */
Compcond cond; /* for -x (condition for this compctl) */
Compctl xor; /* for + (next of the xor'ed compctls) */
Cmatcher matcher; /* matcher control (-M) */
char *mstr; /* matcher string */
};
/* objects to complete (mask) */
#define CC_FILES (1<<0)
#define CC_COMMPATH (1<<1)
#define CC_REMOVE (1<<2)
#define CC_OPTIONS (1<<3)
#define CC_VARS (1<<4)
#define CC_BINDINGS (1<<5)
#define CC_ARRAYS (1<<6)
#define CC_INTVARS (1<<7)
#define CC_SHFUNCS (1<<8)
#define CC_PARAMS (1<<9)
#define CC_ENVVARS (1<<10)
#define CC_JOBS (1<<11)
#define CC_RUNNING (1<<12)
#define CC_STOPPED (1<<13)
#define CC_BUILTINS (1<<14)
#define CC_ALREG (1<<15)
#define CC_ALGLOB (1<<16)
#define CC_USERS (1<<17)
#define CC_DISCMDS (1<<18)
#define CC_EXCMDS (1<<19)
#define CC_SCALARS (1<<20)
#define CC_READONLYS (1<<21)
#define CC_SPECIALS (1<<22)
#define CC_DELETE (1<<23)
#define CC_NAMED (1<<24)
#define CC_QUOTEFLAG (1<<25)
#define CC_EXTCMDS (1<<26)
#define CC_RESWDS (1<<27)
#define CC_DIRS (1<<28)
#define CC_EXPANDEXPL (1<<30)
#define CC_RESERVED (1<<31)
/* objects to complete (mask2) */
#define CC_NOSORT (1<<0)
#define CC_XORCONT (1<<1)
#define CC_CCCONT (1<<2)
#define CC_PATCONT (1<<3)
#define CC_DEFCONT (1<<4)
#define CC_UNIQCON (1<<5)
#define CC_UNIQALL (1<<6)
typedef struct cexpl *Cexpl;
typedef struct cmgroup *Cmgroup;
typedef struct cmatch *Cmatch;
@ -191,7 +58,6 @@ struct cmgroup {
int ecount; /* number of explanation string */
Cexpl *expls; /* explanation strings */
int ccount; /* number of compctls used */
Compctl *ccs; /* the compctls used */
LinkList lexpls; /* list of explanation string while building */
LinkList lmatches; /* list of matches */
LinkList lfmatches; /* list of matches without fignore */
@ -272,22 +138,68 @@ struct cmatcher {
int ralen; /* length of right anchor */
};
#define CMF_LINE 1
#define CMF_LEFT 2
#define CMF_RIGHT 4
struct cpattern {
Cpattern next; /* next sub-pattern */
unsigned char tab[256]; /* table of matched characters */
int equiv; /* if this is a {...} class */
};
/* Flags for makecomplist*(). Things not to do. */
/* This is a special return value for parse_cmatcher(), *
* signalling an error. */
#define CFN_FIRST 1
#define CFN_DEFAULT 2
#define pcm_err ((Cmatcher) 1)
/* Information about what to put on the line as the unambiguous string.
* The code always keeps lists of these structs up to date while
* matches are added (in the aminfo structs below).
* The lists have two levels: in the first one we have one struct per
* word-part, where parts are separated by the anchors of `*' patterns.
* These structs have pointers (in the prefix and suffix fields) to
* lists of cline structs describing the strings before or after the
* the anchor. */
typedef struct cline *Cline;
typedef struct clsub Clsub;
struct cline {
Cline next;
int flags;
char *line;
int llen;
char *word;
int wlen;
char *orig;
int olen;
int slen;
Cline prefix, suffix;
int min, max;
};
#define CLF_MISS 1
#define CLF_DIFF 2
#define CLF_SUF 4
#define CLF_MID 8
#define CLF_NEW 16
#define CLF_LINE 32
#define CLF_JOIN 64
#define CLF_MATCHED 128
/* Information for ambiguous completions. One for fignore ignored and *
* one for normal completion. */
typedef struct aminfo *Aminfo;
struct aminfo {
Cmatch firstm; /* the first match */
int exact; /* if there was an exact match */
Cmatch exactm; /* the exact match (if any) */
int count; /* number of matches */
Cline line; /* unambiguous line string */
};
/* Information about menucompletion stuff. */
@ -463,3 +375,13 @@ struct chdata {
#define CP_KEYPARAMS 27
#define CP_ALLKEYS ((unsigned int) 0x7ffffff)
/* Types of completion. */
#define COMP_COMPLETE 0
#define COMP_LIST_COMPLETE 1
#define COMP_SPELL 2
#define COMP_EXPAND 3
#define COMP_EXPAND_COMPLETE 4
#define COMP_LIST_EXPAND 5
#define COMP_ISEXPAND(X) ((X) >= COMP_EXPAND)

File diff suppressed because it is too large Load diff

160
Src/Zle/compctl.h Normal file
View file

@ -0,0 +1,160 @@
/*
* comp.h - header file for completion
*
* This file is part of zsh, the Z shell.
*
* Copyright (c) 1992-1997 Paul Falstad
* All rights reserved.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and to distribute modified versions of this software for any
* purpose, provided that the above copyright notice and the following
* two paragraphs appear in all copies of this software.
*
* In no event shall Paul Falstad or the Zsh Development Group be liable
* to any party for direct, indirect, special, incidental, or consequential
* damages arising out of the use of this software and its documentation,
* even if Paul Falstad and the Zsh Development Group have been advised of
* the possibility of such damage.
*
* Paul Falstad and the Zsh Development Group specifically disclaim any
* warranties, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose. The software
* provided hereunder is on an "as is" basis, and Paul Falstad and the
* Zsh Development Group have no obligation to provide maintenance,
* support, updates, enhancements, or modifications.
*
*/
#undef compctlread
typedef struct compctlp *Compctlp;
typedef struct compctl *Compctl;
typedef struct compcond *Compcond;
typedef struct patcomp *Patcomp;
/* node for compctl hash table (compctltab) */
struct compctlp {
HashNode next; /* next in hash chain */
char *nam; /* command name */
int flags; /* CURRENTLY UNUSED */
Compctl cc; /* pointer to the compctl desc. */
};
/* for the list of pattern compctls */
struct patcomp {
Patcomp next;
char *pat;
Compctl cc;
};
/* compctl -x condition */
struct compcond {
Compcond and, or; /* the next or'ed/and'ed conditions */
int type; /* the type (CCT_*) */
int n; /* the array length */
union { /* these structs hold the data used to */
struct { /* test this condition */
int *a, *b; /* CCT_POS, CCT_NUMWORDS */
}
r;
struct { /* CCT_CURSTR, CCT_CURPAT,... */
int *p;
char **s;
}
s;
struct { /* CCT_RANGESTR,... */
char **a, **b;
}
l;
}
u;
};
#define CCT_UNUSED 0
#define CCT_POS 1
#define CCT_CURSTR 2
#define CCT_CURPAT 3
#define CCT_WORDSTR 4
#define CCT_WORDPAT 5
#define CCT_CURSUF 6
#define CCT_CURPRE 7
#define CCT_CURSUB 8
#define CCT_CURSUBC 9
#define CCT_NUMWORDS 10
#define CCT_RANGESTR 11
#define CCT_RANGEPAT 12
#define CCT_QUOTE 13
/* Contains the real description for compctls */
struct compctl {
int refc; /* reference count */
Compctl next; /* next compctl for -x */
unsigned long mask, mask2; /* masks of things to complete (CC_*) */
char *keyvar; /* for -k (variable) */
char *glob; /* for -g (globbing) */
char *str; /* for -s (expansion) */
char *func; /* for -K (function) */
char *explain; /* for -X (explanation) */
char *ylist; /* for -y (user-defined desc. for listing) */
char *prefix, *suffix; /* for -P and -S (prefix, suffix) */
char *subcmd; /* for -l (command name to use) */
char *substr; /* for -1 (command name to use) */
char *withd; /* for -w (with directory */
char *hpat; /* for -H (history pattern) */
int hnum; /* for -H (number of events to search) */
char *gname; /* for -J and -V (group name) */
Compctl ext; /* for -x (first of the compctls after -x) */
Compcond cond; /* for -x (condition for this compctl) */
Compctl xor; /* for + (next of the xor'ed compctls) */
Cmatcher matcher; /* matcher control (-M) */
char *mstr; /* matcher string */
};
/* objects to complete (mask) */
#define CC_FILES (1<<0)
#define CC_COMMPATH (1<<1)
#define CC_REMOVE (1<<2)
#define CC_OPTIONS (1<<3)
#define CC_VARS (1<<4)
#define CC_BINDINGS (1<<5)
#define CC_ARRAYS (1<<6)
#define CC_INTVARS (1<<7)
#define CC_SHFUNCS (1<<8)
#define CC_PARAMS (1<<9)
#define CC_ENVVARS (1<<10)
#define CC_JOBS (1<<11)
#define CC_RUNNING (1<<12)
#define CC_STOPPED (1<<13)
#define CC_BUILTINS (1<<14)
#define CC_ALREG (1<<15)
#define CC_ALGLOB (1<<16)
#define CC_USERS (1<<17)
#define CC_DISCMDS (1<<18)
#define CC_EXCMDS (1<<19)
#define CC_SCALARS (1<<20)
#define CC_READONLYS (1<<21)
#define CC_SPECIALS (1<<22)
#define CC_DELETE (1<<23)
#define CC_NAMED (1<<24)
#define CC_QUOTEFLAG (1<<25)
#define CC_EXTCMDS (1<<26)
#define CC_RESWDS (1<<27)
#define CC_DIRS (1<<28)
#define CC_EXPANDEXPL (1<<30)
#define CC_RESERVED (1<<31)
/* objects to complete (mask2) */
#define CC_NOSORT (1<<0)
#define CC_XORCONT (1<<1)
#define CC_CCCONT (1<<2)
#define CC_PATCONT (1<<3)
#define CC_DEFCONT (1<<4)
#define CC_UNIQCON (1<<5)
#define CC_UNIQALL (1<<6)

View file

@ -1,9 +1,6 @@
moddeps="comp1"
moddeps="complete"
autobins="compctl compgen compadd compset"
autoprefixconds="prefix suffix between after"
autoparams="compmatchers"
autobins="compctl"
headers="compctl.h"
objects="compctl.o"

1332
Src/Zle/complete.c Normal file

File diff suppressed because it is too large Load diff

11
Src/Zle/complete.mdd Normal file
View file

@ -0,0 +1,11 @@
hasexport=1
moddeps="zle"
autobins="compgen compadd compset"
autoprefixconds="prefix suffix between after"
autoparams="compmatchers"
objects="complete.o"

View file

@ -415,7 +415,7 @@ clprintm(Cmgroup g, Cmatch *mp, int mc, int ml, int lastc, int width,
}
putc(file_type(buf->st_mode), shout);
len++;
}
}
if ((len = width - len - 2) > 0) {
if (m->gnum != mselect) {
zcoff();

View file

@ -1,3 +1,3 @@
moddeps="comp1 zle"
moddeps="complete"
objects="complist.o"

View file

@ -1,4 +1,4 @@
moddeps="compctl zle"
moddeps="complete"
objects="computil.o"

View file

@ -146,6 +146,17 @@ typedef struct cutbuffer *Cutbuffer;
/* Convenience macros for the hooks */
#define LISTMATCHESHOOK (zlehooks + 0)
#define INSERTMATCHHOOK (zlehooks + 1)
#define MENUSTARTHOOK (zlehooks + 2)
#define LISTMATCHESHOOK (zlehooks + 0)
#define INSERTMATCHHOOK (zlehooks + 1)
#define MENUSTARTHOOK (zlehooks + 2)
#define COMPCTLMAKEHOOK (zlehooks + 3)
#define COMPCTLBEFOREHOOK (zlehooks + 4)
#define COMPCTLAFTERHOOK (zlehooks + 5)
/* compctl hook data structs */
struct ccmakedat {
char *str;
int incmd;
int lst;
};

View file

@ -1,5 +1,75 @@
hasexport=1
autobins="bindkey vared zle"
objects="zle_bindings.o zle_hist.o zle_keymap.o zle_main.o \
zle_misc.o zle_move.o zle_params.o zle_refresh.o \
zle_thingy.o zle_tricky.o zle_utils.o zle_vi.o zle_word.o"
headers="zle.h zle_things.h comp.h"
:<<\Make
zle_things.h: thingies.list zle_things.sed
( \
echo '/** zle_things.h **/'; \
echo '/** indices of and pointers to known thingies **/'; \
echo; \
echo 'enum {'; \
sed -n -f $(sdir)/zle_things.sed < thingies.list; \
echo ' ZLE_BUILTIN_THINGY_COUNT'; \
echo '};'; \
) > $@
zle_widget.h: widgets.list zle_widget.sed
( \
echo '/** zle_widget.h **/'; \
echo '/** indices of and pointers to internal widgets **/'; \
echo; \
echo 'enum {'; \
sed -n -f $(sdir)/zle_widget.sed < widgets.list; \
echo ' ZLE_BUILTIN_WIDGET_COUNT'; \
echo '};'; \
) > $@
thingies.list: iwidgets.list
( \
echo '/** thingies.list **/'; \
echo '/** thingy structures for the known thingies **/'; \
echo; \
echo '/* format: T("name", TH_FLAGS, w_widget, t_nextthingy) */'; \
echo; \
sed -e 's/#.*//; /^$$/d; s/" *,.*/"/' \
-e 's/^"/T("/; s/$$/, 0,/; h' \
-e 's/-//g; s/^.*"\(.*\)".*/w_\1, t_D\1)/' \
-e 'H; g; s/\n/ /' \
< $(sdir)/iwidgets.list; \
sed -e 's/#.*//; /^$$/d; s/" *,.*/"/' \
-e 's/^"/T("./; s/$$/, TH_IMMORTAL,/; h' \
-e 's/-//g; s/^.*"\.\(.*\)".*/w_\1, t_\1)/' \
-e 'H; g; s/\n/ /' \
< $(sdir)/iwidgets.list; \
) > $@
widgets.list: iwidgets.list
( \
echo '/** widgets.list **/'; \
echo '/** widget structures for the internal widgets **/'; \
echo; \
echo '/* format: W(ZLE_FLAGS, t_firstname, functionname) */'; \
echo; \
sed -e 's/#.*//; /^$$/d; s/-//g' \
-e 's/^"\(.*\)" *, *\([^ ]*\) *, *\(.*\)/W(\3, t_\1, \2)/' \
< $(sdir)/iwidgets.list; \
) > $@
zle_bindings.o zle_bindings..o: zle_widget.h widgets.list thingies.list
clean-here: clean.zle
clean.zle:
rm -f zle_things.h zle_widget.h widgets.list thingies.list
Make
hasexport=1
moddeps="comp1"
autobins="bindkey vared zle"

View file

@ -104,7 +104,8 @@ char *curkeymapname;
/* the hash table of keymap names */
static HashTable keymapnamtab;
/**/
HashTable keymapnamtab;
/* key sequence reading data */

View file

@ -30,6 +30,70 @@
#include "zle.mdh"
#include "zle_main.pro"
/* Defined by the complete module, called in zle_tricky.c. */
/**/
void (*makecompparamsptr) _((void));
/**/
void (*comp_setunsetptr) _((int, int, int, int));
/* != 0 if in a shell function called from completion, such that read -[cl] *
* will work (i.e., the line is metafied, and the above word arrays are OK). */
/**/
int incompctlfunc;
/* != 0 if we are in a new style completion function */
/**/
int incompfunc;
/* Global matcher. */
/**/
Cmlist cmatcher;
/* global variables for shell parameters in new style completion */
/**/
zlong compcurrent,
compmatcher,
compmatchertot,
complistmax,
complistlines;
/**/
char **compwords,
*compprefix,
*compsuffix,
*compiprefix,
*compisuffix,
*compqiprefix,
*compqisuffix,
*compmatcherstr,
*compcontext,
*compparameter,
*compredirect,
*compquote,
*compquoting,
*comprestore,
*complist,
*compforcelist,
*compinsert,
*compexact,
*compexactstr,
*comppatmatch,
*comppatinsert,
*complastprompt,
*comptoend,
*compoldlist,
*compoldins,
*compvared;
/**/
Param *comprpms, *compkpms;
/* != 0 if we're done editing */
/**/
@ -961,6 +1025,9 @@ struct hookdef zlehooks[] = {
HOOKDEF("list_matches", ilistmatches, 0),
HOOKDEF("insert_match", NULL, HOOKF_ALL),
HOOKDEF("menu_start", NULL, HOOKF_ALL),
HOOKDEF("compctl_make", NULL, 0),
HOOKDEF("compctl_before", NULL, 0),
HOOKDEF("compctl_after", NULL, 0),
};
/**/
@ -974,17 +1041,6 @@ setup_zle(Module m)
spaceinlineptr = spaceinline;
zlereadptr = zleread;
addmatchesptr = addmatches;
comp_strptr = comp_str;
getcpatptr = getcpat;
makecomplistcallptr = makecomplistcall;
makecomplistctlptr = makecomplistctl;
num_matchesptr = num_matches;
list_linesptr = list_lines;
comp_listptr = comp_list;
unambig_dataptr = unambig_data;
set_comp_sepptr = set_comp_sep;
getkeyptr = getkey;
/* initialise the thingies */
@ -1001,6 +1057,23 @@ setup_zle(Module m)
varedarg = NULL;
incompfunc = incompctlfunc = 0;
comprpms = compkpms = NULL;
compwords = NULL;
compprefix = compsuffix = compiprefix = compisuffix =
compqiprefix = compqisuffix = compmatcherstr =
compcontext = compparameter = compredirect = compquote =
compquoting = comprestore = complist = compinsert =
compexact = compexactstr = comppatmatch = comppatinsert =
compforcelist = complastprompt = comptoend =
compoldlist = compoldins = compvared = NULL;
clwords = (char **) zcalloc((clwsize = 16) * sizeof(char *));
makecompparamsptr = NULL;
comp_setunsetptr = NULL;
return 0;
}
@ -1057,19 +1130,37 @@ finish_zle(Module m)
spaceinlineptr = noop_function_int;
zlereadptr = fallback_zleread;
addmatchesptr = NULL;
comp_strptr = NULL;
getcpatptr = NULL;
makecomplistcallptr = NULL;
makecomplistctlptr = NULL;
num_matchesptr = NULL;
list_linesptr = NULL;
comp_listptr = NULL;
unambig_dataptr = NULL;
set_comp_sepptr = NULL;
getkeyptr = NULL;
freearray(compwords);
zsfree(compprefix);
zsfree(compsuffix);
zsfree(compiprefix);
zsfree(compisuffix);
zsfree(compqiprefix);
zsfree(compqisuffix);
zsfree(compmatcherstr);
zsfree(compcontext);
zsfree(compparameter);
zsfree(compredirect);
zsfree(compquote);
zsfree(compquoting);
zsfree(comprestore);
zsfree(complist);
zsfree(compforcelist);
zsfree(compinsert);
zsfree(compexact);
zsfree(compexactstr);
zsfree(comppatmatch);
zsfree(comppatinsert);
zsfree(complastprompt);
zsfree(comptoend);
zsfree(compoldlist);
zsfree(compoldins);
zsfree(compvared);
zfree(clwords, clwsize * sizeof(char *));
return 0;
}

View file

@ -551,13 +551,13 @@ bin_zle_complete(char *name, char **args, char *ops, char func)
Widget w, cw;
#ifdef DYNAMIC
if (!require_module(name, "compctl", 0, 0)) {
zerrnam(name, "can't load compctl module", NULL, 0);
if (!require_module(name, "complete", 0, 0)) {
zerrnam(name, "can't load complete module", NULL, 0);
return 1;
}
#else
if (!makecompparamsptr) {
zerrnam(name, "compctl module not available", NULL, 0);
if (!module_linked("complete")) {
zerrnam(name, "complete module not available", NULL, 0);
return 1;
}
#endif

File diff suppressed because it is too large Load diff

257
Src/Zle/zleparameter.c Normal file
View file

@ -0,0 +1,257 @@
/*
* zleparameter.c - parameter interface to zle internals
*
* This file is part of zsh, the Z shell.
*
* Copyright (c) 1999 Sven Wischnowsky
* All rights reserved.
*
* Permission is hereby granted, without written agreement and without
* license or royalty fees, to use, copy, modify, and distribute this
* software and to distribute modified versions of this software for any
* purpose, provided that the above copyright notice and the following
* two paragraphs appear in all copies of this software.
*
* In no event shall Sven Wischnowsky or the Zsh Development Group be liable
* to any party for direct, indirect, special, incidental, or consequential
* damages arising out of the use of this software and its documentation,
* even if Sven Wischnowsky and the Zsh Development Group have been advised of
* the possibility of such damage.
*
* Sven Wischnowsky and the Zsh Development Group specifically disclaim any
* warranties, including, but not limited to, the implied warranties of
* merchantability and fitness for a particular purpose. The software
* provided hereunder is on an "as is" basis, and Sven Wischnowsky and the
* Zsh Development Group have no obligation to provide maintenance,
* support, updates, enhancements, or modifications.
*
*/
#include "zleparameter.mdh"
#include "zleparameter.pro"
/* Empty dummy function for special hash parameters. */
/**/
static void
shempty(void)
{
}
/* Create a simple special hash parameter. */
/**/
static Param
createspecialhash(char *name, GetNodeFunc get, ScanTabFunc scan)
{
Param pm;
HashTable ht;
if (!(pm = createparam(name, PM_SPECIAL|PM_HIDE|PM_REMOVABLE|PM_HASHED)))
return NULL;
pm->level = pm->old ? locallevel : 0;
pm->gets.hfn = hashgetfn;
pm->sets.hfn = hashsetfn;
pm->unsetfn = stdunsetfn;
pm->u.hash = ht = newhashtable(7, name, NULL);
ht->hash = hasher;
ht->emptytable = (TableFunc) shempty;
ht->filltable = NULL;
ht->addnode = (AddNodeFunc) shempty;
ht->getnode = ht->getnode2 = get;
ht->removenode = (RemoveNodeFunc) shempty;
ht->disablenode = NULL;
ht->enablenode = NULL;
ht->freenode = (FreeNodeFunc) shempty;
ht->printnode = printparamnode;
ht->scantab = scan;
return pm;
}
/* Functions for the zlewidgets special parameter. */
/**/
static char *
widgetstr(Widget w)
{
if (w->flags & WIDGET_INT)
return dupstring("builtin");
if (w->flags & WIDGET_NCOMP) {
char *t = (char *) zhalloc(13 + strlen(w->u.comp.wid) +
strlen(w->u.comp.func));
strcpy(t, "completion:");
strcat(t, w->u.comp.wid);
strcat(t, ":");
strcat(t, w->u.comp.func);
return t;
}
return dyncat("user:", w->u.fnnam);
}
/**/
static HashNode
getpmwidgets(HashTable ht, char *name)
{
Param pm = NULL;
Thingy th;
HEAPALLOC {
pm = (Param) zhalloc(sizeof(struct param));
pm->nam = dupstring(name);
pm->flags = PM_SCALAR | PM_READONLY;
pm->sets.cfn = NULL;
pm->gets.cfn = strgetfn;
pm->unsetfn = NULL;
pm->ct = 0;
pm->env = NULL;
pm->ename = NULL;
pm->old = NULL;
pm->level = 0;
if ((th = (Thingy) thingytab->getnode(thingytab, name)) &&
!(th->flags & DISABLED))
pm->u.str = widgetstr(th->widget);
else {
pm->u.str = dupstring("");
pm->flags |= PM_UNSET;
}
} LASTALLOC;
return (HashNode) pm;
}
/**/
static void
scanpmwidgets(HashTable ht, ScanFunc func, int flags)
{
struct param pm;
int i;
HashNode hn;
pm.flags = PM_SCALAR | PM_READONLY;
pm.sets.cfn = NULL;
pm.gets.cfn = strgetfn;
pm.unsetfn = NULL;
pm.ct = 0;
pm.env = NULL;
pm.ename = NULL;
pm.old = NULL;
pm.level = 0;
for (i = 0; i < thingytab->hsize; i++)
for (hn = thingytab->nodes[i]; hn; hn = hn->next) {
pm.nam = hn->nam;
if (func != scancountparams)
pm.u.str = widgetstr(((Thingy) hn)->widget);
func((HashNode) &pm, flags);
}
}
/* Functions for the zlekeymaps special parameter. */
static char **
keymapsgetfn(Param pm)
{
int i;
HashNode hn;
char **ret, **p;
p = ret = (char **) zhalloc((keymapnamtab->ct + 1) * sizeof(char *));
for (i = 0; i < keymapnamtab->hsize; i++)
for (hn = keymapnamtab->nodes[i]; hn; hn = hn->next)
*p++ = dupstring(hn->nam);
*p = NULL;
return ret;
}
/* Table for defined parameters. */
struct pardef {
char *name;
int flags;
GetNodeFunc getnfn;
ScanTabFunc scantfn;
void (*hsetfn) _((Param, HashTable));
void (*setfn) _((Param, char **));
char **(*getfn) _((Param));
void (*unsetfn) _((Param, int));
Param pm;
};
static struct pardef partab[] = {
{ "zlewidgets", PM_READONLY,
getpmwidgets, scanpmwidgets, hashsetfn,
NULL, NULL, stdunsetfn, NULL },
{ "zlekeymaps", PM_ARRAY|PM_HIDE|PM_SPECIAL|PM_READONLY,
NULL, NULL, NULL,
arrsetfn, keymapsgetfn, stdunsetfn, NULL },
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
/**/
int
setup_zleparameter(Module m)
{
return 0;
}
/**/
int
boot_zleparameter(Module m)
{
struct pardef *def;
for (def = partab; def->name; def++) {
unsetparam(def->name);
if (def->getnfn) {
if (!(def->pm = createspecialhash(def->name, def->getnfn,
def->scantfn)))
return 1;
def->pm->flags |= def->flags;
if (def->hsetfn)
def->pm->sets.hfn = def->hsetfn;
} else {
if (!(def->pm = createparam(def->name, def->flags)))
return 1;
def->pm->sets.afn = def->setfn;
def->pm->gets.afn = def->getfn;
def->pm->unsetfn = def->unsetfn;
}
}
return 0;
}
#ifdef MODULE
/**/
int
cleanup_zleparameter(Module m)
{
Param pm;
struct pardef *def;
for (def = partab; def->name; def++) {
if ((pm = (Param) paramtab->getnode(paramtab, def->name)) &&
pm == def->pm) {
pm->flags &= ~PM_READONLY;
unsetparam_pm(pm, 0, 1);
}
}
return 0;
}
/**/
int
finish_zleparameter(Module m)
{
return 0;
}
#endif

5
Src/Zle/zleparameter.mdd Normal file
View file

@ -0,0 +1,5 @@
moddeps="zle"
autoparams="zlewidgets zlekeymaps"
objects="zleparameter.o"

View file

@ -1119,6 +1119,17 @@ printaliasnode(HashNode hn, int printflags)
/* Named Directory Hash Table Functions */
/****************************************/
#ifdef HAVE_NIS_PLUS
# include <rpcsvc/nis.h>
#else
# ifdef HAVE_NIS
# include <rpc/types.h>
# include <rpc/rpc.h>
# include <rpcsvc/ypclnt.h>
# include <rpcsvc/yp_prot.h>
# endif
#endif
/* hash table containing named directories */
/**/
@ -1168,12 +1179,102 @@ emptynameddirtable(HashTable ht)
/* Add all the usernames in the password file/database *
* to the named directories table. */
#ifdef HAVE_NIS_PLUS
static int
add_userdir(nis_name table, nis_object *object, void *userdata)
{
if (object->zo_data.objdata_u.en_data.en_cols.en_cols >= 6) {
static char name[40], dir[PATH_MAX + 1];
register entry_col *ec =
object->zo_data.objdata_u.en_data.en_cols.en_cols_val;
register int nl = minimum(ec[0].ec_value.ec_value_len, 39);
register int dl = minimum(ec[5].ec_value.ec_value_len, PATH_MAX);
memcpy(name, ec[0].ec_value.ec_value_val, nl);
name[nl] = '\0';
memcpy(dir, ec[5].ec_value.ec_value_val, dl);
dir[dl] = '\0';
adduserdir(name, dir, ND_USERNAME, 1);
}
return 0;
}
#else
# ifdef HAVE_NIS
static int
add_userdir(int status, char *key, int keylen, char *val, int vallen, char *dummy)
{
char *p, *d, *de;
if (status != YP_TRUE)
return 1;
if (vallen > keylen && *(p = val + keylen) == ':') {
*p++ = '\0';
if ((de = strrchr(p, ':'))) {
*de = '\0';
if ((d = strrchr(p, ':'))) {
if (*++d && val[0])
adduserdir(val, d, ND_USERNAME, 1);
}
}
}
return 0;
}
# endif /* HAVE_NIS */
#endif /* HAVE_NIS_PLUS */
/**/
static void
fillnameddirtable(HashTable ht)
{
#ifdef HAVE_GETPWENT
if (!allusersadded) {
#if defined(HAVE_NIS) || defined(HAVE_NIS_PLUS)
FILE *pwf;
char buf[BUFSIZ], *p, *d, *de;
int skipping;
# ifndef HAVE_NIS_PLUS
char domain[YPMAXDOMAIN];
struct ypall_callback cb;
/* Get potential matches from NIS and cull those without local accounts */
if (getdomainname(domain, YPMAXDOMAIN) == 0) {
cb.foreach = (int (*)()) add_userdir;
cb.data = NULL;
yp_all(domain, PASSWD_MAP, &cb);
}
# else /* HAVE_NIS_PLUS */
/* Maybe we should turn this string into a #define'd constant...? */
nis_list("passwd.org_dir", EXPAND_NAME|ALL_RESULTS|FOLLOW_LINKS|FOLLOW_PATH,
add_userdir, 0);
# endif
/* Don't forget the non-NIS matches from the flat passwd file */
if ((pwf = fopen(PASSWD_FILE, "r")) != NULL) {
skipping = 0;
while (fgets(buf, BUFSIZ, pwf) != NULL) {
if (strchr(buf, '\n') != NULL) {
if (!skipping) {
if ((p = strchr(buf, ':')) != NULL) {
*p++ = '\0';
if ((de = strrchr(p, ':'))) {
*de = '\0';
if ((d = strrchr(p, ':'))) {
if (*++d && buf[0])
adduserdir(buf, d, ND_USERNAME, 1);
}
}
}
} else
skipping = 0;
} else
skipping = 1;
}
fclose(pwf);
}
#else /* no NIS or NIS_PLUS */
#ifdef HAVE_GETPWENT
struct passwd *pw;
setpwent();
@ -1181,13 +1282,13 @@ fillnameddirtable(HashTable ht)
/* loop through the password file/database *
* and add all entries returned. */
while ((pw = getpwent()) && !errflag)
adduserdir(ztrdup(pw->pw_name), pw->pw_dir, ND_USERNAME, 1);
adduserdir(pw->pw_name, pw->pw_dir, ND_USERNAME, 1);
endpwent();
#endif /* HAVE_GETPWENT */
#endif
allusersadded = 1;
}
return;
#endif /* HAVE_GETPWENT */
}
/* Add an entry to the named directory hash *

View file

@ -65,6 +65,21 @@ register_module(char *n)
} LASTALLOC;
}
/* Check if a module is linked in. */
/**/
int
module_linked(char *name)
{
LinkNode node;
for (node = firstnode(bltinmodules); node; incnode(node))
if (!strcmp((char *) getdata(node), name))
return 1;
return 0;
}
/* addbuiltin() can be used to add a new builtin. It returns zero on *
* success, 1 on failure. The only possible type of failure is that *
* a builtin with the specified name already exists. An autoloaded *
@ -1401,7 +1416,7 @@ addhookdefs(char const *nam, Hookdef h, int size)
while (size--) {
if (addhookdef(h)) {
zwarnnam(nam, "name clash when adding condition `%s'", h->name, 0);
zwarnnam(nam, "name clash when adding hook `%s'", h->name, 0);
hadf = 1;
} else
hads = 2;

View file

@ -2012,7 +2012,7 @@ strsetfn(Param pm, char *x)
/* Function to get value of an array parameter */
/**/
static char **
char **
arrgetfn(Param pm)
{
static char *nullarray = NULL;
@ -2023,7 +2023,7 @@ arrgetfn(Param pm)
/* Function to set value of an array parameter */
/**/
static void
void
arrsetfn(Param pm, char **x)
{
if (pm->u.arr && pm->u.arr != x)

View file

@ -1076,6 +1076,10 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
val = dyncat(val, "-export");
if (f & PM_UNIQUE)
val = dyncat(val, "-unique");
if (f & PM_HIDE)
val = dyncat(val, "-hide");
if (f & PM_SPECIAL)
val = dyncat(val, "-special");
vunset = 0;
} else
val = dupstring("");

View file

@ -1,6 +1,6 @@
rlimits
comp1
zle
complete
compctl
sched
complist