From: Marlon Richert <marlon.richert@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: [bug?] How to make _expand behave like the expand-word or list-expand widgets?
Date: Tue, 2 Apr 2024 10:45:26 +0300 [thread overview]
Message-ID: <CAHLkEDs7yZUceg1zK06ySLFiRZiYryLT1NrYGF+aw+-9e4AQKw@mail.gmail.com> (raw)
In-Reply-To: <CAHLkEDtFJbLsq9M=zcWBPhEQG+PgpOXQHohpXnb7WD_yWTwe7w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]
This actually seems to do what I want:
_expand() {
local -a expl
local expansion
expansion="${(b)$( eval print -r -- $words[CURRENT] )}" 2> /dev/null ||
return 1
_description expansions expl expansion
compadd -QU "$expl[@]" -- $expansion
}
This code can of course cause undesirable side effects when expanding
certain special parameters and command substitutions, but _expand suffers
from this, too.
Is there a way to locally disable special parameters and command
substitutions? Are there any other drawbacks to this approach? Why isn't
_expand doing something like this?
On Tue, Apr 2, 2024 at 10:12 AM Marlon Richert <marlon.richert@gmail.com>
wrote:
> I would expect _expand to behave by default like expand-word or
> list-expand, but it doesn't.
>
> For example, given default shell options, if `foo=*`, then expand-word
> and list-expand will complete `$foo` to `*` and `$~foo` to the files
> matched by `*` as a glob expression.
>
> However, no matter what zstyle options I set, _expand will either
> complete both of these to `\*` or both of these to the files globbed by
> `*`.
>
> By default, I would expect _expand to complete expressions in the same
> way as the shell substitutes them when evaluating the command line.
>
> Is there a combination of zstyles that makes _expand complete `$foo` to
> its literal value and `$~foo` to the files globbed by its value?
>
> If not, then I would like to see this being added somehow and preferably
> be made the default behavior.
>
>
[-- Attachment #2: Type: text/html, Size: 4081 bytes --]
prev parent reply other threads:[~2024-04-02 7:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 7:12 Marlon Richert
2024-04-02 7:45 ` Marlon Richert [this message]
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=CAHLkEDs7yZUceg1zK06ySLFiRZiYryLT1NrYGF+aw+-9e4AQKw@mail.gmail.com \
--to=marlon.richert@gmail.com \
--cc=zsh-users@zsh.org \
/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).