help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: Marlon Richert <marlon.richert@gmail.com>
Subject: Re: [PATCH] Make _expand_alias more usable as a completer
Date: Tue, 27 Jul 2021 20:23:29 -0700	[thread overview]
Message-ID: <CAH+w=7bhr0Gs1p1io6a9kG2bZS5Eqq9P+OD6y6NDRuNT36ZzUg@mail.gmail.com> (raw)
In-Reply-To: <906332f9-027b-4b21-bb7f-3fd7118154af@www.fastmail.com>

On Sun, Jul 18, 2021 at 4:35 PM Lawrence Velázquez <larryv@zsh.org> wrote:
> On Sun, Jun 20, 2021, at 6:24 PM, Marlon Richert wrote:
> > On Mon, Jun 21, 2021 at 12:08 AM Mikael Magnusson <mikachu@gmail.com> wrote:
> > >
> > > On 6/20/21, Lawrence Velázquez <larryv@zsh.org> wrote:
> > > > On Thu, Jun 3, 2021, at 5:42 PM, Marlon Richert wrote:
> > > >> On Thu, Jun 3, 2021 at 2:24 AM Oliver Kiddle <opk@zsh.org> wrote:
> > > >>
> > > >> > I also wonder if this would be better done from within _command_names
> > > >> > directly but I'm not sure.

Handling it in _command_names would not be sufficient for global
aliases.  That said, I haven't actually investigated the use of
_expand_alias for global aliases.

> > > >> Actually, I feel like it could instead be added to the _expand
> > > >> completer. Would that be a better idea than what I presented in this
> > > >> patch?
> > > >
> > > > Anyone have answers to Marlon's questions?
> > >
> > > If it helps, I disagree with conflating _expand_alias (expanding
> > > aliases) and _expand (filename expansion).
> >
> > _expand already handles a lot more than just "filename expansion"
> > (which it actually does not handle at all).

Naming has always been a bit strange here.  Yes, strictly per the
docs, "filename expansion" refers to replacing a leading tilde with a
path prefix, and "filename generation" is a fancy term for globbing
but is considered a form of expansion.  I've forgotten why we couldn't
just stick with "tilde expansion" and "globbing" and leave "filename"
out of it entirely, but there you are.  In any event I think it's
likely that Mikael was referring to globbing.

> > Since alias expansion is in fact listed at
> > https://zsh.sourceforge.io/Doc/Release/Expansion.html, I don't think
> > it would be too weird to add it to the _expand completer.

I think it's actually a bit weird to allow _expand_alias to work as a
completer at all, because the completion system generally functions
very badly when the matches do not consist of single words, and
aliases don't usually have one-word replacements.  As soon as you
introduce something that contains spaces, completion gets very
confused (unless you force it directly into menu completion or
selection); if (otherwise) you attempt to press TAB twice to enter
menu completion, it'll instead start a new completion based on the
word after the rightmost space that is still to the left of the
cursor.  This is especially true when using compadd -U.

I suspect this may be where Oliver's tests and Marlon's attempt to
reproduce, went astray from one another.  In any case, I'm fairly sure
this is the reason that _expand_alias (before the patch) does not
allow other completers to run, and similarly it's why the user is
admonished to place _expand before _complete in the zstyle.

> Any other feedback on 48946?

Looking independently at the two questions, my feeling is I'd avoid
the patch as-is, but it wouldn't be unreasonable for _expand to handle
aliases (under control of a zstyle).

  reply	other threads:[~2021-07-28  3:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 21:59 Marlon Richert
2021-06-02 23:23 ` Oliver Kiddle
2021-06-03 21:42   ` Marlon Richert
2021-06-20 19:49     ` Lawrence Velázquez
2021-06-20 21:08       ` Mikael Magnusson
2021-06-20 22:24         ` Marlon Richert
2021-07-18 23:34           ` Lawrence Velázquez
2021-07-28  3:23             ` Bart Schaefer [this message]
2021-08-01 18:50               ` [PATCH] Make _expand handle aliases (was Re: [PATCH] Make _expand_alias more usable as a completer) Marlon Richert
2022-03-31 22:35                 ` Lawrence Velázquez
2022-04-01  0:37                   ` Bart Schaefer
2022-05-06  5:57                     ` Marlon Richert
2022-05-07 20:39                       ` Bart Schaefer
2022-05-11  7:32                         ` Marlon Richert

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7bhr0Gs1p1io6a9kG2bZS5Eqq9P+OD6y6NDRuNT36ZzUg@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=marlon.richert@gmail.com \
    --cc=zsh-workers@zsh.org \


* 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


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).