zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-workers@math.gatech.edu
Subject: PATCH: cvsaddp and cvsremovep in compctl-examples
Date: Tue, 16 Jun 1998 21:35:44 -0700	[thread overview]
Message-ID: <980616213545.ZM12579@candle.brasslantern.com> (raw)
In-Reply-To: <980616110244.ZM10475@candle.brasslantern.com>

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


      reply	other threads:[~1998-06-17  4:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-16 18:02 Bart Schaefer
1998-06-17  4:35 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=980616213545.ZM12579@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).