From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: another optional argument problem?
Date: Mon, 8 May 2000 12:36:04 +0200 (MET DST) [thread overview]
Message-ID: <200005081036.MAA20805@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Tanaka Akira's message of 06 May 2000 17:14:01 +0900
Tanaka Akira wrote:
> Z(5):akr@serein% Src/zsh -f
> serein% bindkey -e; autoload -U compinit; compinit -D; compdef _tst tst
> serein% _tst () { _arguments -s '-o::o:(o)' ':a:(a)' }
> serein% tst -o<TAB>
>
> It should inseart a space, I think.
Yep, because there is no other option.
In another message:
> I found a difference of empty action handling between _arguments and
> _alternative.
>
> Z(5):akr@serein% Src/zsh -f
> serein% bindkey -e; autoload -U compinit; compinit -D
> serein% zstyle ':completion:*:messages' format %d
> serein% compdef _tst1 tst1; _tst1 () { _arguments '-o::o:' ':a:' }
> serein% compdef _tst2 tst2; _tst2 () { _alternative 'option-o-1:o:' 'argument-1:a:' }
>
> serein% tst1 -o <TAB>
> a
>
> serein% tst2 <TAB>
> o
> a
>
> _arguments shows only `a' but _alternative shows both.
That complicated message handling in _arguments. I should have changed
that when I added `compadd -x'.
> They has tags
> `option-o-1' and `argument-1' orderd by defafult tag-order specified
> in _tags. Is this intentional?
Yes. This was caused by _argument_sets. Without this change that would
use the same tag more than once for different completions.
Bye
Sven
Index: Completion/Base/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.11
diff -u -r1.11 _arguments
--- Completion/Base/_arguments 2000/05/08 08:58:37 1.11
+++ Completion/Base/_arguments 2000/05/08 10:35:47
@@ -234,9 +234,8 @@
# An empty action means that we should just display a message.
- [[ -n "$matched" ]] &&
- compadd -n -Q -S '' -s "$SUFFIX" - "$PREFIX"
- mesg="$descr"
+ _message "$descr"
+ mesg=yes
elif [[ "$action" = \(\(*\)\) ]]; then
@@ -361,7 +360,6 @@
[[ -n "$aret" ]] && return 300
- [[ -n "$mesg" ]] && _message "$mesg"
if [[ -n "$noargs" ]]; then
[[ -z "$ismulti" && nm -eq "$compstate[nmatches]" ]] && _message "$noargs"
else
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.13
diff -u -r1.13 computil.c
--- Src/Zle/computil.c 2000/05/05 07:37:17 1.13
+++ Src/Zle/computil.c 2000/05/08 10:35:48
@@ -1072,7 +1072,7 @@
Caarg def, ddef;
Caopt curopt;
int opt, arg, argbeg, optbeg, nargbeg, restbeg, curpos;
- int inopt, inrest, inarg, nth, doff, singles, oopt;
+ int inopt, inrest, inarg, nth, doff, singles, oopt, actopts;
LinkList args;
LinkList *oargs;
};
@@ -1121,7 +1121,7 @@
state.nopts = d->nopts;
state.def = state.ddef = NULL;
state.curopt = NULL;
- state.argbeg = state.optbeg = state.nargbeg = state.restbeg =
+ state.argbeg = state.optbeg = state.nargbeg = state.restbeg = state.actopts =
state.nth = state.inopt = state.inarg = state.opt = state.arg = 1;
state.inrest = state.doff = state.singles = state.doff = state.oopt = 0;
state.curpos = compcurrent;
@@ -1136,7 +1136,7 @@
if (!compwords[1]) {
ca_laststate.opt = ca_laststate.arg = 0;
- return 0;
+ goto end;
}
/* Loop over the words from the line. */
@@ -1349,6 +1349,13 @@
}
}
}
+ end:
+
+ ca_laststate.actopts = 0;
+ for (ptr = d->opts; ptr; ptr = ptr->next)
+ if (ptr->active)
+ ca_laststate.actopts++;
+
return 0;
}
@@ -1574,7 +1581,8 @@
return 1;
}
case 'O':
- if ((ca_laststate.opt || (ca_laststate.doff && ca_laststate.def) ||
+ if (ca_laststate.actopts &&
+ (ca_laststate.opt || (ca_laststate.doff && ca_laststate.def) ||
(ca_laststate.def &&
(ca_laststate.def->type == CAA_OPT ||
(ca_laststate.def->type >= CAA_RARGS &&
@@ -1632,7 +1640,7 @@
}
case 's':
if (ca_laststate.d->single && ca_laststate.singles &&
- ca_laststate.opt) {
+ ca_laststate.actopts > 1 && ca_laststate.opt) {
setsparam(args[1],
ztrdup(ca_laststate.ddef ?
(ca_laststate.ddef->type == CAO_DIRECT ?
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
reply other threads:[~2000-05-08 10:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200005081036.MAA20805@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).