From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28777 invoked from network); 26 Aug 1999 13:52:40 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 26 Aug 1999 13:52:39 -0000 Received: (qmail 20197 invoked by alias); 26 Aug 1999 13:52:30 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7505 Received: (qmail 20189 invoked from network); 26 Aug 1999 13:52:30 -0000 Date: Thu, 26 Aug 1999 15:52:24 +0200 (MET DST) Message-Id: <199908261352.PAA16045@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Tanaka Akira's message of 26 Aug 1999 22:17:14 +0900 Subject: Re: PATCH: completion Tanaka Akira wrote: > Hm. `cvs -e vi ' works now. Thanks. > But common options are too disabled. > > Z(2):akr@is27e1u11% ./Src/zsh -f > is27e1u11% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst > is27e1u11% compconf group_matches=yes > is27e1u11% compconf message_format='%d' > is27e1u11% compconf description_format='%d' > is27e1u11% cvs > add commit export log release tag watchers > admin diff history login remove unedit > annotate edit import logout rtag update > checkout editors init rdiff status watch > > In this case, the cursor is on first non-option argument *or* option > argument. So, _arguments should complete options addition to call > _cvs_command, I suppose. > > Or, should _cvs be changed to > "_arguments ... ':cvs command:_cvs_commands' '*::cvs command arguments:_cvs_args'" ? I /think/ we should help users and add some special casing to allow options in the first rest-arguments position. > is27e1u11% cvs -evi > unknown cvs command: -evi > > Hm. Should work now (this functions has already become more complicated than `_path_files' -- makes me reluctant to merge it with `_long_options', although that would be a good thing). Bye Sven --- oc/Base/_arguments Thu Aug 26 14:06:15 1999 +++ Completion/Base/_arguments Thu Aug 26 15:48:01 1999 @@ -7,7 +7,7 @@ local long args rest ws cur nth def nm expl descr action opt arg tmp local single uns ret=1 soptseq soptseq1 sopts prefix line -local beg optbeg argbeg nargbeg inopt +local beg optbeg argbeg nargbeg inopt fromrest # Associative arrays used to collect information about the options. @@ -236,7 +236,7 @@ def="$opts[$tmp]" optbeg="$beg" argbeg="$beg" - inopt=yes + inopt=yes uns="${ws[1][2,-1]}" opt='' fi @@ -277,10 +277,10 @@ def="$dopts[$tmp[1]]" optbeg="$beg" argbeg="$beg" + inopt=yes [[ -n "$oneshot[$tmp[1]]" ]] && unset "dopts[$tmp[1]]" if [[ "$def" = [^*]*[^\\]:*[^\\]:* ]]; then def="${def#?*[^\\]:*[^\\]:}" - inopt=yes else def='' fi @@ -305,6 +305,7 @@ def="$odopts[$tmp[1]]" optbeg="$beg" argbeg="$beg" + inopt=yes [[ -n "$oneshot[$tmp[1]]" ]] && unset "odopts[$tmp[1]]" # For options whose first argument *may* come after the @@ -318,7 +319,6 @@ def="${def#?*[^\\]:*[^\\]:}" optbeg="$beg" argbeg="$beg" - inopt=yes else def='' fi @@ -358,7 +358,7 @@ (( beg++ )) done -[[ -n "$inopt" ]] && nargbeg="$beg" +[[ -n "$inopt" ]] && nargbeg=$(( beg - 1 )) # Now generate the matches. @@ -390,6 +390,7 @@ def="$rest" optbeg="$nargbeg" argbeg="$nargbeg" + fromrest=yes fi fi @@ -453,7 +454,8 @@ (( $#tmp )) && unset "$tmp[@]" fi - if [[ -n "$opt" ]]; then + if [[ -n "$opt" && ( "$def" != \** || + ( -n "$fromrest" && CURRENT -eq argbeg+1 ) ) ]]; then # We aren't in an argument directly after a option name, so # all option names are possible matches. -- Sven Wischnowsky wischnow@informatik.hu-berlin.de