* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
@ 2019-12-31 15:52 Mattias Engdegård
2020-01-01 16:14 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2019-12-31 15:52 UTC (permalink / raw)
To: 38835
The standard *scratch* buffer is blessed with lexical-binding = t, but if killed and recreated via C-x b *scratch* RET, the new buffer isn't.
Not sure where this logic belongs; the *scratch* handling seems a bit spread out. In Fset_buffer_major_mode?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2019-12-31 15:52 bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil Mattias Engdegård
@ 2020-01-01 16:14 ` Eli Zaretskii
2020-01-01 17:49 ` martin rudalics
2020-01-13 13:57 ` Mattias Engdegård
0 siblings, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2020-01-01 16:14 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: 38835
> From: Mattias Engdegård <mattiase@acm.org>
> Date: Tue, 31 Dec 2019 16:52:18 +0100
>
> The standard *scratch* buffer is blessed with lexical-binding = t, but if killed and recreated via C-x b *scratch* RET, the new buffer isn't.
>
> Not sure where this logic belongs; the *scratch* handling seems a bit spread out. In Fset_buffer_major_mode?
Maybe we should have a command to recreate *scratch*, and call it from
startup.el? Then that command could do this.
Or maybe we should decide that lisp-interaction-mode should do this
for any buffer?
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2020-01-01 16:14 ` Eli Zaretskii
@ 2020-01-01 17:49 ` martin rudalics
2020-01-13 13:57 ` Mattias Engdegård
1 sibling, 0 replies; 8+ messages in thread
From: martin rudalics @ 2020-01-01 17:49 UTC (permalink / raw)
To: Eli Zaretskii, Mattias Engdegård; +Cc: 38835
> Maybe we should have a command to recreate *scratch*, and call it from
> startup.el? Then that command could do this.
'other_buffer_safely' would need it too.
martin
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2020-01-01 16:14 ` Eli Zaretskii
2020-01-01 17:49 ` martin rudalics
@ 2020-01-13 13:57 ` Mattias Engdegård
2020-01-13 16:30 ` Eli Zaretskii
1 sibling, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2020-01-13 13:57 UTC (permalink / raw)
To: Eli Zaretskii, martin rudalics; +Cc: 38835
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
1 jan. 2020 kl. 17.14 skrev Eli Zaretskii <eliz@gnu.org>:
> Or maybe we should decide that lisp-interaction-mode should do this
> for any buffer?
Yes, that seems to be the best and simplest choice. Patch OK for emacs-27?
[-- Attachment #2: 0001-Always-use-lexical-binding-in-lisp-interaction-mode-.patch --]
[-- Type: application/octet-stream, Size: 1854 bytes --]
From e258f78fd1869d301d94ff555358591e49541d94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 13 Jan 2020 14:53:11 +0100
Subject: [PATCH] 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.
---
lisp/progmodes/elisp-mode.el | 3 ++-
lisp/startup.el | 4 +---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 774e3324c2..2617a6e4cc 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -933,7 +933,8 @@ lisp-interaction-mode
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 c27af726f9..2a85c004da 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1435,8 +1435,7 @@ command-line
(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 @@ startup--get-buffer-create-scratch
(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)
--
2.21.0 (Apple Git-122.2)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2020-01-13 13:57 ` Mattias Engdegård
@ 2020-01-13 16:30 ` Eli Zaretskii
2020-01-13 17:04 ` Mattias Engdegård
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-01-13 16:30 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: 38835
> From: Mattias Engdegård <mattiase@acm.org>
> Date: Mon, 13 Jan 2020 14:57:29 +0100
> Cc: 38835@debbugs.gnu.org
>
> > Or maybe we should decide that lisp-interaction-mode should do this
> > for any buffer?
>
> Yes, that seems to be the best and simplest choice. Patch OK for emacs-27?
Yes, but this needs a NEWS entry, and please see if we say enough
about lisp-interaction-mode and/or lexical-binding to mention this in
the manual as well.
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2020-01-13 16:30 ` Eli Zaretskii
@ 2020-01-13 17:04 ` Mattias Engdegård
2020-01-13 18:38 ` Eli Zaretskii
0 siblings, 1 reply; 8+ messages in thread
From: Mattias Engdegård @ 2020-01-13 17:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 38835
[-- Attachment #1: Type: text/plain, Size: 333 bytes --]
13 jan. 2020 kl. 17.30 skrev Eli Zaretskii <eliz@gnu.org>:
> Yes, but this needs a NEWS entry, and please see if we say enough
> about lisp-interaction-mode and/or lexical-binding to mention this in
> the manual as well.
New patch. The existing NEWS entry was rephrased slightly, and a sentence added to the elisp manual.
[-- Attachment #2: 0001-Always-use-lexical-binding-in-lisp-interaction-mode-.patch --]
[-- Type: application/octet-stream, Size: 3232 bytes --]
From d645628e3cf6ebe5eaea3b40100bd77b9c823f8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Mon, 13 Jan 2020 14:53:11 +0100
Subject: [PATCH] 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.
---
doc/lispref/variables.texi | 3 +++
etc/NEWS | 3 ++-
lisp/progmodes/elisp-mode.el | 3 ++-
lisp/startup.el | 4 +---
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/doc/lispref/variables.texi b/doc/lispref/variables.texi
index 1ec97e2f3d..1e357754ab 100644
--- a/doc/lispref/variables.texi
+++ b/doc/lispref/variables.texi
@@ -1187,6 +1187,9 @@ Using Lexical Binding
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 61b9e4a723..031ddf5800 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 774e3324c2..2617a6e4cc 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -933,7 +933,8 @@ lisp-interaction-mode
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 c27af726f9..2a85c004da 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1435,8 +1435,7 @@ command-line
(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 @@ startup--get-buffer-create-scratch
(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)
--
2.21.0 (Apple Git-122.2)
^ permalink raw reply related [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2020-01-13 17:04 ` Mattias Engdegård
@ 2020-01-13 18:38 ` Eli Zaretskii
2020-01-13 18:54 ` Mattias Engdegård
0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2020-01-13 18:38 UTC (permalink / raw)
To: Mattias Engdegård; +Cc: 38835
> From: Mattias Engdegård <mattiase@acm.org>
> Date: Mon, 13 Jan 2020 18:04:22 +0100
> Cc: rudalics@gmx.at, 38835@debbugs.gnu.org
>
> > Yes, but this needs a NEWS entry, and please see if we say enough
> > about lisp-interaction-mode and/or lexical-binding to mention this in
> > the manual as well.
>
> New patch. The existing NEWS entry was rephrased slightly, and a sentence added to the elisp manual.
Thanks, LGTM.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil
2020-01-13 18:38 ` Eli Zaretskii
@ 2020-01-13 18:54 ` Mattias Engdegård
0 siblings, 0 replies; 8+ messages in thread
From: Mattias Engdegård @ 2020-01-13 18:54 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 38835-done
Thank you, pushed to emacs-27.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-01-13 18:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-31 15:52 bug#38835: 27; Recreated *scratch* buffer has lexical-binding = nil Mattias Engdegård
2020-01-01 16:14 ` Eli Zaretskii
2020-01-01 17:49 ` martin rudalics
2020-01-13 13:57 ` Mattias Engdegård
2020-01-13 16:30 ` Eli Zaretskii
2020-01-13 17:04 ` Mattias Engdegård
2020-01-13 18:38 ` Eli Zaretskii
2020-01-13 18:54 ` Mattias Engdegård
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).