zsh-workers
 help / color / mirror / code / Atom feed
* cvsaddp and cvsremovep in compctl-examples
@ 1998-06-16 18:02 Bart Schaefer
  1998-06-17  4:35 ` PATCH: " Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 1998-06-16 18:02 UTC (permalink / raw)
  To: zsh-workers

The number of pipelines and external commands involved is silly, especially
when most of what they do is already done by cvstargets.

cvsremovep() {
    cvstargets
    setopt localoptions extendedglob
    local omit
    omit=(*(D))
    eval 'reply=( ${reply:#('${(j:|:)omit}')} )'
}

cvsaddp() {
    cvstargets
    setopt localoptions extendedglob
    local all omit
    all=(*(D))
    omit=( $reply $=cvsignore )
    [[ -r ~/.cvsignore ]] && omit=( $omit $(<~/.cvsignore) )
    [[ -r .cvsignore ]] && omit=( $omit $(<.cvsignore) )
    eval 'reply=( ${all:#('${(j:|:)omit}')} )' 
}

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* PATCH: cvsaddp and cvsremovep in compctl-examples
  1998-06-16 18:02 cvsaddp and cvsremovep in compctl-examples Bart Schaefer
@ 1998-06-17  4:35 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1998-06-17  4:35 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1998-06-17  4:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-16 18:02 cvsaddp and cvsremovep in compctl-examples Bart Schaefer
1998-06-17  4:35 ` PATCH: " Bart Schaefer

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).