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

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



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

> Although _cvsremovep has same problem too, this fix is not applicable
> because compgen -g does not generate nonexisting filenames.
> 
> Any ideas?

Hm. compset -P is bit dangerous for quoted characters.

is27e1u11% autoload -U compinit; compinit -D
is27e1u11% _tst () { compset -P '*/'; compadd tst }
is27e1u11% compdef _tst tst
is27e1u11% tst \#/<TAB>

Then, I get:

is27e1u11% tst \\\#/tst 

So, I removed compset -P from _cvs.

--- Completion/User/_cvs	Tue Jul 27 19:08:44 1999
+++ Completion/User/_cvs	Tue Jul 27 20:44:07 1999
@@ -196,6 +196,8 @@
   setopt localoptions nullglob unset
   if [[ -f ${pref}CVS/Entries ]]; then
     entries=( ${${${(M)${(f)"$(<${pref}CVS/Entries)"}:#D/*}#D/}%%/*} )
+  else
+    entries=()
   fi
 }
 
@@ -203,6 +205,8 @@
   setopt localoptions nullglob unset
   if [[ -f ${pref}CVS/Entries ]]; then
     entries=( ${${${${(f)"$(<${pref}CVS/Entries)"}:#D}#(D|)/}%%/*} )
+  else
+    entries=()
   fi
 }
 
@@ -213,6 +217,7 @@
     return
   fi
 
+  entries=()
   local line Entries
   typeset -A mtime
 
@@ -242,52 +247,59 @@
 _cvsdirs () {
   if [[ -d ${pref}CVS ]]; then
     _cvsdirentries
-    compadd -fW "$pref" - $entries
+    if (( $#entries )); then
+      compgen "$@" -g '('${(j:|:)entries:q}')'
+    fi
   else
-    _files -W "$pref"
+    _files
   fi
 }
 
 _cvstargets () {
   local qpref pref entries
-  _cvsprefix; compset -P '*/'
+  _cvsprefix
   if [[ -d ${pref}CVS ]]; then
     _cvsentries
-    compgen -W "$pref" -g "(${(j:|:)entries})"
+    if (( $#entries )); then
+      compgen -g '('${(j:|:)entries:q}')'
+    fi
   else
-    _files -W "$pref"
+    _files
   fi
 }
 
 _cvstargets_modified () {
   local qpref pref entries
-  _cvsprefix; compset -P '*/'
+  _cvsprefix
   if [[ -d ${pref}CVS ]]; then
     _cvsentries_modified
-    compgen -W "$pref" -g "(${(j:|:)entries})"
+    if (( $#entries )); then
+      compgen -g '('${(j:|:)entries:q}')'
+    fi
   else
-    _files -W "$pref"
+    _files 
   fi
 }
 
 _cvsremovep () {
   local qpref pref entries
-  _cvsprefix; compset -P '*/'
+  _cvsprefix
   if [[ -d ${pref}CVS ]]; then
     _cvsentries
     setopt localoptions unset
     local omit
     omit=( ${pref}*(D:t) )
-    eval 'compadd -fW "$pref" - ${entries:#('${(j:|:)omit}')}' ||
+    eval 'entries=( ${entries:#('${(j:|:)omit:q}')} )'
+    compadd -P "$qpref" - ${entries:q} ||
     _cvsdirs
   else
-    _files -W "$pref"
+    _files
   fi
 }
 
 _cvsaddp () {
   local qpref pref entries
-  _cvsprefix; compset -P '*/'
+  _cvsprefix
   if [[ -d ${pref}CVS ]]; then
     _cvsentries
     setopt localoptions unset
@@ -296,10 +308,10 @@
     omit=( CVS $entries ${=cvsignore} )
     [[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
     [[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
-    compgen -W "$pref" -g "*~*/(${(j:|:)omit})" ||
-    _cvsdirs
+    compgen -g '*~(*/|)('${(j:|:)omit:q}')' ||
+    { _cvsdirentries; compgen -g '('${(j:|:)entries:q}')' }
   else
-    _files -W "$pref"
+    _files
   fi
 }
 
-- 
Tanaka Akira



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