From: Mattias EngdegÄrd Date: Mon, 13 Jan 2020 13:53:11 +0000 (+0100) Subject: Always use lexical-binding in lisp-interaction-mode (bug#38835) X-Git-Tag: emacs-27.0.90~171 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d645628e3cf6ebe5eaea3b40100bd77b9c823f8b;p=emacs.git Always use lexical-binding in lisp-interaction-mode (bug#38835) * lisp/progmodes/elisp-mode.el (lisp-interaction-mode): Set lexical-binding. * lisp/startup.el (command-line, startup--get-buffer-create-scratch): Don't set lexical-binding here. * doc/lispref/variables.texi: * etc/NEWS: Make it clear that lisp-interaction-mode uses lexical-binding. --- diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi index 1ec97e2f3de..1e357754abe 100644 --- a/doc/lispref/variables.texi +++ b/doc/lispref/variables.texi @@ -1187,6 +1187,9 @@ When evaluating Emacs Lisp code directly using an @code{eval} call, lexical binding is enabled if the @var{lexical} argument to @code{eval} is non-@code{nil}. @xref{Eval}. +Lexical binding is also enabled in Lisp Interaction and IELM +mode, used in the @file{*scratch*} and @file{*ielm*} buffers. + @cindex special variables Even when lexical binding is enabled, certain variables will continue to be dynamically bound. These are called @dfn{special diff --git a/etc/NEWS b/etc/NEWS index 61b9e4a7237..031ddf58005 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -338,7 +338,8 @@ answers, but also function keys like 'F1', character events such as ** Lexical binding is now used when evaluating interactive Elisp forms. More specifically, lexical-binding is now used for 'M-:', '--eval', as -well as in the "*scratch*" and "*ielm*" buffers. +well as in lisp-interaction-mode and ielm-mode, used in the "*scratch*" +and "*ielm*" buffers. --- ** The new user option 'tooltip-resize-echo-area' avoids truncating diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index 774e3324c2e..2617a6e4cce 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -933,7 +933,8 @@ Paragraphs are separated only by blank lines. Semicolons start comments. \\{lisp-interaction-mode-map}" - :abbrev-table nil) + :abbrev-table nil + (setq-local lexical-binding t)) ;;; Emacs Lisp Byte-Code mode diff --git a/lisp/startup.el b/lisp/startup.el index c27af726f9c..2a85c004da1 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1435,8 +1435,7 @@ please check its value") (if (get-buffer "*scratch*") (with-current-buffer "*scratch*" (if (eq major-mode 'fundamental-mode) - (funcall initial-major-mode)) - (setq-local lexical-binding t))) + (funcall initial-major-mode)))) ;; Load library for our terminal type. ;; User init file can set term-file-prefix to nil to prevent this. @@ -2317,7 +2316,6 @@ A fancy display is used on graphic displays, normal otherwise." (or (get-buffer "*scratch*") (with-current-buffer (get-buffer-create "*scratch*") (set-buffer-major-mode (current-buffer)) - (setq-local lexical-binding t) (current-buffer)))) (defun command-line-1 (args-left)