> I still find some quirks in the way Emacs does lexical binding; do you
> need a “;;; -*- lexical-binding: t; -*-” header comment line, or can
> it be done with regular lisp code as “(setq lexical-binding t)”? Also,
> the above code is followed by this line
>
> (setq lexical-binding nil)
>
> because otherwise I found that subsequent use of “(deactivate-mark)”
> was liable to misbehave otherwise. (This might be fixed in newer Emacs
> versions.)
Static-vs-dynamic binding is not just a boolean in the state of the
"Lisp machine" (something which you could change with a `setq`) but is
better thought of as an attribute of source code. At any given time,
you can have several functions using the static dialect of ELisp and
several other functions using the dynamic dialect, and they can all call
each other.
IOW, the static-vs-dynamic property is a static rather than
a dynamic property. 🙂
Imagine compiling a file like:
(setq lexical-binding nil)
(defun my-fun1 (..)
...)
(setq lexical-binding t)
(defun my-fun2 (..)
...)
and take into account that we're only *compiling* the file, so the
`setq`s are not executed: they're just turned into code which will set
the variable when/if the code is later executed.
=== Stefan