summaryrefslogtreecommitdiff
path: root/Completion/compinit
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/compinit')
-rw-r--r--Completion/compinit48
1 files changed, 36 insertions, 12 deletions
diff --git a/Completion/compinit b/Completion/compinit
index f0f8421df..5cb527fac 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -60,6 +60,10 @@
# the end). This takes the dumpfile as an argument. -d (with the
# default dumpfile) is now the default; to turn off dumping use -D.
+# If the dumpfile is being regenerated and you don't know why, you can use
+# the -w flag to see if it was because -D was passed, zsh version mismatched,
+# or number of files in $fpath differed.
+
# The -C flag bypasses both the check for rebuilding the dump file and the
# usual call to compaudit; the -i flag causes insecure directories found by
# compaudit to be ignored, and the -u flag causes all directories found by
@@ -71,9 +75,9 @@ emulate -L zsh
setopt extendedglob
typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
-typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name
+typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name _i_why
-while [[ $# -gt 0 && $1 = -[dDiuC] ]]; do
+while [[ $# -gt 0 && $1 = -[dDiuCw] ]]; do
case "$1" in
-d)
_i_autodump=1
@@ -99,6 +103,10 @@ while [[ $# -gt 0 && $1 = -[dDiuC] ]]; do
_i_check=
shift
;;
+ -w)
+ _i_why=1
+ shift
+ ;;
esac
done
@@ -157,6 +165,7 @@ _comp_options=(
NO_posixidentifiers
NO_shwordsplit
NO_shglob
+ NO_typesettounset
NO_warnnestedvar
NO_warncreateglobal
)
@@ -320,7 +329,7 @@ compdef() {
# and probably do autoloading.
func="$1"
- [[ -n "$autol" ]] && autoload -Uz "$func"
+ [[ -n "$autol" ]] && autoload -rUz "$func"
shift
case "$type" in
@@ -442,7 +451,7 @@ typeset _i_wdirs _i_wfiles
_i_wdirs=()
_i_wfiles=()
-autoload -Uz compaudit
+autoload -RUz compaudit
if [[ -n "$_i_check" ]]; then
typeset _i_q
if ! eval compaudit; then
@@ -458,19 +467,17 @@ Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then
return 1
fi
- _i_wfiles=()
- _i_wdirs=()
- else
- (( $#_i_wfiles )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}" )
- (( $#_i_wdirs )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wdirs%.zwc})/*}" )
fi
+ fpath=(${fpath:|_i_wdirs})
+ (( $#_i_wfiles )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}" )
+ (( $#_i_wdirs )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wdirs%.zwc})/*}" )
fi
typeset -g _comp_secure=yes
fi
fi
# Make sure compdump is available, even if we aren't going to use it.
-autoload -Uz compdump compinstall
+autoload -RUz compdump compinstall
# If we have a dump file, load it.
@@ -484,11 +491,28 @@ if [[ -f "$_comp_dumpfile" ]]; then
then
builtin . "$_comp_dumpfile"
_i_done=yes
+ elif [[ _i_why -eq 1 ]]; then
+ print -nu2 "Loading dump file skipped, regenerating"
+ local pre=" because: "
+ if [[ _i_autodump -ne 1 ]]; then
+ print -nu2 $pre"-D flag given"
+ pre=", "
+ fi
+ if [[ $_i_line[2] -ne $#_i_files ]]; then
+ print -nu2 $pre"number of files in dump $_i_line[2] differ from files found in \$fpath $#_i_files"
+ pre=", "
+ fi
+ if [[ $ZSH_VERSION != $_i_line[4] ]]; then
+ print -nu2 $pre"zsh version changed from $_i_line[4] to $ZSH_VERSION"
+ fi
+ print -u2
fi
else
builtin . "$_comp_dumpfile"
_i_done=yes
fi
+elif [[ _i_why -eq 1 ]]; then
+ print -u2 "No existing compdump file found, regenerating"
fi
if [[ -z "$_i_done" ]]; then
typeset -A _i_test
@@ -512,7 +536,7 @@ if [[ -z "$_i_done" ]]; then
fi
;;
(\#autoload)
- autoload -Uz "$_i_line[@]" ${_i_name}
+ autoload -rUz "$_i_line[@]" ${_i_name}
[[ "$_i_line" != \ # ]] && _compautos[${_i_name}]="$_i_line"
;;
esac
@@ -544,6 +568,6 @@ if [[ ${_i_line[2]} = expand-or-complete ]] &&
fi
unfunction compinit compaudit
-autoload -Uz compinit compaudit
+autoload -RUz compinit compaudit
return 0