[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e08e088: Use lexical-binding by default for M-:, --
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master e08e088: Use lexical-binding by default for M-:, --eval, and *scratch* |
Date: |
Thu, 25 Apr 2019 14:36:12 -0400 (EDT) |
branch: master
commit e08e0880f9892fba747abdb95b1f3382ebd17e32
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
Use lexical-binding by default for M-:, --eval, and *scratch*
* lisp/startup.el (command-line): Default to lexical-binding in *scratch*.
(normal-no-mouse-startup-screen, command-line-1):
Use startup--get-buffer-create-scratch.
(command-line-1):
* lisp/simple.el (eval-expression):
* lisp/server.el (server-eval-and-print): Use lexical-binding to
evaluate the expression.
(server-execute): Use startup--get-buffer-create-scratch.
* lisp/ielm.el (inferior-emacs-lisp-mode): Default to lexical-binding.
---
etc/NEWS | 4 ++++
lisp/ielm.el | 5 +++--
lisp/server.el | 4 ++--
lisp/simple.el | 6 ++++--
lisp/startup.el | 18 +++++++++++++-----
5 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index e861a37..788be70 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -178,6 +178,10 @@ The default value is 30000, as the previously hard-coded
threshold.
+++
** The function 'read-passwd' uses '*' as default character to hide passwords.
+** 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.
+
---
** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text
on GUI frames when tooltips are displayed in the echo area. Instead,
diff --git a/lisp/ielm.el b/lisp/ielm.el
index 82aff99..c7a31a2 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -559,10 +559,11 @@ Customized bindings may be defined in `ielm-map', which
currently contains:
;; Useful for `hs-minor-mode'.
(setq-local comment-start ";")
(setq-local comment-use-syntax t)
+ (setq-local lexical-binding t)
- (set (make-local-variable 'indent-line-function) 'ielm-indent-line)
+ (set (make-local-variable 'indent-line-function) #'ielm-indent-line)
(set (make-local-variable 'ielm-working-buffer) (current-buffer))
- (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph)
+ (set (make-local-variable 'fill-paragraph-function) #'lisp-fill-paragraph)
;; Value holders
(set (make-local-variable '*) nil)
diff --git a/lisp/server.el b/lisp/server.el
index c38fdf8..1e5c57a 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -807,7 +807,7 @@ Server mode runs a process that accepts commands from the
;; intended it to interrupt us rather than interrupt whatever Emacs
;; was doing before it started handling the process filter.
;; Hence `with-local-quit' (bug#6585).
- (let ((v (with-local-quit (eval (car (read-from-string expr))))))
+ (let ((v (with-local-quit (eval (car (read-from-string expr)) t))))
(when proc
(with-temp-buffer
(let ((standard-output (current-buffer)))
@@ -1329,7 +1329,7 @@ The following commands are accepted by the client:
(find-file-noselect
initial-buffer-choice))
((functionp
initial-buffer-choice)
(funcall
initial-buffer-choice)))))
- (if (buffer-live-p buf) buf
(get-buffer-create "*scratch*")))))
+ (if (buffer-live-p buf) buf
(startup--get-buffer-create-scratch)))))
;; Set current buffer so that newly created tty frames
;; show the correct buffer initially.
(frame (with-current-buffer (or (car buffers)
diff --git a/lisp/simple.el b/lisp/simple.el
index 160c433..79db712 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1646,12 +1646,14 @@ this command arranges for all errors to enter the
debugger."
(eval-expression-get-print-arguments current-prefix-arg)))
(if (null eval-expression-debug-on-error)
- (push (eval (macroexpand-all exp) lexical-binding) values)
+ (push (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)
+ values))
(let ((old-value (make-symbol "t")) new-value)
;; Bind debug-on-error to something unique so that we can
;; detect when evalled code changes it.
(let ((debug-on-error old-value))
- (push (eval (macroexpand-all exp) lexical-binding) values)
+ (push (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)
+ values)
(setq new-value debug-on-error))
;; If evalled code has changed the value of debug-on-error,
;; propagate that change to the global binding.
diff --git a/lisp/startup.el b/lisp/startup.el
index a9b58c5..421a6ea 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1378,7 +1378,8 @@ please check its value")
(if (get-buffer "*scratch*")
(with-current-buffer "*scratch*"
(if (eq major-mode 'fundamental-mode)
- (funcall initial-major-mode))))
+ (funcall initial-major-mode))
+ (setq-local lexical-binding t)))
;; Load library for our terminal type.
;; User init file can set term-file-prefix to nil to prevent this.
@@ -2124,7 +2125,7 @@ If you have no Meta key, you may instead type ESC
followed by the character.)"))
(insert "\t\t")
(insert-button "Open *scratch* buffer"
'action (lambda (_button) (switch-to-buffer
- (get-buffer-create "*scratch*")))
+ (startup--get-buffer-create-scratch)))
'follow-link t)
(insert "\n")
(insert "\n" (emacs-version) "\n" emacs-copyright "\n")
@@ -2250,6 +2251,13 @@ A fancy display is used on graphic displays, normal
otherwise."
(defalias 'about-emacs 'display-about-screen)
(defalias 'display-splash-screen 'display-startup-screen)
+(defun 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)
"A subroutine of `command-line'."
(display-startup-echo-area-message)
@@ -2399,7 +2407,7 @@ nil default-directory" name)
(unless (= end (length str-expr))
(error "Trailing garbage following expression: %s"
(substring str-expr end)))
- (eval expr)))
+ (eval expr t)))
((member argi '("-L" "-directory"))
;; -L :/foo adds /foo to the _end_ of load-path.
@@ -2514,7 +2522,7 @@ nil default-directory" name)
(when (eq initial-buffer-choice t)
;; When `initial-buffer-choice' equals t make sure that *scratch*
;; exists.
- (get-buffer-create "*scratch*"))
+ (startup--get-buffer-create-scratch))
;; If *scratch* exists and is empty, insert initial-scratch-message.
;; Do this before switching to *scratch* below to handle bug#9605.
@@ -2538,7 +2546,7 @@ nil default-directory" name)
((functionp initial-buffer-choice)
(funcall initial-buffer-choice))
((eq initial-buffer-choice t)
- (get-buffer-create "*scratch*"))
+ (startup--get-buffer-create-scratch))
(t
(error "`initial-buffer-choice' must be a string, a
function, or t")))))
(unless (buffer-live-p buf)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e08e088: Use lexical-binding by default for M-:, --eval, and *scratch*,
Stefan Monnier <=