Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)



On Jul 27,  2:10am, Tanaka Akira wrote:
} 
} I think _cvs* are only for cvs, there is no necessity to make these
} autoloadable except _cvs.

The following simplifies some of the parameter expansions (use inner quoted
substitutions instead of multiple (@) flags) and fixes a bug where no matches
were generated for `cvs commit' when the `stat' module is not available (now
you may get too many matches, but at least you get some).  The code obviously
was attempting to generate the same output as _cvstargets but had computed
the lines in the CVS/Entries file only in the `stat'-available branch.

There's still a bug, which may be a more general completion problem:  If the
initial prefix of the completion contains a metacharacter (such as '#') that
is inserted quoted, the completer thereafter does not match.  E.g.

zsh% cvs add <C-d>
F#bar F#baz
zsh% cvs add <TAB>
zsh% cvs add F\#<TAB>
(BEEP)
zsh% cvs add F\#<C-d>
(BEEP)
zsh% cvs add F\#<C-b><DEL><C-e>
zsh% cvs add F#<C-d>
F#bar F#baz
zsh% cvs add F#<TAB>
zsh% cvs add F\#

Watch out for tabs converted to spaces in the following ...

Index: Completion/User/_cvs
===================================================================
@@ -157,7 +157,7 @@
 _cvsentries () {
   setopt localoptions nullglob unset
   if [[ -f ${pref}CVS/Entries ]]; then
-      entries=( "${(@)${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D}#(D|)/}%%/*}" )
+      entries=( ${${${${(f)"$(<${pref}CVS/Entries)"}:#D}#(D|)/}%%/*} )
   fi
 }
 
@@ -168,26 +168,27 @@
   local line Entries
   typeset -A mtime
 
+  if [[ -f "${pref}CVS/Entries" ]]; then
+    Entries="$(<${pref}CVS/Entries)"
+  fi
+
   if ! zmodload -e stat; then zmodload stat; fi
   if zmodload -e stat; then
-    if [[ -f "${pref}CVS/Entries" ]]; then
-      Entries="$(<${pref}CVS/Entries)"
-      mtime=( "${(@s:/:)${(j:/:)${(@)${(@)${(@)${(M@)${(f@)Entries}:#/*}#/}%/*/*}/\/*\///}}}" )
-      entries=( "${(@)${(@)${(M@)${(f@)Entries}:#D/*}#D/}%%/*}" )
-      builtin stat -n +mtime -F '%a %b %e %T %Y' "$pref${(@k)^mtime}" |
-      while read line
-      do
-	line=${line#$pref}
-	if [[ x"$mtime[${line%% *}]" == x"${line#* }" ]]; then
-	  #print up-to-date "${line%% *}"
-	else
-	  #print locally-modified "${line%% *}"
-	  entries=($entries "${line%% *}")
-	fi
-      done
-    fi
+    mtime=( ${(s:/:)${(j:/:)${${${${(M)${(f)Entries}:#/*}#/}%/*/*}/\\/*\\///}}} )
+    entries=( ${${${(M)${(f)Entries}:#D/*}#D/}%%/*} )
+    builtin stat -n +mtime -F '%a %b %e %T %Y' "$pref${(@k)^mtime}" |
+    while read line
+    do
+      line=${line#$pref}
+      if [[ x"$mtime[${line%% *}]" == x"${line#* }" ]]; then
+        #print up-to-date "${line%% *}"
+      else
+        #print locally-modified "${line%% *}"
+        entries=($entries "${line%% *}")
+      fi
+    done
   else
-    entries=( "${(@)${(@)${(@)${(f@)Entries}:#D}#(D|)/}%%/*}" )
+    entries=( ${${${${(f)Entries}:#D}#(D|)/}%%/*} )
   fi
 
   if (( $+OLDTZ )); then TZ="$OLDTZ"; else unset TZ; fi
@@ -210,7 +211,7 @@
 }
 
 _cvsrevisions () {
-  compadd - "${(@)${(@)${(@M)${(@f)$(cvs -q status -vl .)}:#	*}##[ 	]##}%%[ 	]*}"
+  compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:#	*}##[ 	]##}%%[ 	]*}
 }
 
 _cvsrepositories () {
@@ -222,7 +223,7 @@
   else
     compadd - \
       $root/^CVSROOT(:t) \
-      "${(@)${(@M)${(@f)$(<$root/CVSROOT/modules)}:#[^#]*}%%[ 	]*}"
+      ${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ 	]*}
   fi
 }
 


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author