From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25268 invoked from network); 24 Aug 1999 09:13:47 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 24 Aug 1999 09:13:47 -0000 Received: (qmail 10927 invoked by alias); 24 Aug 1999 09:13:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7469 Received: (qmail 10909 invoked from network); 24 Aug 1999 09:13:35 -0000 Date: Tue, 24 Aug 1999 11:12:51 +0200 (MET DST) Message-Id: <199908240912.LAA08973@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Tanaka Akira's message of 24 Aug 1999 01:16:59 +0900 Subject: Re: PATCH: completion Tanaka Akira wrote: > It uses '-e:*::program: _normal' as the argument to _arguments and > `xterm -e ' works well. But `xterm -132 -e ' does not. > > ... > > This is because _arguments does not cut off words correctly, I think. Right, I overlooked one place... This also changes `_x_options' to be a post pattern function (so that we don't get those stray X11 options in places where we don't want them), and it cleans up the `_compskip' handling. It also makes `_command_names' accept the option `-e' to make it complete only external commands and executable files -- which is then used in `_xterm'. Bye Sven diff -u -r oc/Base/_arguments Completion/Base/_arguments --- oc/Base/_arguments Mon Aug 23 15:48:18 1999 +++ Completion/Base/_arguments Tue Aug 24 10:31:34 1999 @@ -188,6 +188,8 @@ # associative array so that we don't offer them again. def="$opts[$ws[1]]" + optbeg="$beg" + argbeg="$beg" [[ -n "$oneshot[$ws[1]]" ]] && unset "opts[$ws[1]]" else uns='' diff -u -r oc/Base/_command_names Completion/Base/_command_names --- oc/Base/_command_names Mon Aug 23 11:42:44 1999 +++ Completion/Base/_command_names Tue Aug 24 11:09:44 1999 @@ -1,21 +1,31 @@ #compdef -command- -local nm=$compstate[nmatches] ret=1 expl +# The option `-e' if given as the first argument says that we should +# complete only external commands and executable files. This and a +# `-' as the first argument is then removed from the arguments. +local nm=$compstate[nmatches] ret=1 expl type=-c + +if [[ "$1" = -e ]]; then + type=-m + shift +elif [[ "$1" = - ]]; then + shift +fi # Complete jobs in implicit fg and bg -if [[ "$PREFIX[1]" = "%" ]]; then +if [[ $type = -c && "$PREFIX[1]" = "%" ]]; then _description expl job - compgen "$expl[@]" -j -P '%' + compgen "$expl[@]" "$@" -j -P '%' [[ nm -ne compstate[nmatches] ]] && return fi _description expl command -compgen "$expl[@]" -c && ret=0 +compgen "$expl[@]" "$@" $type && ret=0 if [[ nm -eq compstate[nmatches] ]]; then _description expl 'executable file or directory' - _path_files "$expl[@]" -/g "*(*)" + _path_files "$expl[@]" "$@" -/g "*(*)" else return ret fi diff -u -r oc/Builtins/_zftp Completion/Builtins/_zftp --- oc/Builtins/_zftp Mon Aug 23 11:42:46 1999 +++ Completion/Builtins/_zftp Tue Aug 24 10:56:09 1999 @@ -62,7 +62,7 @@ *) # dunno... try ordinary completion after all. - unset _compskip + _compskip='' return 1 ;; esac diff -u -r oc/Core/_complete Completion/Core/_complete --- oc/Core/_complete Mon Aug 23 11:42:47 1999 +++ Completion/Core/_complete Tue Aug 24 10:54:34 1999 @@ -21,7 +21,7 @@ if [[ ! -z "$comp" ]]; then "$comp" if [[ "$_compskip" = all ]]; then - unset _compskip + _compskip='' (( compstate[nmatches] )) return fi @@ -55,7 +55,7 @@ if [[ -z "$comp" ]]; then if [[ "$_compskip" = *default* ]]; then - unset _compskip + _compskip='' return 1 fi comp="$_comps[-default-]" @@ -63,6 +63,6 @@ [[ -z "$comp" ]] || "$comp" fi -unset _compskip +_compskip='' (( compstate[nmatches] )) diff -u -r oc/Core/_main_complete Completion/Core/_main_complete --- oc/Core/_main_complete Mon Aug 23 11:42:47 1999 +++ Completion/Core/_main_complete Tue Aug 24 10:54:09 1999 @@ -98,6 +98,4 @@ _lastcomp[qiprefix]="$QIPREFIX" _lastcomp[qisuffix]="$QISUFFIX" -unset _compskip - return ret diff -u -r oc/Core/_normal Completion/Core/_normal --- oc/Core/_normal Mon Aug 23 11:42:47 1999 +++ Completion/Core/_normal Tue Aug 24 10:57:05 1999 @@ -1,6 +1,6 @@ #autoload -local comp command cmd1 cmd2 pat val name i ret=1 +local comp command cmd1 cmd2 pat val name i ret=1 _compskip="$_compskip" # Completing in command position? If not we set up `cmd1' and `cmd2' as # two strings we have to search in the completion definition arrays (e.g. @@ -38,7 +38,7 @@ if [[ "$_compskip" = *patterns* ]]; then break elif [[ "$_compskip" = all ]]; then - unset _compskip + _compskip='' return ret fi fi @@ -67,7 +67,7 @@ comp="$_comps[-default-]" fi fi - + if [[ "$_compskip" != (all|*patterns*) ]]; then for i in "$_postpatcomps[@]"; do pat="${i% *}" @@ -78,7 +78,7 @@ if [[ "$_compskip" = *patterns* ]]; then break elif [[ "$_compskip" = all ]]; then - unset _compskip + _compskip='' return ret fi fi @@ -88,6 +88,6 @@ [[ "$name" = -default- && -n "$comp" && "$_compskip" != (all|*default*) ]] && "$comp" && ret=0 -unset _compskip +_compskip='' return ret diff -u -r oc/User/_x_display Completion/User/_x_display --- oc/User/_x_display Tue Aug 24 10:58:52 1999 +++ Completion/User/_x_display Tue Aug 24 10:49:48 1999 @@ -0,0 +1,3 @@ +#autoload + +_hosts -S ':0 ' -r : diff -u -r oc/User/_x_options Completion/User/_x_options --- oc/User/_x_options Mon Aug 23 11:42:56 1999 +++ Completion/User/_x_options Tue Aug 24 10:49:55 1999 @@ -1,12 +1,11 @@ -#compdef -p */X11/* +#compdef -P */X11/* local expl # A simple pattern completion, just as an example. if [ "$words[CURRENT-1]" = "-display" ]; then - _compskip=all - _hosts -S ':0 ' -r : + _x_display else _description expl option compadd "$expl[@]" - -display -name -xrm diff -u -r oc/User/_xterm Completion/User/_xterm --- oc/User/_xterm Tue Aug 24 10:56:42 1999 +++ Completion/User/_xterm Tue Aug 24 11:09:59 1999 @@ -19,7 +19,7 @@ '-cr:text cursor color:_color' \ '-cu' '+cu' \ '-dc' '+dc' \ - '-e:*::program: _normal' \ + '-e:program: _command_names -e:*::program arguments: _normal' \ '-fb:bold font:' \ '-fi:icon font:' \ '-hc:background color for highlighted text:_color' \ @@ -61,7 +61,7 @@ '-bd:border color:_color' \ '-bg:background color:_color' \ '-bw:border width:' \ - '-display:display:' \ + '-display:display:_x_display' \ '-fg:foreground color:_color' \ '-fn:font:' \ '-geometry:geometry:' \ -- Sven Wischnowsky wischnow@informatik.hu-berlin.de