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

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



In article <rsqpv1g2eyy.fsf@xxxxxxxxxxxxxxxxx>,
  Tanaka Akira <akr@xxxxxxxxxxx> writes:

> This refines it.

I found the problem with:
  cvs diff ~/xxx/<TAB>

I also tried to complete only modified files for commit and diff.
Since this use stat module, it does not works without dynamic loading by default.

--- Completion/User/_cvs-	Mon Jul 26 23:42:23 1999
+++ Completion/User/_cvs	Tue Jul 27 00:48:42 1999
@@ -37,10 +37,10 @@
       _complete_opts A '' N '' n '' k: "$complete_k" d: '' f '' l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" j: '' P '' || _cvsrepositories
       ;;
     commit|ci|com) # "+nlRm:fF:r:"
-      _complete_opts n '' l '' R '' m: "$complete_m" f '' F: '' r: "$complete_r" || _cvstargets
+      _complete_opts n '' l '' R '' m: "$complete_m" f '' F: '' r: "$complete_r" || _cvstargets_modified
       ;;
     diff|di|dif) # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:"
-      _complete_opts a '' b '' c '' d '' e '' f '' h '' i '' l '' n '' p '' s '' t '' u '' w '' 0 '' 1 '' 2 '' 3 '' 4 '' 5 '' 6 '' 7 '' 8 '' 9 '' B '' H '' N '' R '' C: '' D: "$complete_D" F: '' I: '' L: '' U: '' V: '' W: '' k: "$complete_k" r: "$complete_r" || _cvstargets
+      _complete_opts a '' b '' c '' d '' e '' f '' h '' i '' l '' n '' p '' s '' t '' u '' w '' 0 '' 1 '' 2 '' 3 '' 4 '' 5 '' 6 '' 7 '' 8 '' 9 '' B '' H '' N '' R '' C: '' D: "$complete_D" F: '' I: '' L: '' U: '' V: '' W: '' k: "$complete_k" r: "$complete_r" || _cvstargets_modified || _cvstargets
       ;;
     edit) # "+lRa:"
       _complete_opts l '' R '' a: '' || _cvstargets
--- Completion/User/_cvsaddp-	Mon Jul 26 23:42:24 1999
+++ Completion/User/_cvsaddp	Tue Jul 27 01:03:00 1999
@@ -1,6 +1,6 @@
 #autoload
 
-local pref entries
+local qpref pref entries
 _cvsprefix
 _cvsentries
 setopt localoptions unset
@@ -9,5 +9,5 @@
 omit=( $entries ${=cvsignore} )
 [[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
 [[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
-eval 'compadd -fp "$pref" - ${all:#('${(j:|:)omit}')}' ||
-  compadd -fp "$pref" - ${pref}*~${pref}CVS(/:t)
+eval 'compadd -fp "$qpref" -W "$pref" - ${all:#('${(j:|:)omit}')}' ||
+  compadd -fp "$qpref" -W "$pref" - ${pref}*~${pref}CVS(/:t)
--- /dev/null	Mon Jul 26 23:54:18 1999
+++ Completion/User/_cvsentries_modified	Tue Jul 27 01:06:39 1999
@@ -0,0 +1,31 @@
+#autoload
+
+local LANG=C
+local OLDTZ="$TZ"; if ! (( $+TZ )); then unset OLDTZ; fi; export TZ=GMT
+
+local line Entries
+typeset -A mtime
+
+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
+else
+  entries=( "${(@)${(@)${(@)${(f@)Entries}:#D}#(D|)/}%%/*}" )
+fi
+
+if (( $+OLDTZ )); then TZ="$OLDTZ"; else unset TZ; fi
--- Completion/User/_cvsprefix-	Mon Jul 26 23:42:24 1999
+++ Completion/User/_cvsprefix	Tue Jul 27 01:00:36 1999
@@ -1,16 +1,18 @@
 #autoload
 
 local f
-pref=$PREFIX
-if [[ $pref != */ ]]; then
-  if [[ $pref = */* ]]; then
-    pref=$pref:h
+qpref=$PREFIX
+if [[ $qpref != */ ]]; then
+  if [[ $qpref = */* ]]; then
+    qpref=$qpref:h
   else
-    pref=
+    qpref=
   fi
 fi
+pref=$~qpref
 if [[ ! -d "$pref" ]]; then
+  qpref=
   pref=
 fi
-[[ -n "$pref" && "$pref" != */ ]] && pref=$pref/
+[[ -n "$pref" && "$pref" != */ ]] && qpref=$qpref/ pref=$pref/
 
--- Completion/User/_cvsremovep-	Mon Jul 26 23:42:24 1999
+++ Completion/User/_cvsremovep	Tue Jul 27 01:03:06 1999
@@ -1,11 +1,11 @@
 #autoload
 
-local pref entries
+local qpref pref entries
 _cvsprefix
 _cvsentries
 setopt localoptions unset
 local omit
 omit=( ${pref}*(D:t) )
-eval 'compadd -fp "$pref" - ${entries:#('${(j:|:)omit}')}' ||
-  compadd -fp "$pref" - ${pref}*~${pref}CVS(/:t)
+eval 'compadd -fp "$qpref" -W "$pref" - ${entries:#('${(j:|:)omit}')}' ||
+  compadd -fp "$qpref" -W "$pref" - ${pref}*~${pref}CVS(/:t)
 
--- Completion/User/_cvstargets-	Mon Jul 26 23:42:24 1999
+++ Completion/User/_cvstargets	Tue Jul 27 01:02:21 1999
@@ -1,7 +1,7 @@
 #autoload
 
-local pref entries
+local qpref pref entries
 _cvsprefix
 _cvsentries
 
-compadd -fp "$pref" - $entries
+compadd -fP "$qpref" -W "$pref" - $entries
--- /dev/null	Mon Jul 26 23:54:18 1999
+++ Completion/User/_cvstargets_modified	Tue Jul 27 01:03:10 1999
@@ -0,0 +1,7 @@
+#autoload
+
+local qpref pref entries
+_cvsprefix
+_cvsentries_modified
+
+compadd -fp "$qpref" -W "$pref" - $entries
-- 
Tanaka Akira



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