Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Proposal: Let compinit make standard widgets with _generic instead of _main_complete
- X-seq: zsh-workers 48442
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Proposal: Let compinit make standard widgets with _generic instead of _main_complete
- Date: Fri, 09 Apr 2021 21:11:25 +0200
- Archived-at: <https://zsh.org/workers/48442>
- In-reply-to: <CAH+w=7YAxLGd=cTFkOqHXiUpk1iPp=7u3-qvEKmE6dTSELcoMA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHLkEDuxX39Z7-ioZTgrosL-SQW8dhZy9_v694u7w4Mtu+EHSw@mail.gmail.com> <CAH+w=7b4b-FBVbrZ4SWSiqxP4OcuLmzQWjqZ39c6Q-WZzPq60Q@mail.gmail.com> <CAH+w=7ZL+soLWYiKUb1Ej20WHbs7johzVWJ+qEvevLP5tK_Z4w@mail.gmail.com> <CAHLkEDtjqfyXFR7RqXBUVmKc5MwWR2T8zazortvO3ygEphZarA@mail.gmail.com> <CAH+w=7bhfeV0k5y0FtZLTsm_Y5uBU1wLJw7GUVubfxsKopaRDg@mail.gmail.com> <CAHLkEDuo=8MbjYWOmQM5d4uLOzo+BC6XTy=S14-BfeBPMZjysw@mail.gmail.com> <CAH+w=7YAxLGd=cTFkOqHXiUpk1iPp=7u3-qvEKmE6dTSELcoMA@mail.gmail.com>
On 4 Apr, Bart Schaefer wrote:
> On Mon, Mar 22, 2021 at 12:17 AM Marlon Richert
> > > +if [[ "${curcontext:-:::}" == ::: ]] &&
> > > + zstyle -t ":completion:::::" generic-widgets "$WIDGET"
> > > +then
> > > + _generic "$@"
> > > + return
> > > +fi
> >
> > This feels like a rather roundabout solution. _generic itself already
That does indeed seem rather roundabout. And all it achieves is a
different way to configure what can already be configured.
> > checks whether $curcontext is set and then calls _main_complete. Why
> > not just do the straightforward thing, and let the widget call
> > _generic directly, which in turn will call _main_complete anyway?
>
> This is really only the first in a few steps of patch that I didn't
> want to spend time on if this were rejected out of hand.
> The problem with calling _generic at all (right now) is that it messes
> with $curcontext in a way that may break other functions that rely on
> _main_complete behavior. If we can invert the call sequence so
> _main_complete remains first, then _generic itself can be tweaked so
> that it does NOT mung the context in that circumstance, while still
> leaving the original semantics of creating a new widget with _generic
> unchanged.
The only thing _generic really does is shove $WIDGET into the second
field of $curcontext where _main_complete left this empty. I wouldn't
know why it was empty by default other than perhaps brevity. But it does
provide for a notion of a default behaviour for the tab key and widgets
like _complete_debug that want to follow that default. Certainly, I have
quite a few styles defined with the two consecutive colons hardcoded. I
can't see how we can change it in a backward compatible way even if we
determine that it would be better.
The intended way to do this is to use zle -C to define a custom widget
based on an existing one and _generic. And if you really want the
existing widget, zstyle -e allows you to check $WIDGET. Or is the aim
here actually something else like making it easier for a plugin to base
changes on underlying user settings.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author