Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Why is an 'x' appended in _prefix completer?

On Thu, Mar 9, 2023 at 1:23 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> > On 08/03/2023 17:48 Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > Anyway, as I recall it, the point of the extra character is to help
> > completion distinguish the position of word breaks when completing
> > somewhere other than at end of line.
> That's a pretty obscure and undocumented effect at the point in question,
> compadd shouldn't be making this visible to shell code.

Prefix completion is in the middle of a word but without treating the
suffix as part of the word.  It's supposed to act like completion in
the middle of words in some other shell (old bash?).  So to hack that,
the _prefix completer inserts a space to the right of the cursor and
then completes as usual.  The "x" indicates where to remove the space
again when all is done.  It's not exposing the internals of compadd,
it's just using the same trick in shell code that compadd does in a
different case.

Messages sorted by: Reverse Date, Date, Thread, Author