Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Disabling null elision (was: Re: Most Recent File)
- X-seq: zsh-users 27295
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Disabling null elision (was: Re: Most Recent File)
- Date: Mon, 25 Oct 2021 23:20:39 +0200
- Archived-at: <https://zsh.org/users/27295>
- In-reply-to: <048e0b3d-6da9-4905-b1ad-253647cea0d3@www.fastmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAP+y1xC3Dx74sBaCf8mgmEcOMh+hUH6zAdt236k=JTjw4-cBqQ@mail.gmail.com> <CF77Q0TPEKI8.1NCL83P9Z0HV3@kbvv> <YXS6sdovNFVnDAmr@gmx.de> <CAN=4vMrfKTP6UAAEA=A6WFWP6_0CuRJtEorDK+NcGLd4mkuEow@mail.gmail.com> <20211025194508.GB8612@tarpaulin.shahaf.local2> <CAN=4vMpZbLxe4navMTjRaKxogemJqnqcre6NuK3v8V6xVgCzRg@mail.gmail.com> <048e0b3d-6da9-4905-b1ad-253647cea0d3@www.fastmail.com>
On Mon, Oct 25, 2021 at 10:42 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
>
> Roman Perepelitsa wrote on Mon, 25 Oct 2021 20:02 +00:00:
>
> > It's also nice that this option would affect parsing, only evaluation,
> > so it won't be necessary to care about it when defining functions.
>
> How so?
Some options can be set within a function for the function to work as
the author has intended. For example, extended_glob.
function foo() {
emulate -L zsh -o extended_glob
# can extended-glob here to one's heart's content
[[ $1 == a## ]]
}
Other options must be set when the function is defined. For example,
brace_expand.
# if brace_expand is unset here, bar is screwed
unset brace_expand # bwa-ha-ha
function bar() {
emulate -L zsh -o brace_expand # this won't help
typeset var{1,2,3}=42
}
setopt brace_expand # this won't help either
bar # oh no!
Options of the second kind cause more grief.
As Bar says, autoload -Uz is key when it comes to loading plugins and
sourcing is a losing game (I learned this from Bart earlier).
Sometimes you still have to have a function in a plugin that must run
with user options but at least that's just for evaluation and not for
parsing.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author