From 3b9e0363689b06b61ef0533c6afe2b9287381bb4 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Fri, 12 Oct 2001 10:49:19 +0000 Subject: use _x_display when setting $DISPLAY and fix bug in enable completion (15594) --- ChangeLog | 4 +++ Completion/Zsh/Command/_enable | 8 ++++++ Completion/Zsh/Context/_value | 63 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 Completion/Zsh/Command/_enable create mode 100644 Completion/Zsh/Context/_value diff --git a/ChangeLog b/ChangeLog index d646c62fb..60b0ee31f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2001-10-12 Oliver Kiddle + * 15594: Completion/Zsh/Context/_value, + Completion/Zsh/Command/_enable: use _x_display when setting + $DISPLAY and fix substitution mistake in enable completion + * 15983: Completion/Unix/Command/_user_admin, Completion/Unix/Command/_sysctl, Completion/Unix/Type/_urls, Completion/Unix/Command/_webbrowser: darwin support in _sysctl, diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable new file mode 100644 index 000000000..380e3ba5d --- /dev/null +++ b/Completion/Zsh/Command/_enable @@ -0,0 +1,8 @@ +#compdef enable + +_arguments -C -s -A "-*" -S \ + "(-f -r)-a[act on aliases]:*:aliases:(${(k)dis_aliases})" \ + "(-a -r)-f[act on functions]:*:functions:(${(k)dis_functions})" \ + "(-a -f)-r[act on reserved words]:*:reserved-words:(${(k)dis_reswords})" \ + '-m[treat arguments as patterns]' \ + "*:builtin command:(${(k)dis_builtins})" diff --git a/Completion/Zsh/Context/_value b/Completion/Zsh/Context/_value new file mode 100644 index 000000000..cb2675c0e --- /dev/null +++ b/Completion/Zsh/Context/_value @@ -0,0 +1,63 @@ +#compdef -value- -array-value- + +_value () { + # You can customize completion for different parameters by writing a + # function `_value:', where is the name of the parameter. + # When completing values of elements of associative arrays, we first + # search for a function `_value:-' and then for + # `_value:', so it's simple to define different functions + # for different keys or one function for a whole association. + + if (( $+functions[_value:$compstate[parameter]] )); then + "_value:$compstate[parameter]" "$@" + elif (( $+functions[_value:${compstate[parameter]%%-*}] )); then + "_value:${compstate[parameter]%%-*}" "$@" + elif [[ "$compstate[parameter]" != *-* && + "${(Pt)${compstate[parameter]}}" = assoc* ]]; then + if (( CURRENT & 1 )); then + _wanted association-keys expl 'association key' \ + compadd -k "$compstate[parameter]" + else + compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}" + _value "$@" + fi + else + local pats + + if { zstyle -a ":completion:${curcontext}:" assign-list pats && + [[ "$compstate[parameter]" = (${(j:|:)~pats}) ]] } || + [[ "$PREFIX$SUFFIX" = *:* ]]; then + compset -P '*:' + compset -S ':*' + _default -r '\-\n\t /:' "$@" + else + _default "$@" + fi + fi +} + +_value:CPPFLAGS () { + compset -q + if compset -P '-I'; then + _files -/ "$@" + else + _default "$@" + fi +} + +_value:LDFLAGS () { + compset -q + if compset -P '-L'; then + _files -/ "$@" + elif compset -P '-R'; then + compset -P '*:' + compset -S ':*' + _files -/ -S/ -r '\n\t\- /:' "$@" + else + _default "$@" + fi +} + +_value:DISPLAY() { _x_display "$@" } + +_value "$@" -- cgit 1.4.1