Subject: Re: bug#62419: 28.2; Elisp let-bound buffer-local variable and kill-local-variable

From: Matthew Malcomson <[email-masked]>
Date: Wed, 29 Mar 2023 11:56:32 +0100

Thanks!

Just for the record I’ve been running using essentially this patch (but with !=) since you suggested it and have not had any problems.

FWIW I also think the change to avoid `let` binding `auto-fill-function` in `normal-mode` is good.

Regards,
Matthew

> On 26 Mar 2023, at 16:30, Stefan Monnier <[email-masked]> wrote:
> 
>> I.e. currently the behaviour of `setq` on automatic	buffer-local variables is:
>> 	- Outside `let`, always affect buffer-local (creating if necessary)
>> 	- In `let` of global binding, affect global binding.
>> 	- In `let` of buffer-local binding, affect buffer-local
>> 	- In `let` of buffer-local binding but where buffer-local value has
>> been killed, affect global value.
>> 
>> I believe that last condition is strange and the behaviour of `setq` would
>> be more understandable without it.
> 
> I think the patch below would fix this corner case.
> 
> 
>        Stefan
> 
> 
> diff --git a/src/eval.c b/src/eval.c
> index ef7ca33f834..82ada40b309 100644
> --- a/src/eval.c
> +++ b/src/eval.c
> @@ -3364,7 +3364,7 @@ DEFUN ("fetch-bytecode", Ffetch_bytecode, Sfetch_bytecode,
>   return object;
> }
> 
> -/* Return true if SYMBOL currently has a let-binding
> +/* Return true if SYMBOL's default currently has a let-binding
>    which was made in the buffer that is now current.  */
> 
> bool
> @@ -3379,6 +3379,7 @@ let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol)
> 	struct Lisp_Symbol *let_bound_symbol = XSYMBOL (specpdl_symbol (p));
> 	eassert (let_bound_symbol->u.s.redirect != SYMBOL_VARALIAS);
> 	if (symbol == let_bound_symbol
> +	    && !p->kind == SPECPDL_LET_LOCAL /* bug#62419 */
> 	    && EQ (specpdl_where (p), buf))
> 	  return 1;
>       }
>