Subject: bug#66706: [PATCH] Automatic elisp dialect insertion

From: Michael Heerdegen <[email-masked]>
Date: Fri, 27 Oct 2023 09:24:19 +0200

Eli Zaretskii <[email-masked]> writes:

> How many of init files do indeed require dynamic binding?  And why?

It was the default, and when I read what others mention ("look at the
code is posted here and there"), I guess there are a lot.  And exactly
those users will have problems with the upgrade.

If you look at the code that is posted in emacs-help, you see that some
people use a coding style that heavily depends on dynamical binding.

>
> If a new Emacs version refuses to start because something in the init
> files goes against some new Emacs feature, we have --debug-init and
> other facilities to debug and fix those.

I don't think that a debugger is that helpful for rewriting that stuff.

> Why should lexical-binding be considered different from any other
> backward-incompatible change that we sometimes do?

As I said: it's unnecessary to break Emacs startup when we can just be
nice and use the other dialect.  We can still force users to rewrite
their init file in nicer ways.

> In any case, how will injecting the cookie help those users, exactly?
> If people who write init files don't understand the implications of
> lexical-binding, their Emacs will fail to start, something that you
> think is a catastrophe.  And if they do understand it, their init
> files are already compatible with lexical-binding.

If Emacs starts and it doesn't find a lexical-binding cookie in the init
file, it might be written in the dynamically binding dialect.  I suggest
that Emacs then prompts the user: hey, your init file lacks that cookie,
if you upgraded your Emacs recently, it is likely that I should
interpret it as dynamically binding, although lexical-binding is the
new default.  If you just installed Emacs, you should use "lexical-binding".

Use lexical binding for now (y-or-n)?

And then you would be instructed to add a cookie for the init file.
With a hint where to look up the relevant information about the two
dialects.

> Your point seems to be incompatible with our plan, which is to turn on
> lexical-binding by default at some point.  We don't want to have a
> schism of two separate flavors of Lisp, we want only one.  The current
> situation is a transitional period, not the ideal.  You seem to be
> suggesting that we should keep this situation forever, and that is not
> what we decided, AFAIU.

No, I don't think you fully understand.  I only want to help the users
with the transition.  Nice programs do that, they help you a bit with
necessary changes to your config after major changes.

I suggest this treatment only for the init file.  And also only for a
transitional period (I already said that though...).

Michael.