[PATCH] compinit: improve and document -w

dana <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
the output of `compinit -w` is inaccurate when used with -D -- it always says
it's re-generating the file when that isn't the case

this fixes the wording and documents the option

i've also added a new-line after the compaudit prompt to prevent it from
running into the next line of output

dana


diff --git a/Completion/Zsh/Command/_compinit b/Completion/Zsh/Command/_compinit
index e97095d7f..5b5c2edd6 100644
--- a/Completion/Zsh/Command/_compinit
+++ b/Completion/Zsh/Command/_compinit
@@ -6,4 +6,4 @@ _arguments : \
   "(-w)-D[don't automatically create dump file]" \
   '(-C -u)-i[ignore insecure files]' \
   "(-C -i)-u[don't check for insecure files]" \
-  '(-D)-w[explain why dump file is created]'
+  "(-D)-w[explain why dump file isn't loaded]"
diff --git a/Completion/compinit b/Completion/compinit
index 60dbb599d..f1280fc60 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -461,6 +461,7 @@ if [[ -n "$_i_check" ]]; then
         if ! read -q \
 "?zsh compinit: insecure $_i_q, run compaudit for list.
 Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then
+	  print -u2
 	  print -u2 "$0: initialization aborted"
           unfunction compinit compdef
           unset _comp_dumpfile _comp_secure compprefuncs comppostfuncs \
@@ -468,6 +469,7 @@ Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then
 
           return 1
         fi
+        print -u2
       fi
       fpath=(${fpath:|_i_wdirs})
       (( $#_i_wfiles )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}"  )
@@ -484,6 +486,8 @@ autoload -RUz compdump compinstall
 
 _i_done=''
 
+[[ _i_why -eq 1 ]] && print -ru2 "Using dump file: $_comp_dumpfile"
+
 if [[ -f "$_comp_dumpfile" ]]; then
   if [[ -n "$_i_check" ]]; then
     IFS=$' \t' read -rA _i_line < "$_comp_dumpfile"
@@ -493,7 +497,7 @@ if [[ -f "$_comp_dumpfile" ]]; then
       builtin . "$_comp_dumpfile"
       _i_done=yes
     elif [[ _i_why -eq 1 ]]; then
-      print -nu2 "Loading dump file skipped, regenerating"
+      print -nu2 "Loading dump file skipped"
       local pre=" because: "
       if [[ _i_autodump -ne 1 ]]; then
         print -nu2 $pre"-D flag given"
@@ -513,8 +517,9 @@ if [[ -f "$_comp_dumpfile" ]]; then
     _i_done=yes
   fi
 elif [[ _i_why -eq 1 ]]; then
-  print -u2 "No existing compdump file found, regenerating"
+  print -u2 "No existing dump file found"
 fi
+
 if [[ -z "$_i_done" ]]; then
   typeset -A _i_test
 
@@ -547,6 +552,7 @@ if [[ -z "$_i_done" ]]; then
   # If autodumping was requested, do it now.
 
   if [[ $_i_autodump = 1 ]]; then
+    [[ _i_why -eq 1 ]] && print -u2 "Regenerating dump file"
     compdump
   fi
 fi
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index fbfccf82e..83032b54f 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -167,7 +167,8 @@ change, it is easiest to delete the dump file by hand so that
 tt(compinit) will re-create it the next time it is run.  The check
 performed to see if there are new functions can be omitted by giving
 the option tt(-C).  In this case the dump file will only be created if
-there isn't one already.
+there isn't one already.  Use option tt(-w) to explain why a dump file
+isn't loaded and/or why it's regenerated.
 
 The dumping is actually done by another function, tt(compdump), but you
 will only need to run this yourself if you change the configuration
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.