Commit e08e0880 authored by Stefan Monnier's avatar Stefan Monnier

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.
parent 0c2d921a
Pipeline #1458 failed with stage
in 6 minutes and 53 seconds
......@@ -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,
......
......@@ -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)
......
......@@ -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)
......
......@@ -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.
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment