From c8d1071cd8ca5c92e7d75b5dda2be529da6755bd Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 27 Feb 2007 20:44:00 +0000 Subject: 23198: improve _values -s unposted: document _regex_words -t --- ChangeLog | 9 +++++++++ Completion/Base/Utility/_regex_words | 5 ++--- Completion/Base/Utility/_values | 2 +- Doc/Zsh/compsys.yo | 6 +++++- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8051dc78d..5d1ff2ef1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-02-27 Peter Stephenson + + * unposted: Doc/Zsh/compsys.yo: document now useful -t + option to _regex_words. + + * 23198: Completion/Base/Utility/_values, + Completion/Base/Utility/_regex_words: make _values -s more + useful and use for regex completions with non-standard suffixes. + 2007-02-27 Clint Adams * 23196: Completion/Debian/Command/_apt: tweak apt-cache madison diff --git a/Completion/Base/Utility/_regex_words b/Completion/Base/Utility/_regex_words index 1cc9e9ccc..77ba197a4 100644 --- a/Completion/Base/Utility/_regex_words +++ b/Completion/Base/Utility/_regex_words @@ -31,9 +31,8 @@ for (( i = 1; i <= $#; i++ )); do if [[ $term = $'\0' ]]; then reply+=(":${tag}:${desc}:(( ${wds[1]//\*}:${wds[2]//(#m)[: \(\)]/\\$MATCH} ))") else - # HERE: we should add the terminator instead of a space, but - # there doesn't appear to be an easy way of doing that. - reply+=(":${tag}:${desc}:(( ${wds[1]//\*}${term//(#m)[: \(\)]/\\$MATCH}:${wds[2]//(#m)[: \(\)]/\\$MATCH} ))") + reply+=(":${tag}:${desc}:_values -s ${(q)term} ${(q)desc} \ +${(q)${${wds[1]//\*}//(#m)[:\[\]]/\\$MATCH}}\\[${(q)${wds[2]//(#m)[:\[\]]/\\$MATCH}}\\]") fi eval "reply+=($wds[3])" if (( $i == $# )); then diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values index 5cfa4bd30..52c42bc70 100644 --- a/Completion/Base/Utility/_values +++ b/Completion/Base/Utility/_values @@ -50,7 +50,7 @@ if compvalues -i "$@"; then fi else compvalues -d descr - if [[ ${#noargs}+${#args}+${#opts} -ne 1 ]] && compvalues -s sep; then + if compvalues -s sep; then sep=( "-qS" "$sep" ) else sep=() diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index a0c38f8a0..de2fcc260 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -4351,7 +4351,7 @@ any argument. In this case tt(_regex_words) could be used to generate a suitable expression for the arguments. ) -findex(_regex_words) +findex(_regex_words [ tt(-t) var(term) ]) item(tt(_regex_words) var(tag) var(description) var(spec) ...)( This function can be used to generate arguments for the tt(_regex_arguments) command which may be inserted at any point where @@ -4379,6 +4379,10 @@ evaluated in order to avoid problems with quoting. This means that typically it contains a reference to an array containing previously generated regex arguments. +The option tt(-t) var(term) specifies a terminator for the word +instead of the usual space. This is handled as an auto-removable suffix +in the manner of the option tt(-s) var(sep) to tt(_values). + The result of the processing by tt(_regex_words) is placed in the array tt(reply), which should be made local to the calling function. If the set of words and arguments may be matched repeatedly, a tt(#) -- cgit 1.4.1