Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: _description -x, _message -[JV]
- X-seq: zsh-workers 16609
- From: Sven Wischnowsky <wischnow@xxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: _description -x, _message -[JV]
- Date: Tue, 12 Feb 2002 14:34:25 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This is a part of the patch in 16565, namely the changes to make
_description and firends accept the -x option, passed on to compadd
and to make _message respect what any -[12JV] options it gets say
(i.e., the message will be added to that group).
Both changes make sense independent of other changes for the fake
style, so I can equally well add them separately.
Bye
Sven
Index: Completion/Base/Core/_all_labels
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_all_labels,v
retrieving revision 1.1
diff -u -r1.1 _all_labels
--- Completion/Base/Core/_all_labels 2 Apr 2001 11:02:44 -0000 1.1
+++ Completion/Base/Core/_all_labels 12 Feb 2002 13:34:29 -0000
@@ -1,16 +1,14 @@
#autoload
-local __gopt=-J __len __tmp __pre __suf __ret=1 __descr __spec __prev
+local __gopt __len __tmp __pre __suf __ret=1 __descr __spec __prev
if [[ "$1" = - ]]; then
__prev=-
shift
fi
-if [[ "$1" = -([12]|)[VJ] ]]; then
- __gopt="$1"
- shift
-fi
+__gopt=()
+zparseopts -D -a __gopt 1 2 V J x
__tmp=${argv[(ib:4:)-]}
__len=$#
@@ -29,12 +27,12 @@
_comp_tags="$_comp_tags $__spec "
if [[ "$curtag" = *[^\\]:* ]]; then
zformat -f __descr "${curtag#*:}" "d:$3"
- _description "$__gopt" "${curtag%:*}" "$2" "$__descr"
+ _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr"
curtag="${curtag%:*}"
"$4" "${(P@)2}" "${(@)argv[5,-1]}" && __ret=0
else
- _description "$__gopt" "$curtag" "$2" "$3"
+ _description "$__gopt[@]" "$curtag" "$2" "$3"
"${(@)argv[4,__pre]}" "${(P@)2}" "${(@)argv[__suf,-1]}" && __ret=0
fi
Index: Completion/Base/Core/_description
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_description,v
retrieving revision 1.3
diff -u -r1.3 _description
--- Completion/Base/Core/_description 22 Jan 2002 10:22:48 -0000 1.3
+++ Completion/Base/Core/_description 12 Feb 2002 13:34:29 -0000
@@ -1,13 +1,13 @@
#autoload
-local name gropt=-J format gname hidden hide match opts tag
+local name gropt nopt xopt format gname hidden hide match opts tag
opts=()
-if [[ "$1" = -([12]|)[VJ] ]]; then
- gropt="$1"
- shift
-fi
+gropt=(-J)
+xopt=(-X)
+nopt=()
+zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt
3="${${3##[[:blank:]]#}%%[[:blank:]]#}"
[[ -n "$3" ]] && _lastdescr=( "$_lastdescr[@]" "$3" )
@@ -62,15 +62,15 @@
if [[ -n "$gname" ]]; then
if [[ -n "$format" ]]; then
- set -A "$name" "$opts[@]" "$gropt" "$gname" -X "$format"
+ set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" "$xopt" "$format"
else
- set -A "$name" "$opts[@]" "$gropt" "$gname"
+ set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname"
fi
else
if [[ -n "$format" ]]; then
- set -A "$name" "$opts[@]" "$gropt" -default- -X "$format"
+ set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- "$xopt" "$format"
else
- set -A "$name" "$opts[@]" "$gropt" -default-
+ set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default-
fi
fi
Index: Completion/Base/Core/_message
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_message,v
retrieving revision 1.2
diff -u -r1.2 _message
--- Completion/Base/Core/_message 22 Jan 2002 10:22:48 -0000 1.2
+++ Completion/Base/Core/_message 12 Feb 2002 13:34:29 -0000
@@ -1,6 +1,6 @@
#autoload
-local format raw
+local format raw gopt
if [[ "$1" = -e ]]; then
local expl ret=1
@@ -15,6 +15,9 @@
return ret
fi
+gopt=()
+zparseopts -D -a gopt 1 2 V J
+
_tags messages || return 1
if [[ "$1" = -r ]]; then
@@ -28,6 +31,6 @@
if [[ -n "$format$raw" ]]; then
[[ -z "$raw" ]] && zformat -f format "$format" "d:$1" "${(@)argv[2,-1]}"
- builtin compadd -x "$format"
+ builtin compadd "$gopt[@]" -x "$format"
_comp_mesg=yes
fi
Index: Completion/Base/Core/_next_label
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_next_label,v
retrieving revision 1.1
diff -u -r1.1 _next_label
--- Completion/Base/Core/_next_label 2 Apr 2001 11:03:49 -0000 1.1
+++ Completion/Base/Core/_next_label 12 Feb 2002 13:34:29 -0000
@@ -1,21 +1,19 @@
#autoload
-local __gopt=-J __descr __spec
+local __gopt __descr __spec
-if [[ "$1" = -([12]|)[VJ] ]]; then
- __gopt="$1"
- shift
-fi
+__gopt=()
+zparseopts -D -a __gopt 1 2 V J x
if comptags -A "$1" curtag __spec; then
_comp_tags="$_comp_tags $__spec "
if [[ "$curtag" = *[^\\]:* ]]; then
zformat -f __descr "${curtag#*:}" "d:$3"
- _description "$__gopt" "${curtag%:*}" "$2" "$__descr"
+ _description "$__gopt[@]" "${curtag%:*}" "$2" "$__descr"
curtag="${curtag%:*}"
set -A $2 "${(P@)2}" "${(@)argv[4,-1]}"
else
- _description "$__gopt" "$curtag" "$2" "$3"
+ _description "$__gopt[@]" "$curtag" "$2" "$3"
set -A $2 "${(@)argv[4,-1]}" "${(P@)2}"
fi
Index: Completion/Base/Core/_requested
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_requested,v
retrieving revision 1.1
diff -u -r1.1 _requested
--- Completion/Base/Core/_requested 2 Apr 2001 11:04:20 -0000 1.1
+++ Completion/Base/Core/_requested 12 Feb 2002 13:34:29 -0000
@@ -1,17 +1,15 @@
#autoload
-local __gopt=-J
+local __gopt
-if [[ "$1" = -([12]|)[VJ] ]]; then
- __gopt="$1"
- shift
-fi
+__gopt=()
+zparseopts -D -a __gopt 1 2 V J x
if comptags -R "$1"; then
if [[ $# -gt 3 ]]; then
- _all_labels - "$__gopt" "$@" || return 1
+ _all_labels - "$__gopt[@]" "$@" || return 1
elif [[ $# -gt 1 ]]; then
- _description "$__gopt" "$@"
+ _description "$__gopt[@]" "$@"
fi
return 0
else
Index: Completion/Base/Core/_wanted
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_wanted,v
retrieving revision 1.1
diff -u -r1.1 _wanted
--- Completion/Base/Core/_wanted 2 Apr 2001 11:05:04 -0000 1.1
+++ Completion/Base/Core/_wanted 12 Feb 2002 13:34:29 -0000
@@ -1,26 +1,15 @@
#autoload
-local __targs __gopt=-J
+local __targs __gopt
-if [[ "$1" = -C?* ]]; then
- __targs=( -C "${1[3,-1]}" )
- shift
-elif [[ "$1" = -C ]]; then
- __targs=( -C "$2" )
- shift 2
-else
- __targs=()
-fi
-
-if [[ "$1" = -([12]|)[VJ] ]]; then
- __gopt="$1"
- shift
-fi
+__gopt=()
+__tagrs=()
+zparseopts -D -a __gopt 1 2 V J x C:=__targs
_tags "$__targs[@]" "$1"
while _tags; do
- _all_labels "$__gopt" "$@" && return 0
+ _all_labels "$__gopt[@]" "$@" && return 0
done
return 1
Index: Doc/Zsh/compsys.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/compsys.yo,v
retrieving revision 1.142
diff -u -r1.142 compsys.yo
--- Doc/Zsh/compsys.yo 26 Jan 2002 21:08:26 -0000 1.142
+++ Doc/Zsh/compsys.yo 12 Feb 2002 13:34:30 -0000
@@ -2930,7 +2930,7 @@
startitem()
findex(_all_labels)
-item(tt(_all_labels) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(args) ... ])(
+item(tt(_all_labels) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(command) var(args) ... ])(
This is a convenient interface to the tt(_next_label) function below,
implementing the loop shown in the tt(_next_label) example. The
var(command) is the one that should be called to generate the matches. The
@@ -3587,7 +3587,7 @@
it does not need to appear inside a loop over tag labels.
)
findex(_description)
-item(tt(_description) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(specs) ... ])(
+item(tt(_description) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(specs) ... ])(
This function is called before completions are added (typically by a call
to tt(compadd)); it tests various styles and arranges for any necessary
options to be passed on to tt(compadd). The styles are tested in the
@@ -3609,7 +3609,10 @@
tt(_description) is called with more than three arguments,
the additional var(specs) should be of the form `var(char)tt(:)var(str)'
and every appearance of `tt(%)var(char)' in the format string will be
-replaced by var(string).
+replaced by var(string). If the tt(-x) option is given, the
+description will be added using the tt(-x) option instead of the
+default tt(-X), i.e. the description will even be displayed if no
+matches are added for the description.
The options placed in the array will also make sure that the matches
are placed in a separate group, depending on the value of the
@@ -3692,7 +3695,7 @@
followed by another character, only options are completed.
)
findex(_message)
-xitem(tt(_message) [ tt(-r) ] var(descr))
+xitem(tt(_message) [ tt(-r12) ] [ tt(-VJ) var(group) ] var(descr))
item(tt(_message -e) var(tag descr))(
The var(descr) is used like the third
argument to the tt(_description) function. However, the resulting
@@ -3709,6 +3712,9 @@
where that string is taken from some pre-processed argument list
containing an expanded description.
+The tt(-12VJ) options and the var(group) are passed to tt(compadd) and
+hence determine the group the message string is added to.
+
In the second form, the var(descr) is added like a description added
by tt(_description) under the given var(tag), but the var(descr) will
always be shown even if no matches are added for the var(tag).
@@ -3741,13 +3747,13 @@
them to the tt(compadd) builtin.
)
findex(_next_label)
-item(tt(_next_label) [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(options) ... ])(
+item(tt(_next_label) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(options) ... ])(
This function should be called repeatedly to generate the tag
labels. On each call it will check if another tag label is to be used
and, if there is at least one, zero is returned. If no more tag
labels are to be used, a non-zero status is returned.
-The tt(-12JV) options and the first three arguments are given to the
+The tt(-x12VJ) options and the first three arguments are given to the
tt(_description) function using the tag label instead of the first
argument as appropriate. The var(options) given after the var(descr)
should be other options to be used for tt(compadd) or whatever
@@ -3932,7 +3938,7 @@
enditem()
)
findex(_requested)
-item(tt(_requested) [ tt(-12VJ) ] var(tag) [ var(name) var(descr) [ var(command) var(args) ... ] ])(
+item(tt(_requested) [ tt(-x) ] [ tt(-12VJ) ] var(tag) [ var(name) var(descr) [ var(command) var(args) ... ] ])(
This function is called to decide whether a tag already registered by a
call to tt(_tags) (see below) is requested and hence completion should be
performed for it; it returns status zero if the tag is requested and
@@ -4159,7 +4165,7 @@
of tt(context) (as described above).
)
findex(_wanted)
-item(tt(_wanted) [ tt(-C) var(name) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) var(command) var(args) ...)(
+item(tt(_wanted) [ tt(-x) ] [ tt(-C) var(name) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) var(command) var(args) ...)(
In many contexts, completion will generate one particular set of
matches (usually corresponding to a single tag); however, it is
still necessary to decide whether the user requires matches of this type.
@@ -4183,7 +4189,8 @@
that have to be passed down to tt(compadd).
Like tt(_tags) this function supports the tt(-C) option to give a
-different name for the argument context field.
+different name for the argument context field. The tt(-x) option has
+the same meaning as for tt(_description).
)
enditem()
--
Sven Wischnowsky wischnow@xxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author