Re: Hiding specials, and namerefs
Mikael Magnusson <[email protected]> Mon, 20 Jul 2026 02:40:40 +0200
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <CAHYJk3SP_uEk8YTCpExj2fYi7uKyMRYA389zUWVyUGqx+VhJ=Q@mail.gmail.com> |
On Mon, Jul 20, 2026 at 1:54=E2=80=AFAM Bart Schaefer <schaefer@brasslanter=
n.com> wrote:
>
> Consider this:
>
> local_nonspecial() { () {
> local -h BUFFER;
> local -n BUFFER=3DCURSOR;
> ((BUFFER-=3D3));
> } }
> zle -N local_nonspecial
>
> Notes:
> -- `typeset -hn ...` is not allowed, but can be worked around, so
> probably should be allowed?
> -- the ZLE parameters are already implicitly local on entry to a
> widget function, so declaring them local again (even with -h) doesn't
> change anything without introducing another scope.
>
> (Noticed this while checking for side-effects of workers/54809)
>
> Should there be an error or warning when attempting to "de-specialize"
> a special parameter in the same scope where it already exists as a
> special?
>
> This is similar to this situation:
> % typeset -i WATCH
> typeset: WATCH: can't change type of autoloaded parameter
I think that would make sense, I vaguely remember being confused why
typeset -h seemingly didn't work, only to realize later it was because
of magic scope. Ah, here it is, 34994 (and 35007). If I had gotten an
error, I would probably have been confused for a shorter period of
time.
--=20
Mikael Magnusson