1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-22 11:51:04 +02:00

support automatically inserted dummy in $words

This commit is contained in:
Sven Wischnowsky 2000-04-05 12:06:30 +00:00
parent b8bdb144d2
commit 80ac43783a
3 changed files with 27 additions and 1 deletions

View File

@ -4,6 +4,9 @@
2000-04-05 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
* 10514: Completion/Base/_arguments, Doc/Zsh/compsys.yo:
support automatically inserted dummy in $words
* 10511: Completion/Debian/_apt, Completion/Debian/_bug,
Completion/Debian/_dpkg, Completion/User/_chown,
Completion/User/_dvi, Completion/User/_imagemagick,

View File

@ -192,6 +192,12 @@ if (( $# )) && comparguments -i "$autod" "$@"; then
if [[ -n "$matched" ]] || _requested arguments; then
_description arguments expl "$descr"
if [[ "$action" = \=\ * ]]; then
action="$action[3,-1]"
words=( "$subc" "$words[@]" )
(( CURRENT++ ))
fi
if [[ "$action" = -\>* ]]; then
comparguments -W line opt_args
state="${${action[3,-1]##[ ]#}%%[ ]#}"

View File

@ -2497,7 +2497,7 @@ using the var(specs) which are of the form:
using tt(_tags) and if the tag is requested, the var(action) is
executed with the given var(descr) (description). The var(action)s
supported are those used by the tt(_arguments) function (described
below), without the `tt(->)var(state)' form.
below), without the `tt(->)var(state)' and `tt(=)var(...)' forms.
For example, the var(action) may be a simple function call. With that
one could do:
@ -2794,6 +2794,23 @@ are taken from the array parameter tt(expl) which will be set up
before executing the var(action) and hence may be used in it (normally
in an expansion like `tt($expl[@])').
If the var(action) starts with `tt(= )' (a equal sign followed by a
space), tt(_arguments) will insert the contents of the var(argument)
field of the current context as the new first element in the tt(words)
special array and increments the value of the tt(CURRENT) special
parameter. In other words, it inserts a dummy element in the tt(words)
array and makes tt(CURRENT) still point to the word in that array
where the cursor is. This is only really useful when used with one of
the forms that make tt(_arguments) modify the tt(words) array to
contain only some of the words from the line, i.e. one of the argument
description forms where the var(message) is preceded by two or three
colons. For example, when the function called in the action for such
an argument itself uses tt(_arguments), the dummy element is needed to
make that second call to tt(_arguments) use all words from the
restricted range for argument parsing. Without the inserted dummy
element, the first word in the range would be taken (by the second
tt(_arguments)) to be the command name and hence ignored.
Except for the `tt(->)var(string)' form, the var(action) will be
executed by calling the tt(_all_labels) function to process all tag labels,
so one doesn't need to call that explicitly unless another tag is to