According to this, it seems to say setting lexical-binding
only happens at the individual buffer level, i.e. I could not do (setq lexical-binding t)
in my init file and have it apply to all subsequent buffers, right?
1 Answer
Correct, it's set on a per-file/buffer basis.
I could not do
(setq lexical-binding t)
in my init file and have it apply to all subsequent buffers, right?
Indeed not, and nor would you want to do that. Libraries may behave differently with lexical binding enabled, and for the vast majority of the history of Emacs that wasn't an option, so no one was writing code with lexical binding in mind. Forcing it on libraries which aren't expecting it could break all manner of things.
Strictly speaking, setq-default
might do this if there's no specific protection against it, but you'd never want to do that, and I have a feeling that Emacs requires it to be a file-local variable.
-
Worse, it must be in the first line. And
eval-region
will fail to notice that, onlyeval-buffer
will honor it.– wasamasaNov 27, 2015 at 8:24