mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
The --script option now enforces lexical binding (bug#79760)
* etc/NEWS: Document the change. * lisp/startup.el (command-line--load-script): Set 'lexical-binding'; if we delete the first line, insert a new line to preserve line numbers. (command-line--eval-script): Set 'lexical-binding'.
This commit is contained in:
parent
e2799739a5
commit
e5130bdecc
2 changed files with 14 additions and 1 deletions
10
etc/NEWS
10
etc/NEWS
|
|
@ -3168,6 +3168,16 @@ and blocks Emacs, or does not provide ways to limit how often it runs.
|
|||
|
||||
* Incompatible Lisp Changes in Emacs 31.1
|
||||
|
||||
** Files loaded from '-x' and '--script' now use lexical binding.
|
||||
If you don't have time to adapt your script's code to the lexical
|
||||
binding dialect (see (info "(elisp)Converting to Lexical Binding")),
|
||||
you can wrap your code in:
|
||||
|
||||
#!/usr/bin/env -S emacs --batch --script
|
||||
(eval
|
||||
'(progn
|
||||
YOUR CODE HERE))
|
||||
|
||||
+++
|
||||
** String mutation has been restricted further.
|
||||
'aset' on unibyte strings now requires the new character to be a single
|
||||
|
|
|
|||
|
|
@ -2961,12 +2961,14 @@ nil default-directory" name)
|
|||
file file nil t
|
||||
(lambda (buffer file)
|
||||
(with-current-buffer buffer
|
||||
(setq-local lexical-binding t)
|
||||
(goto-char (point-min))
|
||||
;; Removing the #! and then calling `eval-buffer' will make the
|
||||
;; reader not signal an error if it then turns out that the
|
||||
;; buffer is empty.
|
||||
(when (looking-at "#!")
|
||||
(delete-line))
|
||||
(delete-line)
|
||||
(insert ";; -*- lexical-binding: t -*-\n"))
|
||||
(eval-buffer buffer nil file nil t)))))
|
||||
|
||||
(defun command-line--eval-script (file)
|
||||
|
|
@ -2975,6 +2977,7 @@ nil default-directory" name)
|
|||
(lambda (buffer _)
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-min))
|
||||
(setq-local lexical-binding t)
|
||||
(when (looking-at "#!")
|
||||
(forward-line))
|
||||
(let (value form)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue