On Wed, Nov 05, 2025 at 05:56:24AM +0000, Ihor Radchenko wrote:
> [email protected] writes:
> 
> > Well, that's the `defvar-local':
> >
> >   Define VAR as a buffer-local variable with default value VAL.
> >   Like ‘defvar’ but additionally marks the variable as being automatically
> >   buffer-local wherever it is set.
> >
> > So any new buffer (the one `with-temp-buffer' is creating) is now 
> > automatically
> > born with a buffer-local variable `yant/foo' with (default) value 1...
> 
> make-local-variable also makes the variable buffer-local.
> In fact, defvar-local is simply a macro that expands to
> (progn (defvar var value docstring) (make-variable-buffer-local 'var))
> 
> So, using your example will work exactly the same
> 
> (set (make-local-variable 'yant/test2) 23)
> yant/test2 ; => 23
> (let ((yant/test2 42)) (buffer-local-value 'yant/test2 (current-buffer))) ; 
> => 23
> (let ((yant/test2 42)) (with-temp-buffer (buffer-local-value 'yant/test2 
> (current-buffer)))) ; => 1

Indeed. Mixing global state change and functional framing does
funny things :-)

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature

Reply via email to