* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
@ 1999-07-21 11:27 Sven Wischnowsky
1999-07-21 12:35 ` Tanaka Akira
1999-07-21 15:54 ` Bart Schaefer
0 siblings, 2 replies; 20+ messages in thread
From: Sven Wischnowsky @ 1999-07-21 11:27 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> Below is an improved version of Tanaka's _cvs completer.
Below is this in slightly modified form as a patch (I guess Peter
already put it into files). Note, however, that I put `_complete_opts'
into Base -- seems reasonable to put it in the directory where
_long_options is, doesn't it?
I mainly changed `compgen -f' to `_files' and `compgen -/' to `_files -/'
and tweaked `_complete_opts' a bit so that `cvs ann -D<TAB>' doesn't
give you `cvs ann -D-'.
Some questions:
- (Bart already marked this) what should the compgen -k '()' do?
- And even with that in place: the `_complete_opts || _files' should
be reduced to `_files', right? (Unless the `compgen' really should
add something -- so I've not changed that, yet.)
Bye
Sven
diff -u -r oc/Base/_complete_opts Completion/Base/_complete_opts
--- oc/Base/_complete_opts Wed Jul 21 13:14:54 1999
+++ Completion/Base/_complete_opts Wed Jul 21 13:15:40 1999
@@ -0,0 +1,88 @@
+#autoload
+
+# Usage:
+# _complete_opts H '' f '_files'
+
+emulate -L zsh
+setopt extendedglob
+
+local done=yes
+
+typeset -A option_pairs
+option_pairs=("$@")
+typeset -a no_arg with_arg opt_arg
+no_arg=($option_pairs[(I)?])
+opt_arg=($option_pairs[(I)?::]:s/:://)
+with_arg=($option_pairs[(I)?:]:s/:// $opt_arg)
+
+case "${#no_arg}-${#with_arg}" in
+ 0-0)
+ if [[ x$PREFIX = x-* ]]; then
+ compgen -k '()' # What does this accomplish?
+ else
+ done=''
+ fi
+ ;;
+
+ 0-*)
+ if [[ x$PREFIX = x- ]]; then
+ IPREFIX="$IPREFIX$PREFIX"
+ PREFIX=
+ compadd $with_arg
+ elif [[ x$PREFIX = x-[${(j::)with_arg}] ]]; then
+ IPREFIX="$IPREFIX$PREFIX"
+ PREFIX=
+ eval $option_pairs[$IPREFIX[-1]:]
+ elif [[ x$PREFIX = x-[${(j::)with_arg}]* ]]; then
+ local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
+ IPREFIX="$IPREFIX$p"
+ PREFIX="$PREFIX[$#p + 1,-1]"
+ eval $option_pairs[$IPREFIX[-1]:]
+ elif [[ x$words[$CURRENT-1] = x-[${(j::)with_arg}] ]]; then
+ local p="$words[$CURRENT - 1]"
+ eval $option_pairs[$p[-1]:]
+ else
+ done=''
+ fi
+ ;;
+
+ *-0)
+ if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
+ IPREFIX="$IPREFIX$PREFIX"
+ PREFIX=
+ compadd $no_arg
+ else
+ done=''
+ fi
+ ;;
+
+ *-*)
+ if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
+ IPREFIX="$IPREFIX$PREFIX"
+ PREFIX=
+ compadd $no_arg
+ compadd $with_arg
+ elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
+ IPREFIX="$IPREFIX$PREFIX"
+ PREFIX=
+ eval $option_pairs[$IPREFIX[-1]:]
+ elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}]* ]]; then
+ local p="$PREFIX[1,(r)[${(j::)with_arg}]]"
+ IPREFIX="$IPREFIX$p"
+ PREFIX="$PREFIX[$#p + 1,-1]"
+ eval $option_pairs[$IPREFIX[-1]:]
+ elif [[ x$words[$CURRENT-1] = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
+ local p="$words[$CURRENT - 1]"
+ eval $option_pairs[$p[-1]:]
+ else
+ done=''
+ fi
+ ;;
+esac
+
+if [[ -z "$done" ]]; then
+ compadd - -${(k)^option_pairs:gs/://}
+ false
+else
+ true
+fi
diff -u -r oc/User/_cvs Completion/User/_cvs
--- oc/User/_cvs Wed Jul 21 13:14:47 1999
+++ Completion/User/_cvs Wed Jul 21 13:14:33 1999
@@ -0,0 +1,134 @@
+#compdef cvs
+
+typeset -A commands
+commands=(add "ad new" admin "adm rcs" annotate ann
+ checkout "co get" commit "ci com" diff "di dif"
+ edit "" editors "" export "exp ex"
+ history "hi his" import "im imp" init ""
+ log "lo rlog" login "logon lgn" logout ""
+ rdiff patch release "re rel" remove "rm delete"
+ status "st stat" rtag "rt rfreeze" tag "ta freeze"
+ unedit "" update "up upd" watch ""
+ watchers "")
+
+local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
+
+local showlist='compstate[list]=list; compstate[force_list]=yes'
+local showhint="$showlist ; compstate[insert]=''"
+local complete_D="compadd yesterday week\\ ago month\\ ago"
+local complete_k="compadd kv kvl k o b v"
+local complete_r="compadd -UX 'Enter tag name or rev number' ''; $showhint"
+local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
+
+
+if (( com < CURRENT )); then
+ case "$words[$com]" in
+ add|ad|new) # "+k:m:"
+ _complete_opts k: "$complete_k" m: "$complete_m" || _files
+ ;;
+ admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
+ _complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' V: '' k: "$complete_k" || _files
+ ;;
+ annotate|ann) # "+lr:D:fR"
+ _complete_opts l '' r: '' D: '' f '' R '' || _files
+ ;;
+ checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
+ _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 '' || compadd MODULE
+ ;;
+ commit|ci|com) # "+nlRm:fF:r:"
+ _complete_opts n '' l '' R '' m: "$complete_m" f '' F: '' r: "$complete_r" || _files
+ ;;
+ 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" || _files
+ ;;
+ edit) # "+lRa:"
+ _complete_opts l '' R '' a: '' || _files
+ ;;
+ editors) # "+lR"
+ _complete_opts l '' R '' || _files
+ ;;
+ export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
+ _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 '' || compadd MODULE
+ ;;
+ history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
+ _complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '' || _files
+ ;;
+ import|im|imp) # "+Qqdb:m:I:k:W:"
+ _complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' k: "$complete_k" W: '' || case $[CURRENT-com] in
+ 1) compgen -X "Enter repository name" -W $CVSROOT -g '*~*CVSROOT(/)' -s '';;
+ 2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
+ 3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
+ *) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
+ esac
+ ;;
+ init)
+ break
+ ;;
+ login|logon|lgn|logout)
+ _complete_opts || _files
+ ;;
+ rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
+ _complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r" || _files
+ ;;
+ release|re|rel) # "+Qdq"
+ _complete_opts Q '' d '' q '' || _files -/
+ ;;
+ remove|rm|delete) # "+flR"
+ _complete_opts f '' l '' R '' || _files
+ ;;
+ status|st|stat) # "+vlR"
+ _complete_opts v '' l '' R '' || _files
+ ;;
+ tag|ta|freeze) # "+FQqlRcdr:D:bf"
+ _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || _files
+ ;;
+ unedit) # "+lR"
+ _complete_opts l '' R '' || _files
+ ;;
+ update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
+ _complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '' || _files
+ ;;
+ watch)
+ if (( CURRENT == com + 1 )); then
+ compadd on off add remove
+ else
+ case "$words[com+1]" in
+ on|off) # "+lR"
+ _complete_opts l '' R '' || _files
+ ;;
+ add|remove) # "+lRa:"
+ _complete_opts l '' R '' a: '' || _files
+ ;;
+ esac
+ fi
+ ;;
+ watchers) # "+lR"
+ _complete_opts l '' R '' || _files
+ ;;
+ *) _files;;
+ esac
+ return
+fi
+
+case ${+cvs_roots} in
+ 0)
+ cvs_roots=()
+ if [[ -f ~/.cvspass ]]; then
+ cvs_roots=(
+ $(cut -d ' ' -f 1 ~/.cvspass)
+ )
+ fi
+ ;;
+esac
+
+_complete_opts \
+ H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
+ b: "compadd /usr/local/bin" \
+ T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
+ e: "compadd vi" \
+ d: "compadd $cvs_roots || _files -/" \
+ z: "compadd 9'" \
+ s: "_cvs_user_variable" \
+ ||
+compadd ${(k)commands} ||
+compadd ${(kv)=commands}
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-21 11:27 CVS completer (Re: PATCH: Re: Completion/User functions again) Sven Wischnowsky
@ 1999-07-21 12:35 ` Tanaka Akira
1999-07-21 15:43 ` Tanaka Akira
1999-07-21 15:54 ` Bart Schaefer
1 sibling, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-21 12:35 UTC (permalink / raw)
To: zsh-workers
In article <199907211127.NAA02895@beta.informatik.hu-berlin.de>,
Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:
> I mainly changed `compgen -f' to `_files' and `compgen -/' to `_files -/'
> and tweaked `_complete_opts' a bit so that `cvs ann -D<TAB>' doesn't
> give you `cvs ann -D-'.
I didn't know _files in those days...
> Some questions:
> - (Bart already marked this) what should the compgen -k '()' do?
Hm. I cannot remember the purpose of it.
I guess that I wanted to complete a space after an argument. Of
course, since it does not works as such behaviour, it should be fixed.
I think it should be replaced by 'compadd "$PREFIX"'.
> - And even with that in place: the `_complete_opts || _files' should
> be reduced to `_files', right? (Unless the `compgen' really should
> add something -- so I've not changed that, yet.)
Since cvs login and cvs logout does not take any argument, it may be
reduced to ':'.
However, I like completing files if there is no suitable completion.
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-21 12:35 ` Tanaka Akira
@ 1999-07-21 15:43 ` Tanaka Akira
0 siblings, 0 replies; 20+ messages in thread
From: Tanaka Akira @ 1999-07-21 15:43 UTC (permalink / raw)
To: zsh-workers
In article <rsqiu7efafd.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> writes:
> I think it should be replaced by 'compadd "$PREFIX"'.
The patch is follows.
Also, I modified the completer for "cvs import" not to generate an
error without CVSROOT.
--- Completion/User/_cvs- Wed Jul 21 23:58:01 1999
+++ Completion/User/_cvs Thu Jul 22 00:08:46 1999
@@ -1,5 +1,7 @@
#compdef cvs
+setopt localoptions extendedglob
+
typeset -A commands
commands=(add "ad new" admin "adm rcs" annotate ann
checkout "co get" commit "ci com" diff "di dif"
@@ -55,7 +57,12 @@
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
_complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' k: "$complete_k" W: '' || case $[CURRENT-com] in
- 1) compgen -X "Enter repository name" -W $CVSROOT -g '*~*CVSROOT(/)' -s '';;
+ 1) if [[ "${+CVSROOT}" == 1 && "$CVSROOT" != :* ]]; then
+ compgen -X "Enter repository name" -W "$CVSROOT" -g '*~*CVSROOT(/)' -s ''
+ else
+ compadd -UX "Enter repository name" -n '' && eval "$showhint"
+ fi
+ ;;
2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
*) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
--- Completion/Base/_complete_opts- Thu Jul 22 00:32:33 1999
+++ Completion/Base/_complete_opts Thu Jul 22 00:33:03 1999
@@ -18,7 +18,7 @@
case "${#no_arg}-${#with_arg}" in
0-0)
if [[ x$PREFIX = x-* ]]; then
- compgen -k '()' # What does this accomplish?
+ compadd - "$PREFIX"
else
done=''
fi
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-21 11:27 CVS completer (Re: PATCH: Re: Completion/User functions again) Sven Wischnowsky
1999-07-21 12:35 ` Tanaka Akira
@ 1999-07-21 15:54 ` Bart Schaefer
1999-07-25 9:23 ` Tanaka Akira
1 sibling, 1 reply; 20+ messages in thread
From: Bart Schaefer @ 1999-07-21 15:54 UTC (permalink / raw)
To: zsh-workers
On Jul 21, 1:27pm, Sven Wischnowsky wrote:
} Subject: Re: CVS completer (Re: PATCH: Re: Completion/User functions again
}
} I mainly changed `compgen -f' to `_files' and `compgen -/' to `_files -/'
} and tweaked `_complete_opts' a bit so that `cvs ann -D<TAB>' doesn't
} give you `cvs ann -D-'.
Probably a list of what's still not quite right about _complete_opts should
be included in the comment at the top of it; and the usage comment should
mention that one trailing : means a required argument, two trailing : mean
an optional one, as per the latest GNU getopts.
Finally, in that vein, something ought to be done with $opt_arg besides just
including it in $with_arg. The 'case "${#no_arg}-${#with_arg}" in' is an
interesting optimization, but I'm not sure it covers all the cases.
} Some questions:
} - And even with that in place: the `_complete_opts || _files' should
} be reduced to `_files', right?
Yes, but again most of the _files should be changed to something that can
interpret CVS/Entries.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-21 15:54 ` Bart Schaefer
@ 1999-07-25 9:23 ` Tanaka Akira
1999-07-25 11:38 ` Tanaka Akira
1999-07-26 4:48 ` Tanaka Akira
0 siblings, 2 replies; 20+ messages in thread
From: Tanaka Akira @ 1999-07-25 9:23 UTC (permalink / raw)
To: zsh-workers
In article <990721155446.ZM6856@candle.brasslantern.com>,
"Bart Schaefer" <schaefer@candle.brasslantern.com> writes:
> Yes, but again most of the _files should be changed to something that can
> interpret CVS/Entries.
This patch do it.
Most of codes to handle CVS/* are taken from Misc/compctl-examples.
--- Completion/User/_cvs- Sat Jul 24 22:59:54 1999
+++ Completion/User/_cvs Sun Jul 25 18:13:11 1999
@@ -17,52 +17,46 @@
local showlist='compstate[list]=list; compstate[force_list]=yes'
local showhint="$showlist ; compstate[insert]=''"
-local complete_D="compadd yesterday week\\ ago month\\ ago"
+local complete_D="compadd today yesterday week\\ ago month\\ ago"
local complete_k="compadd kv kvl k o b v"
-local complete_r="compadd -UX 'Enter tag name or rev number' ''; $showhint"
+local complete_r="_cvsrevisions"
local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
-
if (( com < CURRENT )); then
case "$words[$com]" in
add|ad|new) # "+k:m:"
- _complete_opts k: "$complete_k" m: "$complete_m" || _files
+ _complete_opts k: "$complete_k" m: "$complete_m" || _cvsaddp
;;
admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
- _complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' V: '' k: "$complete_k" || _files
+ _complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' V: '' k: "$complete_k" || _cvstargets
;;
annotate|ann) # "+lr:D:fR"
- _complete_opts l '' r: '' D: '' f '' R '' || _files
+ _complete_opts l '' r: '' D: '' f '' R '' || _cvstargets
;;
checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
- _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 '' || compadd MODULE
+ _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" || _files
+ _complete_opts n '' l '' R '' m: "$complete_m" f '' F: '' r: "$complete_r" || _cvstargets
;;
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" || _files
+ _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
;;
edit) # "+lRa:"
- _complete_opts l '' R '' a: '' || _files
+ _complete_opts l '' R '' a: '' || _cvstargets
;;
editors) # "+lR"
- _complete_opts l '' R '' || _files
+ _complete_opts l '' R '' || _cvstargets
;;
export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
- _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 '' || compadd MODULE
+ _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
;;
history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
- _complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '' || _files
+ _complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '' || _cvstargets
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
_complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' k: "$complete_k" W: '' || case $[CURRENT-com] in
- 1) if [[ "${+CVSROOT}" == 1 && "$CVSROOT" != :* ]]; then
- compgen -X "Enter repository name" -W "$CVSROOT" -g '*~*CVSROOT(/)' -s ''
- else
- compadd -UX "Enter repository name" -n '' && eval "$showhint"
- fi
- ;;
+ 1) _cvsrepositories;;
2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
*) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
@@ -75,25 +69,25 @@
_complete_opts || _files
;;
rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
- _complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r" || _files
+ _complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r" || _cvstargets
;;
release|re|rel) # "+Qdq"
_complete_opts Q '' d '' q '' || _files -/
;;
remove|rm|delete) # "+flR"
- _complete_opts f '' l '' R '' || _files
+ _complete_opts f '' l '' R '' || _cvsremovep
;;
status|st|stat) # "+vlR"
- _complete_opts v '' l '' R '' || _files
+ _complete_opts v '' l '' R '' || _cvstargets
;;
tag|ta|freeze) # "+FQqlRcdr:D:bf"
- _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || _files
+ _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || _cvstargets
;;
unedit) # "+lR"
- _complete_opts l '' R '' || _files
+ _complete_opts l '' R '' || _cvstargets
;;
update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
- _complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '' || _files
+ _complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '' || _cvstargets
;;
watch)
if (( CURRENT == com + 1 )); then
@@ -101,16 +95,16 @@
else
case "$words[com+1]" in
on|off) # "+lR"
- _complete_opts l '' R '' || _files
+ _complete_opts l '' R '' || _cvstargets
;;
add|remove) # "+lRa:"
- _complete_opts l '' R '' a: '' || _files
+ _complete_opts l '' R '' a: '' || _cvstargets
;;
esac
fi
;;
watchers) # "+lR"
- _complete_opts l '' R '' || _files
+ _complete_opts l '' R '' || _cvstargets
;;
*) _files;;
esac
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvsaddp Sun Jul 25 18:13:11 1999
@@ -0,0 +1,12 @@
+#autoload
+
+local pref entries
+_cvsprefix
+_cvsentries
+setopt localoptions unset
+local all omit
+all=( ${pref}*(D) )
+omit=( $entries ${pref}${^${=cvsignore}} )
+[[ -r ~/.cvsignore ]] && omit=( $omit ${pref}${^$(<~/.cvsignore)} )
+[[ -r ${pref}.cvsignore ]] && omit=( $omit ${pref}${^$(<${pref}.cvsignore)} )
+eval 'compadd - ${all:#('${(j:|:)omit}')}'
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvsentries Sun Jul 25 18:13:11 1999
@@ -0,0 +1,7 @@
+#autoload
+
+setopt localoptions nullglob unset
+if [[ -f ${pref}CVS/Entries ]]; then
+ entries=( "${pref}${(@)^${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
+fi
+
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvsprefix Sun Jul 25 18:13:11 1999
@@ -0,0 +1,11 @@
+#autoload
+
+local f
+pref=$PREFIX
+if [[ -d $pref:h && ! -d $pref ]]; then
+ pref=$pref:h
+elif [[ $pref != */* ]]; then
+ pref=
+fi
+[[ -n "$pref" && "$pref" != */ ]] && pref=$pref/
+
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvsremovep Sun Jul 25 18:13:11 1999
@@ -0,0 +1,9 @@
+#autoload
+
+local pref entries
+_cvsprefix
+_cvsentries
+setopt localoptions unset
+local omit
+omit=( ${pref}*(D) )
+eval 'compadd - ${entries:#('${(j:|:)omit}')}'
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvsrepositories Sun Jul 25 18:13:11 1999
@@ -0,0 +1,12 @@
+#autoload
+
+local root=$CVSROOT
+[[ -f CVS/Root ]] && root=$(<CVS/Root)
+
+if [[ $root = :* || ! -d $root ]]; then
+ compadd -UX "Enter repository name" -n '' && { compstate[list]=list; compstate[force_list]=yes; compstate[insert]='' }
+else
+ compadd - \
+ $root/^CVSROOT(:t) \
+ "${(@)${(@M)${(@f)$(<$root/CVSROOT/modules)}:#[^#]*}%%[ ]*}"
+fi
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvsrevisions Sun Jul 25 18:13:11 1999
@@ -0,0 +1,3 @@
+#autoload
+
+compadd - "${(@)${(@)${(@M)${(@f)$(cvs -q status -vl .)}:# *}##[ ]##}%%[ ]*}"
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvstargets Sun Jul 25 18:13:11 1999
@@ -0,0 +1,9 @@
+#autoload
+
+local pref entries
+_cvsprefix
+_cvsentries
+
+compadd - $entries
+
+compgen -g "^CVS(/)"
--- /dev/null Sun Jul 25 17:58:12 1999
+++ Completion/User/_cvstest Sun Jul 25 18:13:11 1999
@@ -0,0 +1,3 @@
+#compdef cvstest
+
+_cvstargets
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-25 9:23 ` Tanaka Akira
@ 1999-07-25 11:38 ` Tanaka Akira
1999-07-26 4:48 ` Tanaka Akira
1 sibling, 0 replies; 20+ messages in thread
From: Tanaka Akira @ 1999-07-25 11:38 UTC (permalink / raw)
To: zsh-workers
In article <rsqvhb9ulqj.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> writes:
> Most of codes to handle CVS/* are taken from Misc/compctl-examples.
Probably, this is a bug fix though I don't understand rules for array
variable expansion completely.
--- Misc/compctl-examples- Sun Jul 25 20:34:56 1999
+++ Misc/compctl-examples Sun Jul 25 20:35:06 1999
@@ -563,7 +563,7 @@
cvsentries() {
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
- reply=( "${pref}${^${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
+ reply=( "${pref}${(@)^${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
fi
}
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-25 9:23 ` Tanaka Akira
1999-07-25 11:38 ` Tanaka Akira
@ 1999-07-26 4:48 ` Tanaka Akira
1999-07-26 16:26 ` Tanaka Akira
1 sibling, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-26 4:48 UTC (permalink / raw)
To: zsh-workers
In article <rsqvhb9ulqj.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> writes:
> Most of codes to handle CVS/* are taken from Misc/compctl-examples.
This refines it.
--- Completion/User/_cvsaddp- Mon Jul 26 13:43:26 1999
+++ Completion/User/_cvsaddp Mon Jul 26 13:43:42 1999
@@ -5,8 +5,9 @@
_cvsentries
setopt localoptions unset
local all omit
-all=( ${pref}*(D) )
-omit=( $entries ${pref}${^${=cvsignore}} )
-[[ -r ~/.cvsignore ]] && omit=( $omit ${pref}${^$(<~/.cvsignore)} )
-[[ -r ${pref}.cvsignore ]] && omit=( $omit ${pref}${^$(<${pref}.cvsignore)} )
-eval 'compadd - ${all:#('${(j:|:)omit}')}'
+all=( ${pref}*~${pref}CVS(D:t) )
+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)
--- Completion/User/_cvsentries- Mon Jul 26 13:43:26 1999
+++ Completion/User/_cvsentries Mon Jul 26 13:43:42 1999
@@ -2,6 +2,6 @@
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
- entries=( "${pref}${(@)^${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
+ entries=( "${(@)${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D}#(D|)/}%%/*}" )
fi
--- Completion/User/_cvsprefix- Mon Jul 26 13:43:27 1999
+++ Completion/User/_cvsprefix Mon Jul 26 13:43:42 1999
@@ -2,10 +2,15 @@
local f
pref=$PREFIX
-if [[ -d $pref:h && ! -d $pref ]]; then
+if [[ $pref != */ ]]; then
+ if [[ $pref = */* ]]; then
pref=$pref:h
-elif [[ $pref != */* ]]; then
+ else
pref=
+ fi
+fi
+if [[ ! -d "$pref" ]]; then
+ pref=
fi
[[ -n "$pref" && "$pref" != */ ]] && pref=$pref/
--- Completion/User/_cvsremovep- Mon Jul 26 13:43:27 1999
+++ Completion/User/_cvsremovep Mon Jul 26 13:43:42 1999
@@ -5,5 +5,7 @@
_cvsentries
setopt localoptions unset
local omit
-omit=( ${pref}*(D) )
-eval 'compadd - ${entries:#('${(j:|:)omit}')}'
+omit=( ${pref}*(D:t) )
+eval 'compadd -fp "$pref" - ${entries:#('${(j:|:)omit}')}' ||
+ compadd -fp "$pref" - ${pref}*~${pref}CVS(/:t)
+
--- Completion/User/_cvstargets- Mon Jul 26 13:43:27 1999
+++ Completion/User/_cvstargets Mon Jul 26 13:43:42 1999
@@ -4,6 +4,4 @@
_cvsprefix
_cvsentries
-compadd - $entries
-
-compgen -g "^CVS(/)"
+compadd -fp "$pref" - $entries
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-26 4:48 ` Tanaka Akira
@ 1999-07-26 16:26 ` Tanaka Akira
1999-07-26 17:10 ` Tanaka Akira
0 siblings, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-26 16:26 UTC (permalink / raw)
To: zsh-workers
In article <rsqpv1g2eyy.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-26 16:26 ` Tanaka Akira
@ 1999-07-26 17:10 ` Tanaka Akira
1999-07-27 7:48 ` PATCH: " Bart Schaefer
1999-07-27 8:15 ` Peter Stephenson
0 siblings, 2 replies; 20+ messages in thread
From: Tanaka Akira @ 1999-07-26 17:10 UTC (permalink / raw)
To: zsh-workers
In article <rsq4sirs7hf.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> writes:
> 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.
I think _cvs* are only for cvs, there is no necessity to make these
autoloadable except _cvs.
diff -Naur Completion/User/_cvs Completion/User/_cvs
--- Completion/User/_cvs Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvs Mon Jul 26 16:57:05 1999
@@ -1,135 +1,254 @@
#compdef cvs
-setopt localoptions extendedglob
+_cvs () {
+ setopt localoptions extendedglob
-typeset -A commands
-commands=(add "ad new" admin "adm rcs" annotate ann
- checkout "co get" commit "ci com" diff "di dif"
- edit "" editors "" export "exp ex"
- history "hi his" import "im imp" init ""
- log "lo rlog" login "logon lgn" logout ""
- rdiff patch release "re rel" remove "rm delete"
- status "st stat" rtag "rt rfreeze" tag "ta freeze"
- unedit "" update "up upd" watch ""
- watchers "")
-
-local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
-
-local showlist='compstate[list]=list; compstate[force_list]=yes'
-local showhint="$showlist ; compstate[insert]=''"
-local complete_D="compadd today yesterday week\\ ago month\\ ago"
-local complete_k="compadd kv kvl k o b v"
-local complete_r="_cvsrevisions"
-local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
-
-if (( com < CURRENT )); then
- case "$words[$com]" in
- add|ad|new) # "+k:m:"
- _complete_opts k: "$complete_k" m: "$complete_m" || _cvsaddp
- ;;
- admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
- _complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' V: '' k: "$complete_k" || _cvstargets
- ;;
- annotate|ann) # "+lr:D:fR"
- _complete_opts l '' r: '' D: '' f '' R '' || _cvstargets
- ;;
- checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
- _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_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_modified || _cvstargets
- ;;
- edit) # "+lRa:"
- _complete_opts l '' R '' a: '' || _cvstargets
- ;;
- editors) # "+lR"
- _complete_opts l '' R '' || _cvstargets
- ;;
- export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
- _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
- ;;
- history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
- _complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '' || _cvstargets
- ;;
- import|im|imp) # "+Qqdb:m:I:k:W:"
- _complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' k: "$complete_k" W: '' || case $[CURRENT-com] in
- 1) _cvsrepositories;;
- 2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
- 3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
- *) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
- esac
- ;;
- init)
- break
- ;;
- login|logon|lgn|logout)
- _complete_opts || _files
- ;;
- rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
- _complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r" || _cvstargets
- ;;
- release|re|rel) # "+Qdq"
- _complete_opts Q '' d '' q '' || _files -/
- ;;
- remove|rm|delete) # "+flR"
- _complete_opts f '' l '' R '' || _cvsremovep
- ;;
- status|st|stat) # "+vlR"
- _complete_opts v '' l '' R '' || _cvstargets
- ;;
- tag|ta|freeze) # "+FQqlRcdr:D:bf"
- _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || _cvstargets
- ;;
- unedit) # "+lR"
- _complete_opts l '' R '' || _cvstargets
- ;;
- update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
- _complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '' || _cvstargets
- ;;
- watch)
- if (( CURRENT == com + 1 )); then
- compadd on off add remove
- else
- case "$words[com+1]" in
- on|off) # "+lR"
- _complete_opts l '' R '' || _cvstargets
- ;;
- add|remove) # "+lRa:"
- _complete_opts l '' R '' a: '' || _cvstargets
- ;;
- esac
+ typeset -A commands
+ commands=(add "ad new" admin "adm rcs" annotate ann
+ checkout "co get" commit "ci com" diff "di dif"
+ edit "" editors "" export "exp ex"
+ history "hi his" import "im imp" init ""
+ log "lo rlog" login "logon lgn" logout ""
+ rdiff patch release "re rel" remove "rm delete"
+ status "st stat" rtag "rt rfreeze" tag "ta freeze"
+ unedit "" update "up upd" watch ""
+ watchers "")
+
+ local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
+
+ local showlist='compstate[list]=list; compstate[force_list]=yes'
+ local showhint="$showlist ; compstate[insert]=''"
+ local complete_D="compadd today yesterday week\\ ago month\\ ago"
+ local complete_k="compadd kv kvl k o b v"
+ local complete_r="_cvsrevisions"
+ local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
+
+ if (( com < CURRENT )); then
+ case "$words[$com]" in
+ add|ad|new) # "+k:m:"
+ _complete_opts k: "$complete_k" m: "$complete_m" || _cvsaddp
+ ;;
+ admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
+ _complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' V: '' k: "$complete_k" || _cvstargets
+ ;;
+ annotate|ann) # "+lr:D:fR"
+ _complete_opts l '' r: '' D: '' f '' R '' || _cvstargets
+ ;;
+ checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
+ _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_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_modified || _cvstargets
+ ;;
+ edit) # "+lRa:"
+ _complete_opts l '' R '' a: '' || _cvstargets
+ ;;
+ editors) # "+lR"
+ _complete_opts l '' R '' || _cvstargets
+ ;;
+ export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
+ _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
+ ;;
+ history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
+ _complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '' || _cvstargets
+ ;;
+ import|im|imp) # "+Qqdb:m:I:k:W:"
+ _complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' k: "$complete_k" W: '' || case $[CURRENT-com] in
+ 1) _cvsrepositories;;
+ 2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
+ 3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
+ *) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
+ esac
+ ;;
+ init)
+ break
+ ;;
+ login|logon|lgn|logout)
+ _complete_opts || _files
+ ;;
+ rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
+ _complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r" || _cvstargets
+ ;;
+ release|re|rel) # "+Qdq"
+ _complete_opts Q '' d '' q '' || _files -/
+ ;;
+ remove|rm|delete) # "+flR"
+ _complete_opts f '' l '' R '' || _cvsremovep
+ ;;
+ status|st|stat) # "+vlR"
+ _complete_opts v '' l '' R '' || _cvstargets
+ ;;
+ tag|ta|freeze) # "+FQqlRcdr:D:bf"
+ _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || _cvstargets
+ ;;
+ unedit) # "+lR"
+ _complete_opts l '' R '' || _cvstargets
+ ;;
+ update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
+ _complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '' || _cvstargets
+ ;;
+ watch)
+ if (( CURRENT == com + 1 )); then
+ compadd on off add remove
+ else
+ case "$words[com+1]" in
+ on|off) # "+lR"
+ _complete_opts l '' R '' || _cvstargets
+ ;;
+ add|remove) # "+lRa:"
+ _complete_opts l '' R '' a: '' || _cvstargets
+ ;;
+ esac
+ fi
+ ;;
+ watchers) # "+lR"
+ _complete_opts l '' R '' || _cvstargets
+ ;;
+ *) _files;;
+ esac
+ return
+ fi
+
+ case ${+cvs_roots} in
+ 0)
+ cvs_roots=()
+ if [[ -f ~/.cvspass ]]; then
+ cvs_roots=(
+ $(cut -d ' ' -f 1 ~/.cvspass)
+ )
fi
;;
- watchers) # "+lR"
- _complete_opts l '' R '' || _cvstargets
- ;;
- *) _files;;
esac
- return
-fi
-case ${+cvs_roots} in
- 0)
- cvs_roots=()
- if [[ -f ~/.cvspass ]]; then
- cvs_roots=(
- $(cut -d ' ' -f 1 ~/.cvspass)
- )
+ _complete_opts \
+ H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
+ b: "compadd /usr/local/bin" \
+ T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
+ e: "compadd vi" \
+ d: "compadd $cvs_roots || _files -/" \
+ z: "compadd 9'" \
+ s: "_cvs_user_variable" \
+ ||
+ compadd ${(k)commands} ||
+ compadd ${(kv)=commands}
+}
+
+_cvsprefix () {
+ local f
+ qpref=$PREFIX
+ if [[ $qpref != */ ]]; then
+ if [[ $qpref = */* ]]; then
+ qpref=$qpref:h
+ else
+ qpref=
+ fi
+ fi
+ pref=$~qpref
+ if [[ ! -d "$pref" ]]; then
+ qpref=
+ pref=
+ fi
+ [[ -n "$pref" && "$pref" != */ ]] && qpref=$qpref/ pref=$pref/
+}
+
+_cvsentries () {
+ setopt localoptions nullglob unset
+ if [[ -f ${pref}CVS/Entries ]]; then
+ entries=( "${(@)${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D}#(D|)/}%%/*}" )
+ fi
+}
+
+_cvsentries_modified () {
+ 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
- ;;
-esac
+ else
+ entries=( "${(@)${(@)${(@)${(f@)Entries}:#D}#(D|)/}%%/*}" )
+ fi
+
+ if (( $+OLDTZ )); then TZ="$OLDTZ"; else unset TZ; fi
+}
+
+_cvstargets () {
+ local qpref pref entries
+ _cvsprefix
+ _cvsentries
+
+ compadd -fP "$qpref" -W "$pref" - $entries
+}
+
+_cvstargets_modified () {
+ local qpref pref entries
+ _cvsprefix
+ _cvsentries_modified
+
+ compadd -fp "$qpref" -W "$pref" - $entries
+}
+
+_cvsrevisions () {
+ compadd - "${(@)${(@)${(@M)${(@f)$(cvs -q status -vl .)}:# *}##[ ]##}%%[ ]*}"
+}
+
+_cvsrepositories () {
+ local root=$CVSROOT
+ [[ -f CVS/Root ]] && root=$(<CVS/Root)
+
+ if [[ $root = :* || ! -d $root ]]; then
+ compadd -UX "Enter repository name" -n '' && { compstate[list]=list; compstate[force_list]=yes; compstate[insert]='' }
+ else
+ compadd - \
+ $root/^CVSROOT(:t) \
+ "${(@)${(@M)${(@f)$(<$root/CVSROOT/modules)}:#[^#]*}%%[ ]*}"
+ fi
+}
+
+_cvsremovep () {
+ local qpref pref entries
+ _cvsprefix
+ _cvsentries
+ setopt localoptions unset
+ local omit
+ omit=( ${pref}*(D:t) )
+ eval 'compadd -fp "$qpref" -W "$pref" - ${entries:#('${(j:|:)omit}')}' ||
+ compadd -fp "$qpref" -W "$pref" - ${pref}*~${pref}CVS(/:t)
+}
+
+_cvsaddp () {
+ local qpref pref entries
+ _cvsprefix
+ _cvsentries
+ setopt localoptions unset
+ local all omit
+ all=( ${pref}*~${pref}CVS(D:t) )
+ omit=( $entries ${=cvsignore} )
+ [[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
+ [[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
+ eval 'compadd -fp "$qpref" -W "$pref" - ${all:#('${(j:|:)omit}')}' ||
+ compadd -fp "$qpref" -W "$pref" - ${pref}*~${pref}CVS(/:t)
+}
-_complete_opts \
- H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
- b: "compadd /usr/local/bin" \
- T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
- e: "compadd vi" \
- d: "compadd $cvs_roots || _files -/" \
- z: "compadd 9'" \
- s: "_cvs_user_variable" \
- ||
-compadd ${(k)commands} ||
-compadd ${(kv)=commands}
+_cvs "$@"
diff -Naur Completion/User/_cvsaddp Completion/User/_cvsaddp
--- Completion/User/_cvsaddp Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvsaddp Thu Jan 1 00:00:00 1970
@@ -1,13 +0,0 @@
-#autoload
-
-local qpref pref entries
-_cvsprefix
-_cvsentries
-setopt localoptions unset
-local all omit
-all=( ${pref}*~${pref}CVS(D:t) )
-omit=( $entries ${=cvsignore} )
-[[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
-[[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
-eval 'compadd -fp "$qpref" -W "$pref" - ${all:#('${(j:|:)omit}')}' ||
- compadd -fp "$qpref" -W "$pref" - ${pref}*~${pref}CVS(/:t)
diff -Naur Completion/User/_cvsentries Completion/User/_cvsentries
--- Completion/User/_cvsentries Mon Jul 26 16:55:47 1999
+++ Completion/User/_cvsentries Thu Jan 1 00:00:00 1970
@@ -1,7 +0,0 @@
-#autoload
-
-setopt localoptions nullglob unset
-if [[ -f ${pref}CVS/Entries ]]; then
- entries=( "${(@)${(@)${(@)${(f@)$(<${pref}CVS/Entries)}:#D}#(D|)/}%%/*}" )
-fi
-
diff -Naur Completion/User/_cvsentries_modified Completion/User/_cvsentries_modified
--- Completion/User/_cvsentries_modified Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvsentries_modified Thu Jan 1 00:00:00 1970
@@ -1,31 +0,0 @@
-#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
diff -Naur Completion/User/_cvsprefix Completion/User/_cvsprefix
--- Completion/User/_cvsprefix Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvsprefix Thu Jan 1 00:00:00 1970
@@ -1,18 +0,0 @@
-#autoload
-
-local f
-qpref=$PREFIX
-if [[ $qpref != */ ]]; then
- if [[ $qpref = */* ]]; then
- qpref=$qpref:h
- else
- qpref=
- fi
-fi
-pref=$~qpref
-if [[ ! -d "$pref" ]]; then
- qpref=
- pref=
-fi
-[[ -n "$pref" && "$pref" != */ ]] && qpref=$qpref/ pref=$pref/
-
diff -Naur Completion/User/_cvsremovep Completion/User/_cvsremovep
--- Completion/User/_cvsremovep Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvsremovep Thu Jan 1 00:00:00 1970
@@ -1,11 +0,0 @@
-#autoload
-
-local qpref pref entries
-_cvsprefix
-_cvsentries
-setopt localoptions unset
-local omit
-omit=( ${pref}*(D:t) )
-eval 'compadd -fp "$qpref" -W "$pref" - ${entries:#('${(j:|:)omit}')}' ||
- compadd -fp "$qpref" -W "$pref" - ${pref}*~${pref}CVS(/:t)
-
diff -Naur Completion/User/_cvsrepositories Completion/User/_cvsrepositories
--- Completion/User/_cvsrepositories Mon Jul 26 16:55:47 1999
+++ Completion/User/_cvsrepositories Thu Jan 1 00:00:00 1970
@@ -1,12 +0,0 @@
-#autoload
-
-local root=$CVSROOT
-[[ -f CVS/Root ]] && root=$(<CVS/Root)
-
-if [[ $root = :* || ! -d $root ]]; then
- compadd -UX "Enter repository name" -n '' && { compstate[list]=list; compstate[force_list]=yes; compstate[insert]='' }
-else
- compadd - \
- $root/^CVSROOT(:t) \
- "${(@)${(@M)${(@f)$(<$root/CVSROOT/modules)}:#[^#]*}%%[ ]*}"
-fi
diff -Naur Completion/User/_cvsrevisions Completion/User/_cvsrevisions
--- Completion/User/_cvsrevisions Mon Jul 26 16:55:47 1999
+++ Completion/User/_cvsrevisions Thu Jan 1 00:00:00 1970
@@ -1,3 +0,0 @@
-#autoload
-
-compadd - "${(@)${(@)${(@M)${(@f)$(cvs -q status -vl .)}:# *}##[ ]##}%%[ ]*}"
diff -Naur Completion/User/_cvstargets Completion/User/_cvstargets
--- Completion/User/_cvstargets Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvstargets Thu Jan 1 00:00:00 1970
@@ -1,7 +0,0 @@
-#autoload
-
-local qpref pref entries
-_cvsprefix
-_cvsentries
-
-compadd -fP "$qpref" -W "$pref" - $entries
diff -Naur Completion/User/_cvstargets_modified Completion/User/_cvstargets_modified
--- Completion/User/_cvstargets_modified Mon Jul 26 16:55:48 1999
+++ Completion/User/_cvstargets_modified Thu Jan 1 00:00:00 1970
@@ -1,7 +0,0 @@
-#autoload
-
-local qpref pref entries
-_cvsprefix
-_cvsentries_modified
-
-compadd -fp "$qpref" -W "$pref" - $entries
diff -Naur Completion/User/_cvstest Completion/User/_cvstest
--- Completion/User/_cvstest Mon Jul 26 16:55:47 1999
+++ Completion/User/_cvstest Thu Jan 1 00:00:00 1970
@@ -1,3 +0,0 @@
-#compdef cvstest
-
-_cvstargets
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-26 17:10 ` Tanaka Akira
@ 1999-07-27 7:48 ` Bart Schaefer
1999-07-27 8:12 ` Peter Stephenson
1999-07-27 10:07 ` Tanaka Akira
1999-07-27 8:15 ` Peter Stephenson
1 sibling, 2 replies; 20+ messages in thread
From: Bart Schaefer @ 1999-07-27 7:48 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 7:48 ` PATCH: " Bart Schaefer
@ 1999-07-27 8:12 ` Peter Stephenson
1999-07-27 10:07 ` Tanaka Akira
1 sibling, 0 replies; 20+ messages in thread
From: Peter Stephenson @ 1999-07-27 8:12 UTC (permalink / raw)
To: zsh-workers
"Bart Schaefer" wrote:
> 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).
I had to apply this by hand to the modified versions. Could both of you
try
http://www.ifh.de/~pws/computing/_cvs.tar.gz
(just the _cvs* files) to see if this is correct?
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-26 17:10 ` Tanaka Akira
1999-07-27 7:48 ` PATCH: " Bart Schaefer
@ 1999-07-27 8:15 ` Peter Stephenson
1999-07-27 8:58 ` Tanaka Akira
1 sibling, 1 reply; 20+ messages in thread
From: Peter Stephenson @ 1999-07-27 8:15 UTC (permalink / raw)
To: zsh-workers
Tanaka Akira wrote:
> I think _cvs* are only for cvs, there is no necessity to make these
> autoloadable except _cvs.
Urk. This has really set the cat among the pigeons. Instead of my last
message, perhaps someone could send me the current complete set of cvs
completions, with Bart's fixes.
--
Peter Stephenson <pws@ibmth.df.unipi.it> Tel: +39 050 844536
WWW: http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 8:15 ` Peter Stephenson
@ 1999-07-27 8:58 ` Tanaka Akira
0 siblings, 0 replies; 20+ messages in thread
From: Tanaka Akira @ 1999-07-27 8:58 UTC (permalink / raw)
To: zsh-workers
In article <9907270815.AA06647@ibmth.df.unipi.it>,
Peter Stephenson <pws@ibmth.df.unipi.it> writes:
> Tanaka Akira wrote:
> > I think _cvs* are only for cvs, there is no necessity to make these
> > autoloadable except _cvs.
>
> Urk. This has really set the cat among the pigeons. Instead of my last
> message, perhaps someone could send me the current complete set of cvs
> completions, with Bart's fixes.
I'm sorry for my many separated patches.
This includes another modification by me addition to Bart's fix. Now
_cvs completes ordinary files if the directory is not maintained by
CVS.
------------------------------------------------------------
#compdef cvs
_cvs () {
setopt localoptions extendedglob
typeset -A commands
commands=(add "ad new" admin "adm rcs" annotate ann
checkout "co get" commit "ci com" diff "di dif"
edit "" editors "" export "exp ex"
history "hi his" import "im imp" init ""
log "lo rlog" login "logon lgn" logout ""
rdiff patch release "re rel" remove "rm delete"
status "st stat" rtag "rt rfreeze" tag "ta freeze"
unedit "" update "up upd" watch ""
watchers "")
local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
local showlist='compstate[list]=list; compstate[force_list]=yes'
local showhint="$showlist ; compstate[insert]=''"
local complete_D="compadd today yesterday week\\ ago month\\ ago"
local complete_k="compadd kv kvl k o b v"
local complete_r="_cvsrevisions"
local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
if (( com < CURRENT )); then
case "$words[$com]" in
add|ad|new) # "+k:m:"
_complete_opts k: "$complete_k" m: "$complete_m" || _cvsaddp
;;
admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
_complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' \
U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' \
V: '' k: "$complete_k" ||
_cvstargets
;;
annotate|ann) # "+lr:D:fR"
_complete_opts l '' r: '' D: '' f '' R '' || _cvstargets
;;
checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
_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_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_modified || _cvstargets
;;
edit) # "+lRa:"
_complete_opts l '' R '' a: '' || _cvstargets
;;
editors) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
_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
;;
history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
_complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' \
D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' \
t: '' u: '' x: '' X: '' z: '' ||
_cvstargets
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
_complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' \
k: "$complete_k" W: '' ||
case $[CURRENT-com] in
1) _cvsrepositories;;
2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
*) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
esac
;;
init)
break
;;
login|logon|lgn|logout)
_complete_opts || _files
;;
rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
_complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' \
q '' l '' R '' D: "$complete_D" r: "$complete_r" ||
_cvstargets
;;
release|re|rel) # "+Qdq"
_complete_opts Q '' d '' q '' || _files -/
;;
remove|rm|delete) # "+flR"
_complete_opts f '' l '' R '' || _cvsremovep
;;
status|st|stat) # "+vlR"
_complete_opts v '' l '' R '' || _cvstargets
;;
tag|ta|freeze) # "+FQqlRcdr:D:bf"
_complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" \
D: "$complete_D" b '' f '' ||
_cvstargets
;;
unedit) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
_complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' \
k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' \
W: '' ||
_cvstargets
;;
watch)
if (( CURRENT == com + 1 )); then
compadd on off add remove
else
case "$words[com+1]" in
on|off) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
add|remove) # "+lRa:"
_complete_opts l '' R '' a: '' || _cvstargets
;;
esac
fi
;;
watchers) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
*) _files;;
esac
return
fi
case ${+cvs_roots} in
0)
cvs_roots=()
if [[ -f ~/.cvspass ]]; then
cvs_roots=(
$(cut -d ' ' -f 1 ~/.cvspass)
)
fi
;;
esac
_complete_opts \
H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
b: "compadd /usr/local/bin" \
T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
e: "compadd vi" \
d: "compadd $cvs_roots || _files -/" \
z: "compadd 9'" \
s: "_cvs_user_variable" \
||
compadd ${(k)commands} ||
compadd ${(kv)=commands}
}
_cvsrevisions () {
compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##}%%[ ]*}
}
_cvsrepositories () {
local root=$CVSROOT
[[ -f CVS/Root ]] && root=$(<CVS/Root)
if [[ $root = :* || ! -d $root ]]; then
compadd -UX "Enter repository name" -n '' &&
{ compstate[list]=list; compstate[force_list]=yes; compstate[insert]='' }
else
compadd - \
$root/^CVSROOT(:t) \
${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*}
fi
}
_cvsprefix () {
local f
qpref=$PREFIX
if [[ $qpref != */ ]]; then
if [[ $qpref = */* ]]; then
qpref=$qpref:h
else
qpref=
fi
fi
pref=$~qpref
if [[ ! -d "$pref" ]]; then
qpref=
pref=
fi
[[ -n "$pref" && "$pref" != */ ]] && qpref=$qpref/ pref=$pref/
}
_cvsdirentries () {
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
entries=( ${${${(M)${(f)"$(<${pref}CVS/Entries)"}:#D/*}#D/}%%/*} )
fi
}
_cvsentries () {
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
entries=( ${${${${(f)"$(<${pref}CVS/Entries)"}:#D}#(D|)/}%%/*} )
fi
}
_cvsentries_modified () {
if (( $+_cvsentries_modified_disable_stat )) ||
! { zmodload -e stat || zmodload stat }; then
_cvsentries
return
fi
local line Entries
typeset -A mtime
if [[ -f "${pref}CVS/Entries" ]]; then
Entries="$(<${pref}CVS/Entries)"
else
return
fi
local LANG=C
local OLDTZ="$TZ"; if ! (( $+TZ )); then unset OLDTZ; fi; export TZ=GMT
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
entries=($entries "${line%% *}")
fi
done
if (( $+OLDTZ )); then TZ="$OLDTZ"; else unset TZ; fi
}
_cvsdirs () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsdirentries
compadd -fP "$qpref" -W "$pref" - $entries
else
_files
fi
}
_cvstargets () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
compadd -fP "$qpref" -W "$pref" - $entries
else
_files
fi
}
_cvstargets_modified () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries_modified
compadd -fP "$qpref" -W "$pref" - $entries
else
_files
fi
}
_cvsremovep () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local omit
omit=( ${pref}*(D:t) )
eval 'compadd -fP "$qpref" -W "$pref" - ${entries:#('${(j:|:)omit}')}' ||
_cvsdirs
else
_files
fi
}
_cvsaddp () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local all omit
all=( ${pref}*~${pref}CVS(D:t) )
omit=( $entries ${=cvsignore} )
[[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
[[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
eval 'compadd -fP "$qpref" -W "$pref" - ${all:#('${(j:|:)omit}')}' ||
_cvsdirs
else
_files
fi
}
_cvs "$@"
------------------------------------------------------------
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 7:48 ` PATCH: " Bart Schaefer
1999-07-27 8:12 ` Peter Stephenson
@ 1999-07-27 10:07 ` Tanaka Akira
1999-07-27 11:45 ` Tanaka Akira
1 sibling, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-27 10:07 UTC (permalink / raw)
To: zsh-workers
In article <990727074804.ZM25420@candle.brasslantern.com>,
"Bart Schaefer" <schaefer@candle.brasslantern.com> writes:
> 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\#
I tried to fix this problem by using compgen -g instead of compadd for
_cvsaddp, _cvstargets and _cvstargets_modified.
Although _cvsremovep has same problem too, this fix is not applicable
because compgen -g does not generate nonexisting filenames.
Any ideas?
--- Completion/User/_cvs Tue Jul 27 18:16:28 1999
+++ /home/fs114/akr/arch/sunos5/usr/local/share/zsh/functions/_cvs Tue Jul 27 19:01:03 1999
@@ -182,22 +182,14 @@
}
_cvsprefix () {
- local f
- qpref=$PREFIX
- if [[ $qpref != */ ]]; then
- if [[ $qpref = */* ]]; then
- qpref=$qpref:h
- else
- qpref=
- fi
- fi
- pref=$~qpref
- if [[ ! -d "$pref" ]]; then
+ #if [[ -prefix */ ]]; then
+ if [[ x"$PREFIX" == x*/* ]]; then
+ qpref="${PREFIX%/*}/"
+ pref=$~qpref
+ else
qpref=
- pref=
+ pref=./
fi
- [[ -n "$pref" && "$pref" != */ ]] && qpref=$qpref/ pref=$pref/
- [[ -z "$pref" ]] && pref=./
}
_cvsdirentries () {
@@ -248,56 +240,54 @@
}
_cvsdirs () {
- local qpref pref entries
- _cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsdirentries
- compadd -fP "$qpref" -W "$pref" - $entries
+ compadd -fW "$pref" - $entries
else
- _files
+ _files -W "$pref"
fi
}
_cvstargets () {
local qpref pref entries
- _cvsprefix
+ _cvsprefix; compset -P '*/'
if [[ -d ${pref}CVS ]]; then
_cvsentries
- compadd -fP "$qpref" -W "$pref" - $entries
+ compgen -W "$pref" -g "(${(j:|:)entries})"
else
- _files
+ _files -W "$pref"
fi
}
_cvstargets_modified () {
local qpref pref entries
- _cvsprefix
+ _cvsprefix; compset -P '*/'
if [[ -d ${pref}CVS ]]; then
_cvsentries_modified
- compadd -fP "$qpref" -W "$pref" - $entries
+ compgen -W "$pref" -g "(${(j:|:)entries})"
else
- _files
+ _files -W "$pref"
fi
}
_cvsremovep () {
local qpref pref entries
- _cvsprefix
+ _cvsprefix; compset -P '*/'
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local omit
omit=( ${pref}*(D:t) )
- eval 'compadd -fP "$qpref" -W "$pref" - ${entries:#('${(j:|:)omit}')}' ||
+ eval 'compadd -fW "$pref" - ${entries:#('${(j:|:)omit}')}' ||
_cvsdirs
else
- _files
+ _files -W "$pref"
fi
}
_cvsaddp () {
local qpref pref entries
- _cvsprefix
+ _cvsprefix; compset -P '*/'
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
@@ -306,10 +296,10 @@
omit=( CVS $entries ${=cvsignore} )
[[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
[[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
- compgen -P "$qpref" -W "$pref" -g "*~*/(${(j:|:)omit})" ||
+ compgen -W "$pref" -g "*~*/(${(j:|:)omit})" ||
_cvsdirs
else
- _files
+ _files -W "$pref"
fi
}
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 10:07 ` Tanaka Akira
@ 1999-07-27 11:45 ` Tanaka Akira
1999-07-27 13:49 ` Bart Schaefer
0 siblings, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-27 11:45 UTC (permalink / raw)
To: zsh-workers
In article <rsqd7xexv75.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 11:45 ` Tanaka Akira
@ 1999-07-27 13:49 ` Bart Schaefer
1999-07-27 13:58 ` Tanaka Akira
0 siblings, 1 reply; 20+ messages in thread
From: Bart Schaefer @ 1999-07-27 13:49 UTC (permalink / raw)
To: Tanaka Akira, zsh-workers
On Jul 27, 8:45pm, Tanaka Akira wrote:
} Subject: Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User func
}
} So, I removed compset -P from _cvs.
Neither 7292 nor 7293 applied cleanly to the _cvs file from 7290. I don't
have time this morning to attempt to figure it out.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 13:49 ` Bart Schaefer
@ 1999-07-27 13:58 ` Tanaka Akira
1999-07-27 14:11 ` Tanaka Akira
0 siblings, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-27 13:58 UTC (permalink / raw)
To: zsh-workers
In article <990727134938.ZM26449@candle.brasslantern.com>,
"Bart Schaefer" <schaefer@candle.brasslantern.com> writes:
> Neither 7292 nor 7293 applied cleanly to the _cvs file from 7290. I don't
> have time this morning to attempt to figure it out.
Sorry, It's mistake.
My latest version of _cvs is follows:
------------------------------------------------------------
#compdef cvs
_cvs () {
setopt localoptions extendedglob
typeset -A commands
commands=(add "ad new" admin "adm rcs" annotate ann
checkout "co get" commit "ci com" diff "di dif"
edit "" editors "" export "exp ex"
history "hi his" import "im imp" init ""
log "lo rlog" login "logon lgn" logout ""
rdiff patch release "re rel" remove "rm delete"
status "st stat" rtag "rt rfreeze" tag "ta freeze"
unedit "" update "up upd" watch ""
watchers "")
local com="${words[(i)(${(j:|:)${(kv)=commands}})]}"
local showlist='compstate[list]=list; compstate[force_list]=yes'
local showhint="$showlist ; compstate[insert]=''"
local complete_D="compadd today yesterday week\\ ago month\\ ago"
local complete_k="compadd kv kvl k o b v"
local complete_r="_cvsrevisions"
local complete_m="compadd -UX 'Enter log message' -n ''; $showhint"
if (( com < CURRENT )); then
case "$words[$com]" in
add|ad|new) # "+k:m:"
_complete_opts k: "$complete_k" m: "$complete_m" || _cvsaddp
;;
admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
_complete_opts i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' \
U '' n: '' N: '' m: "$complete_m" o: '' s: '' t:: '' I '' q '' x '' \
V: '' k: "$complete_k" ||
_cvstargets
;;
annotate|ann) # "+lr:D:fR"
_complete_opts l '' r: '' D: '' f '' R '' || _cvstargets
;;
checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
_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_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_modified || _cvstargets
;;
edit) # "+lRa:"
_complete_opts l '' R '' a: '' || _cvstargets
;;
editors) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
_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
;;
history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
_complete_opts T '' a '' c '' e '' l '' o '' w '' \? '' \
D: "$complete_D" b: '' f: '' m: "$complete_m" n: '' p: '' r: '' \
t: '' u: '' x: '' X: '' z: '' ||
_cvstargets
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
_complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' \
k: "$complete_k" W: '' ||
case $[CURRENT-com] in
1) _cvsrepositories;;
2) compadd -UX "Enter vendor tag name" -n '' && eval "$showhint";;
3) compadd -UX "Enter release tag name" -n '' && eval "$showhint";;
*) compadd -UX "No futher arguments used" -n '' && eval "$showhint";;
esac
;;
init)
break
;;
login|logon|lgn|logout)
_complete_opts || _files
;;
rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
_complete_opts V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' \
q '' l '' R '' D: "$complete_D" r: "$complete_r" ||
_cvstargets
;;
release|re|rel) # "+Qdq"
_complete_opts Q '' d '' q '' || _files -/
;;
remove|rm|delete) # "+flR"
_complete_opts f '' l '' R '' || _cvsremovep
;;
status|st|stat) # "+vlR"
_complete_opts v '' l '' R '' || _cvstargets
;;
tag|ta|freeze) # "+FQqlRcdr:D:bf"
_complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" \
D: "$complete_D" b '' f '' ||
_cvstargets
;;
unedit) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
_complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' \
k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' \
W: '' ||
_cvstargets
;;
watch)
if (( CURRENT == com + 1 )); then
compadd on off add remove
else
case "$words[com+1]" in
on|off) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
add|remove) # "+lRa:"
_complete_opts l '' R '' a: '' || _cvstargets
;;
esac
fi
;;
watchers) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
*) _files;;
esac
return
fi
case ${+cvs_roots} in
0)
cvs_roots=()
if [[ -f ~/.cvspass ]]; then
cvs_roots=(
$(cut -d ' ' -f 1 ~/.cvspass)
)
fi
;;
esac
_complete_opts \
H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a '' \
b: "compadd /usr/local/bin" \
T: "compadd $TMPPREFIX:h $TMPDIR /tmp" \
e: "compadd vi" \
d: "compadd $cvs_roots || _files -/" \
z: "compadd 9'" \
s: "_cvs_user_variable" \
||
compadd ${(k)commands} ||
compadd ${(kv)=commands}
}
_cvsrevisions () {
compadd - ${${${(M)${(f)"$(cvs -q status -vl .)"}:# *}##[ ]##}%%[ ]*}
}
_cvsrepositories () {
local root=$CVSROOT
[[ -f CVS/Root ]] && root=$(<CVS/Root)
if [[ $root = :* || ! -d $root ]]; then
compadd -UX "Enter repository name" -n '' &&
{ compstate[list]=list; compstate[force_list]=yes; compstate[insert]='' }
else
compadd - \
$root/^CVSROOT(:t) \
${${(M)${(f)"$(<$root/CVSROOT/modules)"}:#[^#]*}%%[ ]*}
fi
}
_cvsprefix () {
#if [[ -prefix */ ]]; then
if [[ x"$PREFIX" == x*/* ]]; then
qpref="${PREFIX%/*}/"
pref=$~qpref
else
qpref=
pref=./
fi
}
_cvsdirentries () {
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
entries=( ${${${(M)${(f)"$(<${pref}CVS/Entries)"}:#D/*}#D/}%%/*} )
else
entries=()
fi
}
_cvsentries () {
setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
entries=( ${${${${(f)"$(<${pref}CVS/Entries)"}:#D}#(D|)/}%%/*} )
else
entries=()
fi
}
_cvsentries_modified () {
if (( $+_cvsentries_modified_disable_stat )) ||
! { zmodload -e stat || zmodload stat }; then
_cvsentries
return
fi
entries=()
local line Entries
typeset -A mtime
if [[ -f "${pref}CVS/Entries" ]]; then
Entries="$(<${pref}CVS/Entries)"
else
return
fi
local LANG=C
local OLDTZ="$TZ"; if ! (( $+TZ )); then unset OLDTZ; fi; export TZ=GMT
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
entries=($entries "${line%% *}")
fi
done
if (( $+OLDTZ )); then TZ="$OLDTZ"; else unset TZ; fi
}
_cvsdirs () {
if [[ -d ${pref}CVS ]]; then
_cvsdirentries
if (( $#entries )); then
compgen "$@" -g '('${(j:|:)entries:q}')'
fi
else
_files
fi
}
_cvstargets () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
if (( $#entries )); then
compgen -g '('${(j:|:)entries:q}')'
fi
else
_files
fi
}
_cvstargets_modified () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries_modified
if (( $#entries )); then
compgen -g '('${(j:|:)entries:q}')'
fi
else
_files
fi
}
_cvsremovep () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local omit
omit=( ${pref}*(D:t) )
eval 'entries=( ${entries:#('${(j:|:)omit:q}')} )'
compadd -P "$qpref" - ${entries:q} ||
_cvsdirs
else
_files
fi
}
_cvsaddp () {
local qpref pref entries
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
setopt localoptions unset
local all omit
all=( ${pref}*~${pref}CVS(D:t) )
omit=( CVS $entries ${=cvsignore} )
[[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
[[ -r ${pref}.cvsignore ]] && omit=( $omit $(<${pref}.cvsignore) )
compgen -g '*~(*/|)('${(j:|:)omit:q}')' ||
{ _cvsdirentries; compgen -g '('${(j:|:)entries:q}')' }
else
_files
fi
}
_cvs "$@"
------------------------------------------------------------
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 13:58 ` Tanaka Akira
@ 1999-07-27 14:11 ` Tanaka Akira
1999-07-28 16:05 ` Tanaka Akira
0 siblings, 1 reply; 20+ messages in thread
From: Tanaka Akira @ 1999-07-27 14:11 UTC (permalink / raw)
To: zsh-workers
In article <rsqzp0idwjv.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> writes:
> My latest version of _cvs is follows:
I found a problem of return status of _cvstargets, etc.
Index: Completion/User/_cvs
===================================================================
RCS file: /projects/zsh/zsh/Completion/User/_cvs,v
retrieving revision 1.1.1.1.2.7
diff -u -F^( -r1.1.1.1.2.7 _cvs
--- _cvs 1999/07/27 11:48:15 1.1.1.1.2.7
+++ _cvs 1999/07/27 14:10:03
@@ -249,6 +249,8 @@
_cvsdirentries
if (( $#entries )); then
compgen "$@" -g '('${(j:|:)entries:q}')'
+ else
+ false
fi
else
_files
@@ -262,6 +264,8 @@
_cvsentries
if (( $#entries )); then
compgen -g '('${(j:|:)entries:q}')'
+ else
+ false
fi
else
_files
@@ -275,6 +279,8 @@
_cvsentries_modified
if (( $#entries )); then
compgen -g '('${(j:|:)entries:q}')'
+ else
+ false
fi
else
_files
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
1999-07-27 14:11 ` Tanaka Akira
@ 1999-07-28 16:05 ` Tanaka Akira
0 siblings, 0 replies; 20+ messages in thread
From: Tanaka Akira @ 1999-07-28 16:05 UTC (permalink / raw)
To: zsh-workers
In article <rsqwvvmdvxe.fsf@crane.jaist.ac.jp>,
Tanaka Akira <akr@jaist.ac.jp> writes:
> I found a problem of return status of _cvstargets, etc.
Hm. When entries has just one elements, the argument such as
'(_cvs)' is supplied to compgen -g and it is treated as glob
qualifiers. The completer should not use parenthesises in this case.
This patch also tries to complete arguments for some options.
--- Completion/User/_cvs Wed Jul 28 14:37:08 1999
+++ Completion/User/_cvs Wed Jul 28 14:45:23 1999
@@ -35,16 +35,17 @@
_cvstargets
;;
annotate|ann) # "+lr:D:fR"
- _complete_opts l '' r: '' D: '' f '' R '' || _cvstargets
+ _complete_opts l '' r: "$complete_r" D: "$complete_D" f '' R '' ||
+ _cvstargets
;;
checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
- _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 '' ||
+ _complete_opts A '' N '' n '' k: "$complete_k" d: '_files -/' f '' \
+ l '' R '' p '' Q '' q '' c '' s '' r: "$complete_r" D: "$complete_D" \
+ j: "$complete_r" P '' ||
_cvsrepositories
;;
commit|ci|com) # "+nlRm:fF:r:"
- _complete_opts n '' l '' R '' m: "$complete_m" f '' F: '' \
+ _complete_opts n '' l '' R '' m: "$complete_m" f '' F: _files \
r: "$complete_r" ||
_cvstargets_modified
;;
@@ -56,15 +57,15 @@
_cvstargets_modified || _cvstargets
;;
edit) # "+lRa:"
- _complete_opts l '' R '' a: '' || _cvstargets
+ _complete_opts l '' R '' a: 'compadd edit unedit commit all none' ||
+ _cvstargets
;;
editors) # "+lR"
_complete_opts l '' R '' || _cvstargets
;;
- export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
- _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 '' ||
+ export|exp|ex) # "+Nnk:d:flRQqr:D:"
+ _complete_opts N '' n '' k: "$complete_k" d: '_files -/' f '' l '' \
+ R '' Q '' q '' r: "$complete_r" D: "$complete_D" ||
_cvsrepositories
;;
history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
@@ -74,7 +75,7 @@
_cvstargets
;;
import|im|imp) # "+Qqdb:m:I:k:W:"
- _complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: '' \
+ _complete_opts Q '' q '' d '' b: '' m: "$complete_m" I: _files \
k: "$complete_k" W: '' ||
case $[CURRENT-com] in
1) _cvsrepositories;;
@@ -113,8 +114,8 @@
;;
update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
_complete_opts A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' \
- k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' \
- W: '' ||
+ k: "$complete_k" r: "$complete_r" D: "$complete_D" j: "$complete_r" \
+ I: '' W: '' ||
_cvstargets
;;
watch)
@@ -126,7 +127,9 @@
_complete_opts l '' R '' || _cvstargets
;;
add|remove) # "+lRa:"
- _complete_opts l '' R '' a: '' || _cvstargets
+ _complete_opts l '' R '' \
+ a: 'compadd edit unedit commit all none' || \
+ _cvstargets
;;
esac
fi
@@ -247,11 +250,11 @@
_cvsdirs () {
if [[ -d ${pref}CVS ]]; then
_cvsdirentries
- if (( $#entries )); then
- compgen "$@" -g '('${(j:|:)entries:q}')'
- else
- false
- fi
+ case $#entries in
+ 0) false;;
+ 1) compgen "$@" -g "${entries:q}";;
+ *) compgen "$@" -g '('${(j:|:)entries:q}')';;
+ esac
else
_files
fi
@@ -262,11 +265,11 @@
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries
- if (( $#entries )); then
- compgen -g '('${(j:|:)entries:q}')'
- else
- false
- fi
+ case $#entries in
+ 0) false;;
+ 1) compgen -g "${entries:q}";;
+ *) compgen -g '('${(j:|:)entries:q}')';;
+ esac
else
_files
fi
@@ -277,11 +280,11 @@
_cvsprefix
if [[ -d ${pref}CVS ]]; then
_cvsentries_modified
- if (( $#entries )); then
- compgen -g '('${(j:|:)entries:q}')'
- else
- false
- fi
+ case $#entries in
+ 0) false;;
+ 1) compgen -g "${entries:q}";;
+ *) compgen -g '('${(j:|:)entries:q}')';;
+ esac
else
_files
fi
--
Tanaka Akira
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: PATCH: Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
@ 1999-08-02 9:47 Sven Wischnowsky
0 siblings, 0 replies; 20+ messages in thread
From: Sven Wischnowsky @ 1999-08-02 9:47 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> 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\#
Indeed. Due to the changed quoting rules in the completion code, we
should do the quoting of ppre and psuf in addmatches() earlier and
avoid quoting lpre/lsuf a second time altogether.
Bye
Sven
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Mon Aug 2 11:44:54 1999
+++ Src/Zle/zle_tricky.c Mon Aug 2 11:42:26 1999
@@ -3726,7 +3726,7 @@
addmatches(Cadata dat, char **argv)
{
char *s, *ms, *lipre = NULL, *lisuf = NULL, *lpre = NULL, *lsuf = NULL;
- char **aign = NULL, **dparr = NULL, oaq = autoq;
+ char **aign = NULL, **dparr = NULL, oaq = autoq, *oppre = dat->ppre;
char *oqp = qipre, *oqs = qisuf, qc;
int lpl, lsl, pl, sl, bpl, bsl, llpl = 0, llsl = 0, nm = mnum;
int oisalt = 0, isalt, isexact, doadd, ois = instring, oib = inbackt;
@@ -3847,12 +3847,21 @@
else if (lisuf)
dat->isuf = lisuf;
if (dat->ppre) {
- dat->ppre = dupstring(dat->ppre);
+ if (!(dat->aflags & CAF_QUOTE)) {
+ dat->ppre = quotename(dat->ppre, NULL);
+ if ((dat->flags & CMF_FILE) &&
+ dat->ppre[0] == '\\' && dat->ppre[1] == '~')
+ chuck(dat->ppre);
+ } else
+ dat->ppre = dupstring(dat->ppre);
lpl = strlen(dat->ppre);
} else
lpl = 0;
if (dat->psuf) {
- dat->psuf = dupstring(dat->psuf);
+ if (!(dat->aflags & CAF_QUOTE))
+ dat->psuf = quotename(dat->psuf, NULL);
+ else
+ dat->psuf = dupstring(dat->psuf);
lsl = strlen(dat->psuf);
} else
lsl = 0;
@@ -3877,7 +3886,7 @@
dat->pre = dupstring(dat->pre);
if (dat->suf)
dat->suf = dupstring(dat->suf);
- if (!dat->prpre && (dat->prpre = dat->ppre)) {
+ if (!dat->prpre && (dat->prpre = oppre)) {
singsub(&(dat->prpre));
untokenize(dat->prpre);
} else
@@ -3901,22 +3910,6 @@
dat->rems = NULL;
} else if (dat->rems)
dat->rems = dupstring(dat->rems);
-
- /* Probably quote the prefix and suffix for testing. */
- if (!(dat->aflags & CAF_QUOTE)) {
- if (!cp && (dat->aflags & CAF_MATCH)) {
- lpre = quotename(lpre, NULL);
- lsuf = quotename(lsuf, NULL);
- }
- if (dat->ppre) {
- dat->ppre = quotename(dat->ppre, NULL);
- if ((dat->flags & CMF_FILE) &&
- dat->ppre[0] == '\\' && dat->ppre[1] == '~')
- chuck(dat->ppre);
- }
- if (dat->psuf)
- dat->psuf = quotename(dat->psuf, NULL);
- }
}
/* Walk through the matches given. */
for (; (s = *argv); argv++) {
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~1999-08-02 9:47 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-21 11:27 CVS completer (Re: PATCH: Re: Completion/User functions again) Sven Wischnowsky
1999-07-21 12:35 ` Tanaka Akira
1999-07-21 15:43 ` Tanaka Akira
1999-07-21 15:54 ` Bart Schaefer
1999-07-25 9:23 ` Tanaka Akira
1999-07-25 11:38 ` Tanaka Akira
1999-07-26 4:48 ` Tanaka Akira
1999-07-26 16:26 ` Tanaka Akira
1999-07-26 17:10 ` Tanaka Akira
1999-07-27 7:48 ` PATCH: " Bart Schaefer
1999-07-27 8:12 ` Peter Stephenson
1999-07-27 10:07 ` Tanaka Akira
1999-07-27 11:45 ` Tanaka Akira
1999-07-27 13:49 ` Bart Schaefer
1999-07-27 13:58 ` Tanaka Akira
1999-07-27 14:11 ` Tanaka Akira
1999-07-28 16:05 ` Tanaka Akira
1999-07-27 8:15 ` Peter Stephenson
1999-07-27 8:58 ` Tanaka Akira
1999-08-02 9:47 PATCH: " Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).