Subject: Re: bug#74145: 31.0.50; Default lexical-binding to t

From: Eli Zaretskii <[email-masked]>
Date: Fri, 14 Mar 2025 10:31:38 +0200

> Cc: [email-masked]
> From: Richard Stallman <[email-masked]>
> Date: Thu, 13 Mar 2025 23:51:45 -0400
> 
>   > >   > E.g. "why don't we start by warning when we load files
>   > >   > without the lexical-binding cookie?":
>   > >
>   > >   >     https://lists.gnu.org/r/emacs-devel/2024-05/msg00250.html
>   > >
>   > >   > I don't have any new answers to those questions.
>   > >
>   > > Are you ok with our implementing that warning now?
> 
>   > Of course.  For me, the purpose of this bug#74145 is not to see *if* we
>   > can change the default but *how*, or rather under which conditions.
> 
> This chamge woud be good to make right away.  Please go ahead.
> 
> However, to change the default value of `lexical-binding' would 
> cause cnfusion and problems.  Please don't do that now.
> 
> Instead, we should do the other change that reminds users
> to make their files set this variable.  We could release 30.2
> right away with that one change.  Then users would start changing
> their files to avoid future problems.

We generally avoid making changes that aren't bugfixes in bugfix
releases such as 30.2.  But we could make an exception in this case, I
guess.

> I have an idea for another change that will help with this too.
> The idea is, whenever Emacs loads a file from a directory D,
> it should look for other Emacs Lisp files in D which lack a binding
> for lexical-binding, and if it sees any, it should
> urge the user to add such bindings to all the Lisp files in D.
> 
> To make this easier for users, it could ask the qyestion,
> 
>   Add a lexical-binding spec to each Emacs Lisp file in dir D?
> 
> If the user says yes, it could ask
> 
>   Use lexical-binding t for all files, or lexical-binding nil for all,
>   or ask about each file?
> 
> This will encourage users to fix lots of files soon, even files
> they won't actually have thought about.

But it could slow down loading files, especially if D is a large
directory.  We should also allow the user to opt out from these
questions and the check itself.

On balance, I'm not sure this feature will not be a nuisance more than
help.  In any case, I think we should discuss this kind of change on
emacs-devel, not here.