* PATCH: _arguments (was: Re: odd diff completion)
@ 2000-06-15 8:06 Sven Wischnowsky
2000-06-16 15:19 ` PATCH: _arguments and _dpkg Clint Adams
0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 2000-06-15 8:06 UTC (permalink / raw)
To: zsh-workers
Clint Adams wrote:
> Under 3.1.9:
>
> diff pars<TAB>
> completes to diff parse.c
>
> Under yesterday's CVS:
>
> diff pars<TAB>
> completes to diff parsB
Ahem. Sorry, under certain conditons ca_get_sopt() returned an option
even for non-option strings.
In another message:
> > The `-A -*' doesn't mean that it complete ignores all unknown strings
> > starting with a hyphen, it just means that it doesn't stop completing
> > options if it finds undescribed `-foo's.
>
> > So, you still have to give it the `--{install,...}' to make it ignore
> > it. Or you use the `= ' trick together with the `::' trick, as in:
> >
> > '(-i)--install:*::Debian packages:= ->install' \
>
> I'm confused. If I omit the '--{install,...}', doesn't that make
> --install an undescribed -foo, and thus it shouldn't stop completing
> options?
I've now had a look and am of the opinion, that the behaviour is the
right thing. The install case uses multiple sets. For multiple sets,
_arguments has to detect undescribed options and it has to stop trying
to complete a set if there is a string not covered by the descriptions
for that set on the line (otherwise it couldn't make the sets be
mutually exclusive).
We could make the -A pattern be used there, the patch below contains
the code for that, #if'ed out with a marker comment above it. However,
that would defeat the purpose of multiple sets, i.e. the sets are then
not mutually exclusive if we use a simple pattern like -*. One would
then need a pattern that exactly matches all possible options -- not
very user-friendly.
So the solution for the current state of _arguments, which I don't
want to change is to include the --install etc. in the second call to
_arguments, that makes everything work as you want. BUT, I'd be
willing to give some more help for this. The only things I could think
of are:
- an option, say -I, which gives an array of options which are to be
ignored but not completed
- or, probably more more user-friendly, yet another optspec syntax
describing options which are to be ignored but not completed; for
example, if we find a syntax that starts with a special string for
that, one could use <not>${^_dpkg_actions} in the second call to
_arguments to make it skip all options described in $_dpkg_options
I think I prefer the latter (or both). Anyone got an idea for an
acceptable syntax? Or other suggestions?
Bye
Sven
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.29
diff -u -r1.29 computil.c
--- Src/Zle/computil.c 2000/06/13 12:14:32 1.29
+++ Src/Zle/computil.c 2000/06/15 07:20:53
@@ -1083,7 +1083,7 @@
LinkList l = NULL;
*lp = NULL;
- for (p = NULL; *line; line++)
+ for (p = NULL; *line; line++) {
if ((p = d->single[STOUC(*line)]) && p->active &&
p->args && p->name[0] == pre) {
if (p->type == CAO_NEXT) {
@@ -1100,8 +1100,10 @@
}
break;
}
- } else if (!p || (!p->active && p->name[0] != pre))
+ } else if (p && !p->active)
return NULL;
+ p = NULL;
+ }
if (p && end)
*end = line;
return p;
@@ -1444,7 +1446,14 @@
state.opt = 0;
else
state.curopt = NULL;
- } else if (multi && (*line == '-' || *line == '+') && cur != compcurrent)
+ } else if (multi && (*line == '-' || *line == '+') && cur != compcurrent
+#if 0
+ /**** Ouch. Using this will disable the mutual exclusion
+ of different sets. Not using it will make the -A
+ pattern be effectively ignored with multiple sets. */
+ && (!napat || !pattry(napat, line))
+#endif
+ )
return 1;
else if (state.arg && (!napat || !pattry(napat, line))) {
/* Otherwise it's a normal argument. */
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: _arguments and _dpkg
2000-06-15 8:06 PATCH: _arguments (was: Re: odd diff completion) Sven Wischnowsky
@ 2000-06-16 15:19 ` Clint Adams
0 siblings, 0 replies; 2+ messages in thread
From: Clint Adams @ 2000-06-16 15:19 UTC (permalink / raw)
To: Sven Wischnowsky; +Cc: zsh-workers
> - an option, say -I, which gives an array of options which are to be
> ignored but not completed
> - or, probably more more user-friendly, yet another optspec syntax
> describing options which are to be ignored but not completed; for
> example, if we find a syntax that starts with a special string for
> that, one could use <not>${^_dpkg_actions} in the second call to
> _arguments to make it skip all options described in $_dpkg_options
>
> I think I prefer the latter (or both). Anyone got an idea for an
> acceptable syntax? Or other suggestions?
I think I prefer the latter too. In the meantime, I'm using the following
patch.
Unfortunately, with current CVS, this results in anything beginning
with -- followed by the first letter of any of the long options
covered by the state engine to be not completed.
e.g. dpkg --p<TAB>, dpkg --pu<TAB>, dpkg --pur<TAB>, &c., will all
just insert a space.
Index: Completion/Debian/_dpkg
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_dpkg,v
retrieving revision 1.5
diff -u -r1.5 _dpkg
--- Completion/Debian/_dpkg 2000/06/13 17:45:56 1.5
+++ Completion/Debian/_dpkg 2000/06/16 15:09:48
@@ -1,7 +1,7 @@
#compdef dpkg dpkg-deb
local _dpkg_deb_actions _dpkg_common_actions _dpkg_actions _dpkg_options
-local _dpkg_options_recursive
+local _dpkg_options_recursive _dpkg_actions_install _dpkg_actions_record_avail
local curcontext="$curcontext" context state line expl ret
typeset -A opt_args
@@ -81,6 +81,8 @@
--{force,refuse,no-force}'--[forcing options]:what:(auto-select downgrade configure-any hold bad-path not-root overwrite overwrite-diverted depends-version depends confnew confold confdef confmiss conflicts architecture overwrite-dir remove-reinstreq remove-essential)')
_dpkg_options_recursive=('(--recursive)-R[recursive]' '(-R)--recursive')
+_dpkg_actions_install=('(--install)-i[install]' '(-i)--install')
+_dpkg_actions_record_avail=('(--record-avail)-A[record available]' '(-A)--record-avail')
case "${words[1]:t}" in
dpkg)
@@ -102,7 +104,8 @@
case "$state" in
install|record_avail)
_funcall ret _dpkg_$state && return ret
- _arguments -C -A "-*" -s "$_dpkg_options[@]" \
+ _arguments -C -s "$_dpkg_options[@]" \
+ "${(@e):-\$_dpkg_actions_${state}}" \
- recur \
'(--recursive)-R[recursive]' \
'(-R)--recursive' \
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-06-16 15:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-15 8:06 PATCH: _arguments (was: Re: odd diff completion) Sven Wischnowsky
2000-06-16 15:19 ` PATCH: _arguments and _dpkg Clint Adams
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).