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

Re: Hiding specials, and namerefs



On Mon, Jul 20, 2026 at 1:54 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Consider this:
>
> local_nonspecial() { () {
>   local -h BUFFER;
>   local -n BUFFER=CURSOR;
>   ((BUFFER-=3));
> } }
> 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.

-- 
Mikael Magnusson




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