Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: cvsaddp and cvsremovep in compctl-examples
- X-seq: zsh-workers 4130
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx
- Subject: PATCH: cvsaddp and cvsremovep in compctl-examples
- Date: Tue, 16 Jun 1998 21:35:44 -0700
- In-reply-to: <980616110244.ZM10475@xxxxxxxxxxxxxxxxxxxxxxx>
- References: <980616110244.ZM10475@xxxxxxxxxxxxxxxxxxxxxxx>
On Jun 16, 11:02am, Bart Schaefer wrote:
} Subject: cvsaddp and cvsremovep in compctl-examples
}
} The number of pipelines and external commands involved is silly, especially
} when most of what they do is already done by cvstargets.
Here's a slightly improved solution, as a patch to Misc/compctl-examples.
My previous samples worked only when completing in the current directory.
Those in this patch share computation of the file prefix among cvstargets,
cvsremovep, and cvsaddp, so that all can complete in other directories.
I'm having a vague recollection that some versions of cvs can't handle
"cvs add" except in the current directory; if that's an issue, simply
remove or comment out the call to cvsprefix in cvsaddp.
Index: Misc/compctl-examples
===================================================================
--- compctl-examples 1998/06/01 17:08:43 1.1.1.1
+++ compctl-examples 1998/06/17 04:31:33
@@ -550,9 +550,8 @@
compctl -/K cvstargets cvstest
-cvstargets() {
- local nword args pref f
- setopt localoptions nullglob
+cvsprefix() {
+ local nword args f
read -nc nword; read -Ac args
pref=$args[$nword]
if [[ -d $pref:h && ! -d $pref ]]; then
@@ -561,11 +560,21 @@
pref=
fi
[[ -n "$pref" && "$pref" != */ ]] && pref=$pref/
+}
+
+cvsentries() {
+ setopt localoptions nullglob unset
if [[ -f ${pref}CVS/Entries ]]; then
reply=( "${pref}${^${${${(f@)$(<${pref}CVS/Entries)}:#D*}#/}%%/*}" )
fi
}
+cvstargets() {
+ local pref
+ cvsprefix
+ cvsentries
+}
+
cvsrevisions() {
reply=( "${${${(M)${(f)$(cvs -q status -vl .)}:# *}##[ ]##}%%[ ]*}" )
}
@@ -580,17 +589,26 @@
}
cvsremovep() {
- if [[ -f CVS/Entries ]]; then
- reply=($(
- ( sed -ne 's:^/\([^/]*\)/[^-].*$:E\1:p' <CVS/Entries; ls -a1 | sed 's:^\(.*\)$:D\1:g' ) |
- sort +0.1 | uniq --skip-chars=1 -u | sed -ne 's/^E\(.*\)$/\1/p'
- ))
- fi
+ local pref
+ cvsprefix
+ cvsentries
+ setopt localoptions unset
+ local omit
+ omit=( ${pref}*(D) )
+ eval 'reply=( ${reply:#('${(j:|:)omit}')} )'
}
cvsaddp() {
- setopt localoptions nullglob
- [[ -e CVS/Entries ]] && reply=(`(sed -ne 's:^/\([^/]*\)/.*$:E\1:p' -e 's:^/\([^/]*\)/-.*$:E\1:p' <CVS/Entries; ( ls -a1 | sed 's:^\(.*\)$:D\1:g' ); (ls -ad1 $(echo "$cvsignore"; cat .cvsignore 2>/dev/null ) 2>/dev/null | sed 's:^\(.*\)$:I\1:g' ) ) | sort +0.1 | uniq --skip-chars=1 -u | sed -ne 's/^[^I]\(.*\)$/\1/p'`)
+ local pref
+ cvsprefix
+ cvsentries
+ setopt localoptions unset
+ local all omit
+ all=( ${pref}*(D) )
+ omit=( $reply ${pref}${^${=cvsignore}} )
+ [[ -r ~/.cvsignore ]] && omit=( $omit ${pref}${^$(<~/.cvsignore)} )
+ [[ -r ${pref}.cvsignore ]] && omit=( $omit ${pref}${^$(<${pref}.cvsignore)} )
+ eval 'reply=( ${all:#('${(j:|:)omit}')} )'
}
#------------------------------------------------------------------------------
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Messages sorted by:
Reverse Date,
Date,
Thread,
Author