From 04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 15 Apr 1999 18:20:19 +0000 Subject: zsh-3.1.5-pws-12 --- Completion/Core/compinit | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'Completion/Core/compinit') diff --git a/Completion/Core/compinit b/Completion/Core/compinit index ec5867838..31d011565 100644 --- a/Completion/Core/compinit +++ b/Completion/Core/compinit @@ -37,18 +37,24 @@ # Note that no white space is allowed between the `#' and the rest of # the string. # -# See the file `compdump' for how to speed up initialiation. +# Functions that are used to generate matches should return zero if they +# were able to add matches and non-zero otherwise. +# +# See the file `compdump' for how to speed up initialisation. # # If you are using global matching specifications with `compctl -M ...' # have a look at the files `_match_test' and `_match_pattern'. To make # all the example functions use matching as specified with `-M' these # need some editing. -# + # If we got the `-d'-flag, we will automatically dump the new state (at # the end). +# If we were given an argument, this will be taken as the name of the +# file in which to store the dump. if [[ "$1" = -d ]]; then _i_autodump=1 + shift else _i_autodump=0 fi @@ -59,6 +65,18 @@ fi typeset -A _comps _patcomps=() +# This is the associative array used for configuration. + +typeset -A compconfig + +# Standard initialisation for `compconfig'. + +(( $# )) && compconfig[dump_file]="$1" +[[ -z "$compconfig[dump_file]" ]] && compconfig[dump_file]="$0.dump" + +compconfig[correct_prompt]='correct to:' + + # This function is used to register or delete completion functions. For # registering completion functions, it is invoked with the name of the # function as it's first argument (after the options). The other @@ -197,11 +215,25 @@ compdef() { fi } -# Now we automatically make the definition files autoloaded. +# Functional interface to configuration. This takes its arguments +# and sets the according values in `compconfig'. +# Arguments may be `foo=bar' to set key `foo' to `bar' or `baz' to +# set key `baz' to the empty string. -# First we get the name of a dump file if this will be used. +compconf() { + local i name -: ${COMPDUMP:=$0.dump} + for i; do + if [[ "$i" = *\=* ]]; then + name="${i%%\=*}" + compconfig[$name]="${i#*\=}" + else + compconfig[$i]='' + fi + done +} + +# Now we automatically make the definition files autoloaded. if [[ ! -o extendedglob ]]; then _i_noextglob=yes @@ -215,10 +247,10 @@ _i_done='' # If we have a dump file, load it. -if [[ -f "$COMPDUMP" ]]; then - read -rA _i_line < "$COMPDUMP" +if [[ -f "$compconfig[dump_file]" ]]; then + read -rA _i_line < "$compconfig[dump_file]" if [[ _i_autodump -eq 1 && $_i_line[2] -eq $#_i_files ]]; then - builtin . "$COMPDUMP" + builtin . "$compconfig[dump_file]" _i_done=yes fi unset _i_line -- cgit 1.4.1