]> git.eshelyaron.com Git - emacs.git/commit
Add aid for finding missing dynamic variable declarations
authorMattias Engdegård <mattiase@acm.org>
Fri, 16 Oct 2020 17:02:25 +0000 (19:02 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sat, 17 Oct 2020 14:57:38 +0000 (16:57 +0200)
commit3217ae6e05c5d99f5d2d364b8f631001ee1d29c9
treef168d63122d599d493f35b0e6f3388ff14972a23
parent39a001451fba253bf9480d1a0347ae054760f8e2
Add aid for finding missing dynamic variable declarations

Find lexical use of variables that are dynamically declared in other
files by recording 'defvar' declarations in files that can be read
in by the compiler in a second compilation.  This is particularly
useful when converting code to use lexical-binding.

The facility is controlled by setting environment variables:

 EMACS_GENERATE_DYNVARS -- set to non-empty to generate a .dynvars file
                           corresponding to each .elc.
 EMACS_DYNVARS_FILE     -- set to the name of a .dynvars file to use
                           as defvar information during compilation,
                           enabling the new warnings.

* lisp/emacs-lisp/bytecomp.el (byte-compile--known-dynamic-vars)
(byte-compile--seen-defvars): New variables.
(byte-compile-warning-types): Add lexical-dynamic warning.
(byte-compile--load-dynvars, byte-compile--warn-lexical-dynamic):
New functions.
* lisp/emacs-lisp/bytecomp.el (byte-compile-file, byte-compile--declare-var)
(byte-compile-lambda, byte-compile-bind): Add dynamic variable loads,
dumps and checks.
* doc/lispref/variables.texi (Converting to Lexical Binding): Document.
doc/lispref/variables.texi
lisp/emacs-lisp/bytecomp.el