diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-10-15 22:01:06 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-10-21 15:12:55 +0200 |
commit | a3db503351e9a8720cdea2f1ca42d55d2de684e2 (patch) | |
tree | 299791970977df508b580a64040e86f7e1f30782 /lisp/emacs-lisp/checkdoc.el | |
parent | 12c8cdb60cc41fb17a85c7e3f75f91cca2d60483 (diff) | |
download | emacs-a3db503351e9a8720cdea2f1ca42d55d2de684e2.tar.gz emacs-a3db503351e9a8720cdea2f1ca42d55d2de684e2.tar.bz2 emacs-a3db503351e9a8720cdea2f1ca42d55d2de684e2.zip |
Move lexical-binding warning from checkdoc to byte-compiler
This warning is much more appropriate for the compiler, since lexical
binding affects what it can reason and warn about, than for checkdoc
as the warning has no bearing to documentation at all.
The move also improves the reach of the warning.
* etc/NEWS: Update.
* lisp/emacs-lisp/checkdoc.el (checkdoc-lexical-binding-flag)
(checkdoc-file-comments-engine): Move warning from here....
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): ...to here.
* test/lisp/emacs-lisp/bytecomp-resources/no-byte-compile.el:
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--unescaped-char-literals)
(bytecomp-tests-function-put, bytecomp-tests--not-writable-directory)
(bytecomp-tests--target-file-no-directory):
Update tests.
(bytecomp-tests--log-from-compilation)
(bytecomp-tests--lexical-binding-cookie): New test.
Diffstat (limited to 'lisp/emacs-lisp/checkdoc.el')
-rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 440e133f44b..471a2fbdf48 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -128,14 +128,6 @@ ;; simple style rules to follow which checkdoc will auto-fix for you. ;; `y-or-n-p' and `yes-or-no-p' should also end in "?". ;; -;; Lexical binding: -;; -;; We recommend always using lexical binding in new code, and -;; converting old code to use it. Checkdoc warns if you don't have -;; the recommended string "-*- lexical-binding: t -*-" at the top of -;; the file. You can disable this check with the user option -;; `checkdoc-lexical-binding-flag'. -;; ;; Adding your own checks: ;; ;; You can experiment with adding your own checks by setting the @@ -347,12 +339,6 @@ See Info node `(elisp) Documentation Tips' for background." :type 'boolean :version "28.1") -(defcustom checkdoc-lexical-binding-flag t - "Non-nil means generate warnings if file is not using lexical binding. -See Info node `(elisp) Converting to Lexical Binding' for more." - :type 'boolean - :version "30.1") - ;; This is how you can use checkdoc to make mass fixes on the Emacs ;; source tree: ;; @@ -2391,31 +2377,6 @@ Code:, and others referenced in the style guide." (point-min) (save-excursion (goto-char (point-min)) (line-end-position)))) nil)) - (when checkdoc-lexical-binding-flag - (setq - err - ;; Lexical binding cookie. - (if (not (save-excursion - (save-restriction - (goto-char (point-min)) - (narrow-to-region (point) (pos-eol)) - (re-search-forward - (rx "-*-" (* (* nonl) ";") - (* space) "lexical-binding:" (* space) "t" (* space) - (* ";" (* nonl)) - "-*-") - nil t)))) - (let ((pos (save-excursion (goto-char (point-min)) - (goto-char (pos-eol)) - (point)))) - (if (checkdoc-y-or-n-p "There is no lexical-binding cookie! Add one?") - (progn - (goto-char pos) - (insert " -*- lexical-binding: t -*-")) - (checkdoc-create-error - "The first line should end with \"-*- lexical-binding: t -*-\"" - pos (1+ pos) t))) - nil))) (setq err (or |