From 86f38401aacfcd9b3ef6cb54faf305f7c843e60b Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Thu, 23 May 2002 12:20:15 +0000 Subject: for automatic long options completion, use the string after the equal signs (from the --help-text) as the description to shown when completing after the option (17214) --- Completion/Base/Utility/_arguments | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'Completion/Base') diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index b60e76342..fe8edd61a 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -79,7 +79,7 @@ if (( long )); then # Using (( ... )) gives a parse error. let "$tmpargv[(I)(|\([^\)]#\))(|\*)${opt}(|[-+]|=(|-))(|\[*\])(|:*)]" || - tmp=( "$tmp[@]" "$opt" ) + tmp=( "$tmp[@]" "$lopts[(r)$opt(|=*)]" ) done lopts=( "$tmp[@]" ) @@ -102,7 +102,7 @@ if (( long )); then # makes those options be completed without an argument description. set -- "$@" '*=FILE*:file:_files' \ - '*=(DIR|PATH)*:directory:_files -/' '*: : ' + '*=(DIR|PATH)*:directory:_files -/' '*=*:=: ' '*: : ' while (( $# )); do @@ -136,12 +136,19 @@ if (( long )); then tmpo=("${(@M)tmp:#*\[\=*}") if (( $#tmpo )); then tmp=("${(@)tmp:#*\[\=*}") - tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") - if [[ "$descr" = ::* ]]; then - cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" ) + if [[ "$descr" = :\=* ]]; then + for opt in "$tmpo[@]"; do + cache=( "$cache[@]" + "${${opt%%\=*}//[^a-zA-Z0-9-]}=::${(L)${opt%\]}#*\=}: " ) + done else - cache=( "$cache[@]" "${(@)^tmpo}=${dir}:${descr}" ) + tmpo=("${(@)${(@)tmpo%%\=*}//[^a-zA-Z0-9-]}") + if [[ "$descr" = ::* ]]; then + cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" ) + else + cache=( "$cache[@]" "${(@)^tmpo}=${dir}:${descr}" ) + fi fi fi @@ -150,9 +157,17 @@ if (( long )); then tmpo=("${(@M)tmp:#*\=*}") if (( $#tmpo )); then tmp=("${(@)tmp:#*\=*}") - tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") - cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" ) + if [[ "$descr" = :\=* ]]; then + for opt in "$tmpo[@]"; do + cache=( "$cache[@]" + "${${opt%%\=*}//[^a-zA-Z0-9-]}=:${(L)${opt%\]}#*\=}: " ) + done + else + tmpo=("${(@)${(@)tmpo%%\=*}//[^a-z0-9-]}") + + cache=( "$cache[@]" "${(@)^tmpo}=${dir}${descr}" ) + fi fi # Everything else is just added as an option without arguments or -- cgit 1.4.1