zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: Re: Completion/User functions again
@ 1999-07-14 12:46 Sven Wischnowsky
  1999-07-14 13:12 ` Tanaka Akira
  1999-07-14 14:29 ` Completion/User functions again Oliver Kiddle
  0 siblings, 2 replies; 17+ messages in thread
From: Sven Wischnowsky @ 1999-07-14 12:46 UTC (permalink / raw)
  To: zsh-workers


Oliver Kiddle wrote:

> Andrej Borsenkow wrote:
> > 
> >  - _tar and _find are hopelessly GNUish. You cannot expect, that users will
> > study every function to find out if it is applicable to there system. They will
> > simply install it and wonder why it does not work. Of course, gzip, configure
> > etc are GNU as well - but they do not conflict with system standard commands.
> 
> This is why I suggested a while ago that things such as tar and find are
> moved to a 'Gnu' directory and other directories such as Aix, Irix etc
> can contain completions specific to
> those systems.

I've been thinking about this for a long time, too. The problems are
that we would have to fill those directories (so that they don't look
silly) and with such directories users would expect to need only to
copy the contents of one such directory (or link User to it), so they
would have to be (almost) complete. That's a lot of work and who'll do 
that, I wonder.

While we are at it: we still don't have completion functions for some
commands for which we have compctl examples, e.g. cvs and rpm. I don't 
use either of these often enough to be able to write good functions
for them -- any volunteers for that?

> The patch to _x_options also
> causes it to only complete options on words starting with a '-'. I
> prefer to complete options this way as it keeps the number of matches
> down.

I never expected _x_options to survive this long... ;-)

> Maybe we should put a note in one of the readmes to make it clear that
> the functions may not work on all systems, maybe detailing which might
> have issues. I find many of the functions enormously useful and it would
> be a pity for them not to be used.

Maybe, yes.

> One thing which I just noticed which I don't think is right:
> rlogin <tab>
> zsh: do you wish to see all 114 possibilities? n
> The no returns to 'rlogin ' on the command-line. now, if I press tab
> again, menu completion
> starts. I think it should ignore the original tab if the question was
> answered with no.

Hm. 1) It has always been like that (or should have been). 2) Dunno,
you can always use ^D, but I don't have a real opinion about this --
anyone else wanting to comment?


Maybe we should add some kind of programming style guide some day,
containing things like `make functions that can be used as helper
functions do something useful with their arguments if possible' and
`do not use compgen if you're only after the -k or -s options'
(compadd is faster and -- I think -- cleaner for this).

Bye
 Sven

diff -u -r oc/User/_hosts Completion/User/_hosts
--- oc/User/_hosts	Tue Jul 13 10:58:41 1999
+++ Completion/User/_hosts	Wed Jul 14 14:32:29 1999
@@ -2,4 +2,4 @@
 
 : ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
 
-compgen -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' -k hosts
+compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" - "$hosts[@]"
diff -u -r oc/User/_x_options Completion/User/_x_options
--- oc/User/_x_options	Wed Jul 14 14:33:41 1999
+++ Completion/User/_x_options	Wed Jul 14 14:42:29 1999
@@ -3,7 +3,8 @@
 # A simple pattern completion, just as an example.
 
 if [ "$words[CURRENT-1]" = "-display" ]; then
-  ISUFFIX=':0' _hosts
+  _compskip=''
+  _hosts -S :0
 else
   compadd -P- -J options - display name xrm
 fi

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


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

* Re: PATCH: Re: Completion/User functions again
  1999-07-14 12:46 PATCH: Re: Completion/User functions again Sven Wischnowsky
@ 1999-07-14 13:12 ` Tanaka Akira
  1999-07-20 18:05   ` CVS completer (Re: PATCH: Re: Completion/User functions again) Bart Schaefer
  1999-07-14 14:29 ` Completion/User functions again Oliver Kiddle
  1 sibling, 1 reply; 17+ messages in thread
From: Tanaka Akira @ 1999-07-14 13:12 UTC (permalink / raw)
  To: zsh-workers

In article <199907141246.OAA11798@beta.informatik.hu-berlin.de>,
  Sven Wischnowsky <wischnow@informatik.hu-berlin.de> writes:

> While we are at it: we still don't have completion functions for some
> commands for which we have compctl examples, e.g. cvs and rpm. I don't 
> use either of these often enough to be able to write good functions
> for them -- any volunteers for that?

I wrote _cvs.
But it's ugly, not self-contained and it doesn't deal with CVS/Entries.
And I don't have a time to implove it in this week.

So, if another implementation exists, it may better.

---------- _cvs ----------
#compdef cvs

typeset -A short_opts

local com="${words[(i)(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 complete_D="compgen -k '(yesterday week\\ ago month\\ ago)'"
local complete_k="compgen -k '(kv kvl k o b v)'"
local complete_r="compgen -k '(tag)'"

#_view_completion_parameters "com=$com"

if (( $com < $CURRENT )); then
  case "$words[$com]" in
    add|ad|new) # "+k:m:"
      short_opts=(k: "$complete_k" m: "compgen -k '(MESSAGE)'")
      _complete_opts || compgen -f
      ;;
    admin|adm|rcs) # "+ib::c:a:A:e:l::u::LUn:N:m:o:s:t::IqxV:k:"
      short_opts=(i '' b:: '' c: '' a: '' A: '' e: '' l:: '' u:: '' L '' U '' n: '' N: '' m: '' o: '' s: '' t:: '' I '' q '' x '' V: '' k: '')
      _complete_opts || compgen -f
      ;;
    annotate|ann) # "+lr:D:fR"
      short_opts=(l '' r: '' D: '' f '' R '')
      _complete_opts || compgen -f
      ;;
    checkout|co|get) # "+ANnk:d:flRpQqcsr:D:j:P"
      short_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 || compgen -k '(MODULE)'
      ;;
    commit|ci|com) # "+nlRm:fF:r:"
      short_opts=(n '' l '' R '' m: '' f '' F: '' r: "$complete_r")
      _complete_opts || compgen -f
      ;;
    diff|di|dif) # "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:"
      short_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")
      _complete_opts || compgen -f
      ;;
    edit) # "+lRa:"
      short_opts=(l '' R '' a: '')
      _complete_opts || compgen -f
      ;;
    editors) # "+lR"
      short_opts=(l '' R '')
      _complete_opts || compgen -f
      ;;
    export|exp|ex) # "+ANnk:d:flRpQqcsr:D:j:P"
      short_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 || compgen -k '(MODULE)'
      ;;
    history|hi|his) # "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:"
      short_opts=(T '' a '' c '' e '' l '' o '' w '' \? '' D: "$complete_D" b: '' f: '' m: '' n: '' p: '' r: '' t: '' u: '' x: '' X: '' z: '')
      _complete_opts || compgen -f
      ;;
    import|im|imp) # "+Qqdb:m:I:k:W:"
      short_opts=(Q '' q '' d '' b: '' m: '' I: '' k: '' W: '')
      _complete_opts || compgen -k '(REPOSITORY-VENDORTAG-RELEASETAG)'
      ;;
    init)
      short_opts=()
      _complete_opts || compgen -f
      ;;
    login|logon|lgn)
      short_opts=()
      _complete_opts || compgen -f
      ;;
    logout)
      short_opts=()
      _complete_opts || compgen -f
      ;;
    rdiff|patch|pa) # "+V:k:cuftsQqlRD:r:"
      short_opts=(V: '' k: "$complete_k" c '' u '' f '' t '' s '' Q '' q '' l '' R '' D: "$complete_D" r: "$complete_r")
      _complete_opts || compgen -f
      ;;
    release|re|rel) # "+Qdq"
      short_opts=(Q '' d '' q '')
      _complete_opts || compgen -f
      ;;
    remove|rm|delete) # "+flR"
      short_opts=(f '' l '' R '')
      _complete_opts || compgen -f
      ;;
    status|st|stat) # "+vlR"
      short_opts=(v '' l '' R '')
      _complete_opts || compgen -f
      ;;
    tag|ta|freeze) # "+FQqlRcdr:D:bf"
      short_opts=(F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '')
      _complete_opts || compgen -f
      ;;
    unedit) # "+lR"
      short_opts=(l '' R '')
      _complete_opts || compgen -f
      ;;
    update|up|upd) # "+ApPflRQqduk:r:D:j:I:W:"
      short_opts=(A '' p '' P '' f '' l '' R '' Q '' q '' d '' u '' k: "$complete_k" r: "$complete_r" D: "$complete_D" j: '' I: '' W: '')
      _complete_opts || compgen -f
      ;;
    watch)
      if [[ $CURRENT = $(($com + 1)) ]]; then
        compgen -k '(on off add remove)'
      else
        case "$words[$com+1]" in
          on|off) # "+lR"
            short_opts=(l '' R '')
            _complete_opts || compgen -f
            ;;
          add|remove) # "+lRa:"
            short_opts=(l '' R '' a: '')
            _complete_opts || compgen -f
            ;;
        esac
      fi
      ;;
    watchers) # "+lR"
      short_opts=(l '' R '')
      _complete_opts || compgen -f
      ;;
    *) compgen -f;;
  esac
  return
fi

case ${+cvs_roots} in
  0)
    cvs_roots=()
    if [[ -f ~/.cvspass ]]; then
      cvs_roots=(
	$(cut -d ' ' -f 1 ~/.cvspass)
      )
    fi
    ;;
esac

short_opts=(
  H '' Q '' q '' r '' w '' l '' n '' t '' v '' f '' a ''
  b: "compgen -k '(/usr/local/bin)'"
  T: "compgen -k '(/tmp)'"
  e: "compgen -k '(vi)'"
  d: "compgen -k cvs_roots || compgen -/"
  z: "compgen -k '(9)'"
  s: "_cvs_user_variable"
)

_complete_opts || 
compgen -k '(add admin annotate checkout commit
             diff edit editors export history
             import init log login logout
             rdiff release remove status rtag
             tag unedit update watch watchers)' ||
compgen -k '(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)'

------------------------------

---------- _complete_opts ----------
#autoload

# Usage:
#  typeset -A short_opts
#  short_opts=(
#    H '' 
#    f 'compgen -f'
#  )
#  _complete_opts

typeset -a no_arg with_arg
no_arg=($short_opts[(I)?])
with_arg=($short_opts[(I)?:]:s/://)

case "${#no_arg}-${#with_arg}" in
  0-0)
    if [[ x$PREFIX = x-* ]]; then
      compgen -k '()'
    else
      false
    fi
    ;;

  0-*)
    if [[ x$PREFIX = x- ]]; then
      IPREFIX="$IPREFIX$PREFIX"
      PREFIX=
      compgen -k with_arg
    elif [[ x$PREFIX = x-[${(j::)with_arg}] ]]; then
      IPREFIX="$IPREFIX$PREFIX"
      PREFIX=
      eval $short_opts[$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 $short_opts[$IPREFIX[-1]:]
    elif [[ x$words[$CURRENT-1] = x-[${(j::)with_arg}] ]]; then
      local p="$words[$CURRENT - 1]"
      eval $short_opts[$p[-1]:]
    else
      false
    fi
    ;;

  *-0)
    if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
      IPREFIX="$IPREFIX$PREFIX"
      PREFIX=
      compgen -k no_arg
    else
      false
    fi
    ;;

  *-*)
    if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
      IPREFIX="$IPREFIX$PREFIX"
      PREFIX=
      compgen -k no_arg
      compgen -k with_arg
    elif [[ x$PREFIX = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
      IPREFIX="$IPREFIX$PREFIX"
      PREFIX=
      eval $short_opts[$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 $short_opts[$IPREFIX[-1]:]
    elif [[ x$words[$CURRENT-1] = x-[${(j::)no_arg}]#[${(j::)with_arg}] ]]; then
      local p="$words[$CURRENT - 1]"
      eval $short_opts[$p[-1]:]
    else
      false
    fi
    ;;
esac
------------------------------

Also, I wrote _wget, _lynx, etc. If you interest them, See
http://www.ldl.jaist.ac.jp/~akr/zsh/dot-zsh/funcs/.

I want standard way to specify user's completion preferences such as
host-port relation for _telnet and _socket, URLs for _wget and _lynx,
user-host relation for _finger, and so on.
-- 
Tanaka Akira


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

* Re: Completion/User functions again
  1999-07-14 12:46 PATCH: Re: Completion/User functions again Sven Wischnowsky
  1999-07-14 13:12 ` Tanaka Akira
@ 1999-07-14 14:29 ` Oliver Kiddle
  1 sibling, 0 replies; 17+ messages in thread
From: Oliver Kiddle @ 1999-07-14 14:29 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:

> I've been thinking about this for a long time, too. The problems are
> that we would have to fill those directories (so that they don't look

I don't think it would matter too much if they were on the empty side
while we are still on version 3.1.x.

> silly) and with such directories users would expect to need only to
> copy the contents of one such directory (or link User to it), so they
> would have to be (almost) complete. That's a lot of work and who'll do
> that, I wonder.

Linking User to the directory probably wouldn't be the best approach
because there are many commands for which the completion won't be system
specific. I would go for an approach similar to that for installing
modules so users can add directories to install to a file listing the
completion directories. The configure script could possibly be enhanced
to intelligently add any appropriate directories. I would also subdivide
the User directory a little. For example if all the X programs were in
their own directory then they could be excluded on a system which lacks
X. We might later add directories for obscure software which would only
be relevant to a small number of users. This is a large reason why I
prefer the directories to be preserved with the installation (via
--enable-function-subdirs) and think it should be the default.

> While we are at it: we still don't have completion functions for some
> commands for which we have compctl examples, e.g. cvs and rpm. I don't
> use either of these often enough to be able to write good functions
> for them -- any volunteers for that?

I don't use rpm or cvs either so I won't volunteer for those but there
are many other programs for which I plan to write completions - I had an
enormous number of tcsh completes which I have yet to convert to zsh.
I've got a few IRIX/AIX specific ones which I'll contribute if and when
we have directories set up to accomodate them.

> Maybe we should add some kind of programming style guide some day,
> containing things like `make functions that can be used as helper
> functions do something useful with their arguments if possible' and
> `do not use compgen if you're only after the -k or -s options'
> (compadd is faster and -- I think -- cleaner for this).

A programming style guide would certainly be a good idea and its
usefulness would not be limited to writing zsh completions. It might be
a good idea to start one off as a simple text file, listing key points
particularly any which aren't immediately obvious like the compadd
point. We can always convert it to LaTeX/yodl/texinfo/whatever and
expand it into a readable document later.

Oliver Kiddle


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

* CVS completer (Re: PATCH: Re: Completion/User functions again)
  1999-07-14 13:12 ` Tanaka Akira
@ 1999-07-20 18:05   ` Bart Schaefer
  1999-07-26  0:52     ` Tanaka Akira
  0 siblings, 1 reply; 17+ messages in thread
From: Bart Schaefer @ 1999-07-20 18:05 UTC (permalink / raw)
  To: Tanaka Akira; +Cc: zsh-workers

On Jul 14, 10:12pm, Tanaka Akira wrote:
} Subject: Re: PATCH: Re: Completion/User functions again
}
} > While we are at it: we still don't have completion functions for some
} > commands for which we have compctl examples, e.g. cvs and rpm.
} 
} I wrote _cvs.
} But it's ugly, not self-contained and it doesn't deal with CVS/Entries.
} And I don't have a time to implove it in this week.

Below is an improved version of Tanaka's _cvs completer.  I changed many
"compgen -[sk]" calls into compadd calls, fixed up completing of option
letters in a couple of cases, and used the explanation-printing trick
recently discussed on zsh-users in a couple of others.  And I changed
_complete_opts to take the list of options and completion actions as
commmand-line arguments rather than through a shared global association.

However, there is still much room for improvement; for example, the
explanation strings get confused after "cvs import" if there are any
intervening options between the word "import" and the repository name.
I simply don't have time to beat on it any longer.

Also, some options like -k require that there be no space between the
option and its arguments, but nothing seems to enforce that -- even if
I type "cvs add -kv <TAB>" (note space after -kv) the completions I get
are the ones for -k; it should instead act as if a new option or file
name were being completed.

Finally, there are a number of cases where "compgen -f" could be replaced
by something similar to the cvstargets function from misc/compctl-examples.

There are some fairly long lines below, so watch out for wrapping.

--- 8< --- _cvs --- 8< ---
#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"

#_view_completion_parameters "com=$com"

if (( $com < $CURRENT )); then
  case "$words[$com]" in
    add|ad|new) # "+k:m:"
      _complete_opts k: "$complete_k" m: "$complete_m" || compgen -f
      ;;
    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" || compgen -f
      ;;
    annotate|ann) # "+lr:D:fR"
      _complete_opts l '' r: '' D: '' f '' R '' || compgen -f
      ;;
    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" || compgen -f
      ;;
    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" || compgen -f
      ;;
    edit) # "+lRa:"
      _complete_opts l '' R '' a: '' || compgen -f
      ;;
    editors) # "+lR"
      _complete_opts l '' R '' || compgen -f
      ;;
    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: '' || compgen -f
      ;;
    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)
      _complete_opts || compgen -f
      ;;
    logout)
      _complete_opts || compgen -f
      ;;
    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" || compgen -f
      ;;
    release|re|rel) # "+Qdq"
      _complete_opts Q '' d '' q '' || compgen -/
      ;;
    remove|rm|delete) # "+flR"
      _complete_opts f '' l '' R '' || compgen -f
      ;;
    status|st|stat) # "+vlR"
      _complete_opts v '' l '' R '' || compgen -f
      ;;
    tag|ta|freeze) # "+FQqlRcdr:D:bf"
      _complete_opts F '' Q '' q '' l '' R '' c '' d '' r: "$complete_r" D: "$complete_D" b '' f '' || compgen -f
      ;;
    unedit) # "+lR"
      _complete_opts l '' R '' || compgen -f
      ;;
    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: '' || compgen -f
      ;;
    watch)
      if (( CURRENT == com + 1 )); then
        compadd on off add remove
      else
        case "$words[com+1]" in
          on|off) # "+lR"
            _complete_opts l '' R '' || compgen -f
            ;;
          add|remove) # "+lRa:"
            _complete_opts l '' R '' a: '' || compgen -f
            ;;
        esac
      fi
      ;;
    watchers) # "+lR"
      _complete_opts l '' R '' || compgen -f
      ;;
    *) compgen -f;;
  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 || compgen -/" \
  z: "compadd 9'" \
  s: "_cvs_user_variable" \
 || 
compadd ${(k)commands} ||
compadd ${(kv)=commands}

--- 8< --- end of _cvs --- 8< ---
--- 8< --- _complete_opts --- 8< ---

#autoload

# Usage:
#  _complete_opts H '' f 'compgen -f'

emulate -L zsh
setopt extendedglob

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
      false
    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
      false
    fi
    ;;

  *-0)
    if [[ x$PREFIX = x-[${(j::)no_arg}]# ]]; then
      IPREFIX="$IPREFIX$PREFIX"
      PREFIX=
      compadd $no_arg
    else
      false
    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
      false
    fi
    ;;
esac || { compadd - -${(k)^option_pairs:gs/://} && false }

--- 8< --- end of _complete_opts --- 8< ---

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


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

* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
  1999-07-20 18:05   ` CVS completer (Re: PATCH: Re: Completion/User functions again) Bart Schaefer
@ 1999-07-26  0:52     ` Tanaka Akira
  0 siblings, 0 replies; 17+ messages in thread
From: Tanaka Akira @ 1999-07-26  0:52 UTC (permalink / raw)
  To: zsh-workers

I think _complete_opts is bit verbose.

--- Completion/Base/_complete_opts-	Mon Jul 26 09:45:51 1999
+++ Completion/Base/_complete_opts	Mon Jul 26 09:46:49 1999
@@ -81,7 +81,9 @@
 esac
 
 if [[ -z "$done" ]]; then
-  compadd - -${(k)^option_pairs:gs/://}
+  if (( $+complete_opts_verbose )); then
+    compadd - -${(k)^option_pairs:gs/://}
+  fi
   false
 else
   true

-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 17+ 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; 17+ 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] 17+ messages in thread

* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
  1999-07-26 17:10         ` Tanaka Akira
@ 1999-07-27  8:15           ` Peter Stephenson
  1999-07-27  8:58             ` Tanaka Akira
  0 siblings, 1 reply; 17+ 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] 17+ 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  8:15           ` Peter Stephenson
  0 siblings, 1 reply; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ messages in thread

* Re: CVS completer (Re: PATCH: Re: Completion/User functions again)
@ 1999-07-22  6:43 Sven Wischnowsky
  0 siblings, 0 replies; 17+ messages in thread
From: Sven Wischnowsky @ 1999-07-22  6:43 UTC (permalink / raw)
  To: zsh-workers


Tanaka Akira wrote:

> > I think it should be replaced by 'compadd "$PREFIX"'.
> 
> The patch is follows.

Just for completeness' sake...

Bye
 Sven

diff -u -r oc/Base/_complete_opts Completion/Base/_complete_opts
--- oc/Base/_complete_opts	Thu Jul 22 08:35:45 1999
+++ Completion/Base/_complete_opts	Thu Jul 22 08:41:05 1999
@@ -18,7 +18,7 @@
 case "${#no_arg}-${#with_arg}" in
   0-0)
     if [[ x$PREFIX = x-* ]]; then
-      compadd - "$PREFIX"
+      compadd -nQ - "$PREFIX$SUFFIX"
     else
       done=''
     fi

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ 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; 17+ 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] 17+ messages in thread

* 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; 17+ 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] 17+ messages in thread

end of thread, other threads:[~1999-07-27  8:58 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-14 12:46 PATCH: Re: Completion/User functions again Sven Wischnowsky
1999-07-14 13:12 ` Tanaka Akira
1999-07-20 18:05   ` CVS completer (Re: PATCH: Re: Completion/User functions again) Bart Schaefer
1999-07-26  0:52     ` Tanaka Akira
1999-07-14 14:29 ` Completion/User functions again Oliver Kiddle
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  8:15           ` Peter Stephenson
1999-07-27  8:58             ` Tanaka Akira
1999-07-22  6:43 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).