* PATCH: _complete_help with _value:VAR functions
@ 2002-01-03 18:20 Oliver Kiddle
0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2002-01-03 18:20 UTC (permalink / raw)
To: zsh-workers
_complete_help doesn't work too well with functions that have a colon
in their name. This results in things not working to well with, for
example _value:DISPLAY. Try: DISPLAY=^Xh
The problem is the use of `:' as a separator character. This patch
changes it to use the nul character. I also reformatted the function a
bit in the process of trying to understand it - mostly use of $'\n' (to
preserve indentation) and += (to shorten assignments). I hope no one
minds.
It might be a good idea if we replace the _value: functions with a
$_comp_values companion to $_comps and add a -v option to compdef.
Oliver
Index: Completion/Base/Widget/_complete_help
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Widget/_complete_help,v
retrieving revision 1.3
diff -u -r1.3 _complete_help
--- Completion/Base/Widget/_complete_help 2001/06/21 10:05:19 1.3
+++ Completion/Base/Widget/_complete_help 2002/01/03 18:15:53
@@ -14,8 +14,8 @@
if [[ "$help_sfuncs[$2]" != *${_f}* ||
"$help_styles[${2}${_f}]" != *${3}* ]]; then
- [[ "$help_sfuncs[$2]" != *${_f}* ]] &&
- help_sfuncs[$2]="${help_sfuncs[$2]}:${_f}"
+
+ [[ "$help_sfuncs[$2]" != *${_f}* ]] && help_sfuncs[$2]+=$'\0'"${_f}"
local _t
case "$1" in
@@ -24,7 +24,7 @@
-h) _t='[assoc] ';;
*) _t='[boolean]';;
esac
- help_styles[${2}${_f}]="${help_styles[${2}${_f}]},${_t} ${3}:${_f}"
+ help_styles[${2}${_f}]+=",${_t} ${3}:${_f}"
fi
# No need to call the completers more than once with different match specs.
@@ -43,32 +43,27 @@
trap - EXIT INT
for i in "${(@ok)help_funcs}"; do
- text="${text}
-tags in context :completion:${i}:"
+ text+=$'\n'"tags in context :completion:${i}:"
tmp=()
- for j in "${(@s.:.)help_funcs[$i][2,-1]}"; do
- tmp=( "$tmp[@]" "${(@s.,.)help_tags[${i}${j}][2,-1]}" )
+ for j in "${(@ps.\0.)help_funcs[$i][2,-1]}"; do
+ tmp+=( "${(@s.,.)help_tags[${i}${j}][2,-1]}" )
done
zformat -a tmp ' (' "$tmp[@]"
- tmp=( '
- '${^tmp}')' )
- text="${text}${tmp}"
+ tmp=( $'\n '${^tmp}')' )
+ text+="${tmp}"
done
if [[ ${NUMERIC:-1} -ne 1 ]]; then
- text="$text
-"
+ text+=$'\n'
for i in "${(@ok)help_sfuncs}"; do
- text="${text}
-styles in context ${i}"
+ text+=$'\n'"styles in context ${i}"
tmp=()
- for j in "${(@s.:.)help_sfuncs[$i][2,-1]}"; do
- tmp=( "$tmp[@]" "${(@s.,.)help_styles[${i}${j}][2,-1]}" )
+ for j in "${(@ps.\0.)help_sfuncs[$i][2,-1]}"; do
+ tmp+=( "${(@s.,.)help_styles[${i}${j}][2,-1]}" )
done
zformat -a tmp ' (' "$tmp[@]"
- tmp=( '
- '${^tmp}')' )
- text="${text}${tmp}"
+ tmp=( $'\n '${^tmp}')' )
+ text+="${tmp}"
done
fi
compstate[list]='list force'
@@ -83,8 +78,8 @@
if [[ "$help_funcs[$curcontext]" != *${f}* ||
"$help_tags[${curcontext}${f}]" != *(${(j:|:)~argv})* ]]; then
[[ "$help_funcs[$curcontext]" != *${f}* ]] &&
- help_funcs[$curcontext]="${help_funcs[$curcontext]}:${f}"
- help_tags[${curcontext}${f}]="${help_tags[${curcontext}${f}]},${argv}:${f}"
+ help_funcs[$curcontext]+=$'\0'"${f}"
+ help_tags[${curcontext}${f}]+=",${argv}:${f}"
comptry "$@"
fi
}
This email has been scanned for all viruses by the MessageLabs SkyScan service. For more information on a pro-active anti-virus service working around the clock, around the globe visit http://www.messagelabs.com/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-01-03 18:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-03 18:20 PATCH: _complete_help with _value:VAR functions Oliver Kiddle
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).