From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4862 invoked from network); 4 Nov 1999 13:50:09 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 4 Nov 1999 13:50:09 -0000 Received: (qmail 16143 invoked by alias); 4 Nov 1999 13:50:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8537 Received: (qmail 16135 invoked from network); 4 Nov 1999 13:50:03 -0000 Date: Thu, 4 Nov 1999 14:50:01 +0100 (MET) Message-Id: <199911041350.OAA01369@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Sven Wischnowsky's message of Thu, 4 Nov 1999 10:32:43 +0100 (MET) Subject: Re: completion grouping (I'm beginning to think that maybe everyone should apply 8520 and 8533 even though I said otherwise in 8520 -- it's probably easier to build/change that than to keep different versions alive.) I wrote: > I also forgot to mention another thing that may be interesting: I > already used the style-stuff for `describe_option' and friends. That > was easy to think about because they allowed definitions on a per- > command basis already. But ther may be other things we currently use > config keys for which may be interesting to turn into styles so that > we can define them differently for different commands (the `ps_*' keys > come to mind, but that may be a bad example). If we do that, however, > we probably should think about some standard structure for defining > styles. Things like multiple styles (separated by commas?), styles > with values (`[style_a=foo,style_b=bar]' or something like that). If > this turns out to be useful, I would like change `_tags' to report > styles in a format that is easier to parse in the calling functions. When hacking the tags stuff I first thought about storing the definitions in `compconfig'. The I decided against that because for tags we need a more convenient way to modify the entries than what `compconf' offers (where it isn't needed). After having a look at the keys as listed in the compsys doc, I'm back again at the idea to combine configuration definitions and tag definitions -- but this time the other way round. There are only very few config keys for which it is really completely unnecessary to let user define them per-command. For several keys it would be rather weird to define different values, but that never kept us from doing things. So, maybe we should try to look at it from this point of view and see what comes of it... (per-command completer-key? ouch! ;-) We'll need an easy way to define per-tag defaults and some kind of agreement about what to do with keys that must not have more than one value, and we should probably try to make this look less tag-centered (with styles looking only like some random add-on), etc. This patch finally adds `_pids' to complete process ids and make the functions use it. It also adds the `-i' option to `_tags' which means `immediately' and can be used like `_tags -i foo || return 1' to name a tag and immediately check if matches of that type are wanted. Otherwise there isn't much... I just had some time while waiting for a compiler run. Bye Sven diff -u -r oldcompletion/Base/_describe Completion/Base/_describe --- oldcompletion/Base/_describe Thu Nov 4 10:33:55 1999 +++ Completion/Base/_describe Thu Nov 4 14:32:45 1999 @@ -23,9 +23,7 @@ # Do the tests. `showd' is set if the descriptions should be shown. -_tags -c "$cmd" -f "$func" "$type" - -_tags || return 1 +_tags -i -c "$cmd" -f "$func" "$type" || return 1 [[ "$tags" = *:${type}\[*describe*\]* ]] && showd=yes diff -u -r oldcompletion/Base/_values Completion/Base/_values --- oldcompletion/Base/_values Thu Nov 4 10:33:55 1999 +++ Completion/Base/_values Thu Nov 4 14:32:10 1999 @@ -6,8 +6,7 @@ if ! compvalues -D descr action; then - _tags value - _tags || return 1 + _tags -i value || return 1 compvalues -V noargs args opts @@ -52,8 +51,7 @@ fi fi - _tags argument - _tags || return 1 + _tags -i argument || return 1 _description expl "$descr" diff -u -r oldcompletion/Builtins/_kill Completion/Builtins/_kill --- oldcompletion/Builtins/_kill Thu Nov 4 10:33:56 1999 +++ Completion/Builtins/_kill Thu Nov 4 14:32:05 1999 @@ -1,24 +1,21 @@ #compdef kill -local list expl +local tags list expl if compset -P 1 -; then + + _tags -i signal || return 1 + _description expl signal compadd "$expl[@]" $signals[1,-3] else - local tags ret=1 + local ret=1 _tags job process while _tags; do - [[ "$tags" = *:job:* ]] && _jobs && ret=0 - if [[ "$tags" = *:process:* ]]; then - list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}") - _description expl 'process ID' - compadd "$expl[@]" -ld list - \ - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && - ret=0 - fi + [[ "$tags" = *:job:* ]] && _jobs && ret=0 + [[ "$tags" = *:process:* ]] && _pids && ret=0 (( ret )) || break done diff -u -r oldcompletion/Builtins/_pids Completion/Builtins/_pids --- oldcompletion/Builtins/_pids Thu Nov 4 13:48:35 1999 +++ Completion/Builtins/_pids Thu Nov 4 14:28:00 1999 @@ -0,0 +1,18 @@ +#autoload + +# If given the `-m ' option, this tries to complete only pids +# of processes whose command line match the `'. + +local list expl match + +if [[ "$1" = -m ]]; then + match="${2}*" + shift 2 +fi + +_description expl 'process ID' + +list=("${(@Mr:COLUMNS-1:)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}") + +compadd "$expl[@]" "$@" -ld list - \ + ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]:#*${~match}}## #}%% *} diff -u -r oldcompletion/Builtins/_wait Completion/Builtins/_wait --- oldcompletion/Builtins/_wait Thu Nov 4 10:33:57 1999 +++ Completion/Builtins/_wait Thu Nov 4 13:41:11 1999 @@ -1,18 +1,12 @@ #compdef wait -local tags list ret=1 expl +local tags ret=1 _tags job process while _tags; do - [[ "$tags" = *:job:* ]] && _jobs && ret=0 - if [[ "$tags" = *:process:* ]]; then - list=("${(@M)${(f@)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*}") - _description expl 'process ID' - compadd "$expl[@]" -ld list - \ - ${${${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}[2,-1]## #}%% *} && - ret=0 - fi + [[ "$tags" = *:job:* ]] && _jobs && ret=0 + [[ "$tags" = *:process:* ]] && _pids && ret=0 (( ret )) || break done diff -u -r oldcompletion/Core/_tags Completion/Core/_tags --- oldcompletion/Core/_tags Thu Nov 4 10:34:00 1999 +++ Completion/Core/_tags Thu Nov 4 14:31:24 1999 @@ -2,13 +2,14 @@ if (( $# )); then local cmd="$words[1]" func="$funcstack[2]" defs i tags tag pat style prio + local trynow - while getopts 'c:f:' i; do - if [[ "$i" = c ]]; then - cmd="$OPTARG" - else - func="$OPTARG" - fi + while getopts 'c:f:i' i; do + case "$i" in + c) cmd="$OPTARG" ;; + f) func="$OPTARG" ;; + i) trynow=yes ;; + esac done shift OPTIND-1 @@ -67,7 +68,7 @@ _prio_names[$funcstack]="$prio" eval "${prio}=( \"\${(@)tags:#}\" )" - return 0 + [[ -z "$trynow" ]] && return 0 fi local prios="$_prio_names[$funcstack]" diff -u -r oldcompletion/User/_gdb Completion/User/_gdb --- oldcompletion/User/_gdb Thu Nov 4 10:34:03 1999 +++ Completion/User/_gdb Thu Nov 4 13:52:25 1999 @@ -21,20 +21,22 @@ _description expl option compadd "$expl[@]" -QS '' - -symbols\= -exec\= -se\= -core\= -command\= \ -directory\= -cd\= -tty\= - compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q -batch \ - -fullname -f -b + compadd "$expl[@]" - -help -h -s -e -c -x -d -nx -n -quiet -q \ + -batch -fullname -f -b else prev="$words[CURRENT-1]" case "$prev" in - (-d) _files -/ && return 0 ;; + (-d) _files -/ && return 0 ;; (-[csx]) _files && return 0 ;; - (-e) _description expl executable - _files "$expl[@]" -g '*(*)' && return 0 ;; - (-b) _description -V expl 'baud rate' - compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 2400 4800 \ - 9600 19200 38400 57600 115200 230400 && return 0 ;; + (-e) _description expl executable + _files "$expl[@]" -g '*(*)' && return 0 ;; + (-b) _description -V expl 'baud rate' + compadd "$expl[@]" 0 50 75 110 134 150 200 300 600 1200 1800 \ + 2400 4800 9600 19200 38400 57600 115200 \ + 230400 && return 0 ;; esac + w=( "${(@)words[2,-1]}" ) while [[ "$w[1]" = -* ]]; do [[ "$w[1]" = -[decsxb] ]] && shift 1 w @@ -42,10 +44,8 @@ done if [[ $#w -gt 1 ]]; then - _files && ret=0 - _description expl 'process ID' - list=("${(@M)${(f)$(ps ${=compconfig[ps_listargs]:-$=compconfig[ps_args]} 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${w[1]:t}*}") - compadd "$expl[@]" -ld list - ${${${(M)${(f)"$(ps $=compconfig[ps_args] 2>/dev/null)"}:#*${w[1]:t}*}## #}%% *} && ret=0 + _files && ret=0 + _pids -m "${w[1]:t}" && ret=0 return ret else -- Sven Wischnowsky wischnow@informatik.hu-berlin.de