From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11369 invoked from network); 20 Aug 1999 23:23:17 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 20 Aug 1999 23:23:17 -0000 Received: (qmail 29189 invoked by alias); 20 Aug 1999 23:23:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7458 Received: (qmail 29181 invoked from network); 20 Aug 1999 23:23:07 -0000 To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: completion References: <199908201259.OAA00799@beta.informatik.hu-berlin.de> MIME-Version: 1.0 (generated by AKEMI 1.13.2 - =?ISO-2022-JP?B?Ig==?= =?ISO-2022-JP?B?GyRCQTA0Y0s8GyhCIg==?=) Content-Type: text/plain; charset=US-ASCII From: Tanaka Akira Date: 21 Aug 1999 08:22:55 +0900 In-Reply-To: Sven Wischnowsky's message of "Fri, 20 Aug 1999 14:59:20 +0200 (MET DST)" Message-ID: User-Agent: Chao-gnus/6.12.5 AKEMI/1.13.2 (=?ISO-2022-JP?B?GyRCQTAbKEI=?= =?ISO-2022-JP?B?GyRCNGNLPBsoQg==?=) FLAM-DOODLE/1.12.6 (=?ISO-2022-JP?B?GyRCM3cbKEI=?= 10R4.0/5.0) Emacs/20.4 (sparc-sun-solaris2.6) MULE/4.0 (HANANOEN) In article <199908201259.OAA00799@beta.informatik.hu-berlin.de>, Sven Wischnowsky writes: > Not that easy and some people probably don't like the way option names > are completed with this patch, but still... I tried to use this for "patch" and few problems are found and fixed. And I thought some about _arguments. 1. The help message may not suited for _long_options. For example, help message of "patch" contains: -p NUM --strip=NUM Strip NUM leading components from file names. The options are not separeted by ",". I avoid this problem by modifying the help message. # http://www.ldl.jaist.ac.jp/~akr/junk/patch-2.5.3-cvsaware-19990820.patch But, in general, help messages may not able to modify. Therefore I think it is useful that _arguments can handle options started with "--". # Also, if _arguments supports options started with "--" directly, # opt-spec to specify both "--xxx=yyy" and "--xxx yyy" at once may # useful. 2. I would like to refer the parsed arguments in completers. I think this is useful in many cases. For example, if the completer for port of telnet can refer host argument, it can complete ports precisely: "nntp" for news servers, "smtp" for mail servers, etc. If the completer for emacs can check whether the argument of -f is batch-byte-compile, we can complete only *.el. 3. "xterm -e" style. Some options take arguments up to end of command line. If _arguments supports this style of options, it is also useful for _cvs, I suppose. Because first non-option argument for cvs command behaves like that. For example, I would like to describe _cvs as: _cvs () { _arguments -s \ '-d:cvsroot:...' \ ... \ '**:subcommand:_cvs_subcommand' } _cvs_subcommand () { if [[ CURRENT = 1 ]]; then compadd -- add commit diff ... else case $words[1] in add) _arguments -s '-k+:keyword expansion:...' ...;; ... esac fi } Index: Completion/Base/_arguments =================================================================== RCS file: /projects/zsh/zsh/Completion/Base/_arguments,v retrieving revision 1.1.1.4 diff -u -F^( -r1.1.1.4 _arguments --- _arguments 1999/08/20 13:29:01 1.1.1.4 +++ _arguments 1999/08/20 22:25:02 @@ -158,12 +158,12 @@ else uns='' if [[ -n "$single" && "$ws[1]" = [-+]* ]]; then - if [[ $#opts -ne 0 && + if [[ ${#${(kj::)opts[(R)?*]#?}} -ne 0 && "$ws[1]" = ${ws[1][1]}*[${(kj::)opts[(R)?*]#?}] ]]; then def="$opts[${ws[1][1]}${ws[1][-1]}]" uns="${ws[1][2,-1]}" opt='' - elif [[ $#mopts -ne 0 && + elif [[ ${#${(kj::)mopts[(R)?*]#?}} -ne 0 && "$ws[1]" = ${ws[1][1]}*[${(kj::)mopts[(R)?*]#?}] ]]; then def="$mopts[${ws[1][1]}${ws[1][-1]}]" uns="${ws[1][2,-1]}" @@ -457,7 +457,7 @@ [[ $#long -ne 0 && ( "$compconfig[option_prefix]" != *(long|all)* || "$PREFIX" = --* ) ]] && \ - _long_options && ret=0 + _long_options "$long[@]" && ret=0 fi fi Index: Completion/Base/_long_options =================================================================== RCS file: /projects/zsh/zsh/Completion/Base/_long_options,v retrieving revision 1.1.1.7 diff -u -F^( -r1.1.1.7 _long_options --- _long_options 1999/08/19 14:41:32 1.1.1.7 +++ _long_options 1999/08/20 22:25:02 @@ -135,7 +135,7 @@ set -- "$@" '*=FILE*:file:_files' '*=(DIR|PATH)*:directory:_files -/' '*:unknown:' - while [[ $# -gt 1 ]]; do + while [[ $# -gt 0 ]]; do # First, we get the pattern and the action to use and take them # from the positional parameters. @@ -265,6 +265,8 @@ action=($=action) ${(e)action[1]} "$expl[@]" ${(e)~action[2,-1]} fi + else + _message "$descr" fi # We found the option string, return. Index: Completion/User/_patch =================================================================== RCS file: _patch diff -N _patch --- /dev/null Fri Apr 17 15:56:34 1998 +++ _patch Fri Aug 20 22:25:03 1999 @@ -0,0 +1,32 @@ +#compdef patch + +_arguments -s \ + '-p+:number:(0)' \ + '-F+:lines:' \ + '-l' '-c' '-e' '-n' '-u' '-N' '-R' \ + '-i+:patch file:_files' \ + '-o+:output file:_files' \ + '-r+:reject file:_files' \ + '-D+:name:' \ + '-E' '-Z' '-T' \ + '-b' \ + '-V+:version control style:(simple numbered existing)' \ + '-B+:backup path prefix:' \ + '-Y+:basename basename prefix:_files' \ + '-z+:backup file suffix:(.bak)' \ + '-g+:NUM:' \ + '-t' '-f' '-s' \ + '-d+:chdir to:_files -/' \ + '-v' \ + ':original file:_files' \ + ':patch file:_files' \ + -- \ + '*=NUM*:number:(0)' \ + '*=LINES*:lines:' \ + '*=PATCHFILE*:patch file:_files' \ + '*=FILE*:file:_files' \ + '*=NAME*:name:' \ + '*=WORD*:quoting style:(literal shell shell-always c escape)' \ + '*=STYLE*:version control style:(simple numbered existing)' \ + '*=SUFFIX*:backup file suffix:(.bak)' \ + '*=DIR*:chdir to:_files -/' -- Tanaka Akira