From 7c670f1e6a0e154f0b1a2d4b6eed0e71c9404b56 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sat, 3 Jul 1999 13:16:46 +0000 Subject: zsh-3.1.5-pws-25 --- Completion/Core/compinit | 93 +++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 57 deletions(-) (limited to 'Completion/Core/compinit') diff --git a/Completion/Core/compinit b/Completion/Core/compinit index f4aa80f21..9302d8243 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -41,15 +41,14 @@ # See the file `compdump' for how to speed up initialisation. # If we got the `-d'-flag, we will automatically dump the new state (at -# the end). -# `-f dir' is used to pass down the directory where this file was -# found. This is necessary if functionargzero is not set. -# If we were given an argument, this will be taken as the name of the -# file in which to store the dump. - -_i_fdir='' -_i_dumpfile='' -_i_autodump=0 +# the end). This takes the dumpfile as an argument. -d (with the +# default dumpfile) is now the default; to turn off dumping use -D. + +emulate -L zsh + +typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1 +typeset _i_tag _i_file _i_addfiles + while [[ $# -gt 0 && $1 = -[df] ]]; do if [[ "$1" = -d ]]; then _i_autodump=1 @@ -58,57 +57,30 @@ while [[ $# -gt 0 && $1 = -[df] ]]; do _i_dumpfile="$1" shift fi + elif [[ "$1" = -D ]]; then + _i_autodump=0 elif [[ "$1" = -f ]]; then - # Used by compinstall to pass down directory where compinit was found + # Not used any more; use _compdir shift - _i_fdir="$1" shift fi done -# Get the directory if we don't have it already and we can -if [[ -z "$_i_fdir" && -o functionargzero && $0 = */* ]]; then - _i_fdir=${0:h} -fi # The associative array containing the definitions for the commands. # Definitions for patterns will be stored in the normal array `_patcomps'. -typeset -A _comps +typeset -gA _comps _patcomps=() # This is the associative array used for configuration. -typeset -A compconfig +typeset -gA compconfig # Standard initialisation for `compconfig'. if [[ -n $_i_dumpfile ]]; then # Explicitly supplied dumpfile. compconfig[dumpfile]="$_i_dumpfile" -elif [[ -o functionargzero ]]; then - # We can deduce it from the name of this script - compconfig[dumpfile]="$0.dump" -elif [[ -n $_i_fdir ]]; then - # We were told what directory to use. - compconfig[dumpfile]="$_i_fdir/compinit.dump" else - compconfig[dumpfile]='' -fi - -if [[ -n $compconfig[dumpfile] ]]; then - # Check the file is writeable. If it doesn't exist, the - # only safe way is to try and create it. - if [[ -f $compconfig[dumpfile] ]]; then - [[ -w $compconfig[dumpfile] ]] || compconfig[dumpfile]='' - elif touch $compconfig[dumpfile] >& /dev/null; then - rm -f $compconfig[dumpfile] - else - compconfig[dumpfile]='' - fi -fi - -if [[ -z $compconfig[dumpfile] ]]; then - # If no dumpfile given, or it was not writeable, then use - # user's ZDOTDIR. compconfig[dumpfile]="${ZDOTDIR:-$HOME}/.zcompdump" fi @@ -322,19 +294,24 @@ compconf() { typeset -U _i_files _i_files=( ${^~fpath:/.}/_(|*[^~])(N:t) ) -if [[ $#_i_files -lt 20 ]]; then - # Too few files: we need some more directories - # Assume that we need to add the compinit directory to fpath. - if [[ -n $_i_fdir ]]; then - if [[ $_i_fdir = */Core ]]; then +if [[ $#_i_files -lt 20 || $_compdir = */Core || -d $_compdir/Core ]]; then + # Too few files: we need some more directories, + # or we need to check that all directories (not just Core) are present. + if [[ -n $_compdir ]]; then + _i_addfiles=() + if [[ $_compdir = */Core ]]; then # Add all the Completion subdirectories - fpath=(${_i_fdir:h}/*(/) $fpath) - elif [[ -d $_i_fdir/Core ]]; then + _i_addfiles=(${_compdir:h}/*(/)) + elif [[ -d $_compdir/Core ]]; then # Likewise - fpath=(${_i_fdir}/*(/) $fpath) - else - fpath=($_i_fdir $fpath) + _i_addfiles=(${_compdir}/*(/)) fi + for _i_line in {1..$#i_addfiles}; do + _i_file=${_i_addfiles[$_i_line]} + [[ -d $_i_file && -z ${fpath[(r)$_i_$file]} ]] || + _i_addfiles[$_i_line]= + done + fpath=($_i_addfiles $fpath) _i_files=( ${^~fpath:/.}/_(|*[^~])(N:t) ) fi fi @@ -346,9 +323,13 @@ for _i_line in complete-word delete-char-or-list expand-or-complete \ menu-expand-or-complete reverse-menu-complete; do zle -C $_i_line .$_i_line _main_complete done +zle -la menu-select && zle -C menu-select .menu-select _main_complete _i_done='' +# Make sure compdump is available, even if we aren't going to use it. +autoload -U compdump compinstall + # If we have a dump file, load it. if [[ -f "$compconfig[dumpfile]" ]]; then @@ -357,7 +338,6 @@ if [[ -f "$compconfig[dumpfile]" ]]; then builtin . "$compconfig[dumpfile]" _i_done=yes fi - unset _i_line fi if [[ -z "$_i_done" ]]; then for _i_dir in $fpath; do @@ -381,13 +361,12 @@ if [[ -z "$_i_done" ]]; then done done - unset _i_dir _i_line _i_file _i_tag - # If autodumping was requested, do it now. - if [[ -n ${_i_fdir} && $_i_autodump = 1 ]]; then - builtin . ${_i_fdir}/compdump + if [[ $_i_autodump = 1 ]]; then + compdump fi fi -unset _i_files _i_initname _i_done _i_autodump _i_fdir _i_dumpfile +unfunction compinit +autoload -U compinit -- cgit 1.4.1