diff options
author | Oliver Kiddle <opk@zsh.org> | 2017-10-11 01:23:56 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2017-10-11 01:23:56 +0200 |
commit | 1a3a07a35f0bea5774297ccf2ab4ddd9b525fc94 (patch) | |
tree | 303b14bcc74de299cfee750b3811e3c0d7b6e571 | |
parent | 04a7dca3b0aa7659846e66415a2021b1562492f5 (diff) | |
download | zsh-1a3a07a35f0bea5774297ccf2ab4ddd9b525fc94.tar.gz zsh-1a3a07a35f0bea5774297ccf2ab4ddd9b525fc94.tar.xz zsh-1a3a07a35f0bea5774297ccf2ab4ddd9b525fc94.zip |
41849: handle both unexpand and expand in a single function
They have some commonalities and using _unexpand dodges around the clash with the _expand completer.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | Completion/Unix/Command/_expand_cmd | 16 | ||||
-rw-r--r-- | Completion/Unix/Command/_unexpand | 37 |
3 files changed, 26 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog index 0c80025ec..f0b8f2e12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2017-10-10 Oliver Kiddle <opk@zsh.org> + * 41849: Completion/Unix/Command/_unexpand: handle both unexpand + and expand in a single function: they have some commonalities + and it dodges around the clash with the _expand completer + * 41831: Completion/Unix/Type/_tilde_files, Completion/Unix/Command/_less, Completion/Unix/Command/_vorbis, Completion/Zsh/Type/_globquals: fix compset usage in ogg123 diff --git a/Completion/Unix/Command/_expand_cmd b/Completion/Unix/Command/_expand_cmd deleted file mode 100644 index 3f297dce2..000000000 --- a/Completion/Unix/Command/_expand_cmd +++ /dev/null @@ -1,16 +0,0 @@ -#compdef expand gexpand - -local -a args - -if _pick_variant gnu=GNU unix --version; then - args=( - '(-i --initial --help)'{-i,--initial}"[don't convert tabs after non blanks]" - '(-t --tabs --version)'{-t+,--tabs=}'[specify tab width]:list of tab positions' - '(* -)--help[display usage information]' - '(* -)--version[output version information]' - ) -else - args=( -A "-*" '(-t --tabs)'{-t+,--tabs=}'[specify tab width]:list of tab positions' ) -fi - -_arguments -s -S "$args[@]" '*:file:_files' diff --git a/Completion/Unix/Command/_unexpand b/Completion/Unix/Command/_unexpand index d9793ea70..13f6ce835 100644 --- a/Completion/Unix/Command/_unexpand +++ b/Completion/Unix/Command/_unexpand @@ -1,26 +1,33 @@ -#compdef unexpand gunexpand +#compdef unexpand gunexpand expand gexpand -local all tabs ret=1 +local all tabs local -a args all="convert all whitespace, instead of just initial whitespace" -tabs="use comma separated list of tab positions" -args=( - "(--all)-a[$all]" - "(--tabs)-t+[$tabs]:tablist" - '*:file:_files' -) +tabs="[use comma separated list of tab positions]:list of tab positions" if _pick_variant gnu="Free Soft" unix --version; then + if [[ $service = *un* ]]; then + args=( + "(-a --help --version)--all[$all]" + '(--help --version)--first-only[convert only leading sequences of whitespace]' + ) + else + args=( + '(-i --initial --help --version)'{-i,--initial}"[don't convert tabs after non blanks]" + ) + fi + args+=( - "(-a)--all[$all]" - '--first-only[convert only leading sequences of whitespace]' - "(-t)--tabs=[$tabs]:tablist" + "(-t --help --version)--tabs=${tabs}" '(* -)--help[display usage information]' - '(* -)--version[output version information]' + '(* -)--version[display version information]' ) +elif [[ $OSTYPE = (*bsd*|dragonfly*|darwin*) ]]; then + args=( -A "-*" ) fi +[[ $service = *un* ]] && args+=( "(--all --help --version)-a[$all]" ) -_arguments -s -S "$args[@]" && ret=0 - -return ret +_arguments -s -S "$args[@]" \ + "(--tabs --help)-t+${tabs}" \ + '*:file:_files' |