aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2019-04-25 14:36:03 -0400
committerStefan Monnier2019-04-25 14:36:03 -0400
commite08e0880f9892fba747abdb95b1f3382ebd17e32 (patch)
treea77c6861a632026546804e6482c6a3adbdbab9bc
parent0c2d921a75375e5667224bfd92b28be3b77977b3 (diff)
downloademacs-e08e0880f9892fba747abdb95b1f3382ebd17e32.tar.gz
emacs-e08e0880f9892fba747abdb95b1f3382ebd17e32.zip
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.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ielm.el5
-rw-r--r--lisp/server.el4
-rw-r--r--lisp/simple.el6
-rw-r--r--lisp/startup.el18
5 files changed, 26 insertions, 11 deletions
diff --git a/etc/NEWS b/etc/NEWS
index e861a372b17..788be7060af 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -178,6 +178,10 @@ The default value is 30000, as the previously hard-coded threshold.
178+++ 178+++
179** The function 'read-passwd' uses '*' as default character to hide passwords. 179** The function 'read-passwd' uses '*' as default character to hide passwords.
180 180
181** Lexical binding is now used when evaluating interactive Elisp forms
182More specifically, lexical-binding is now used for M-:, --eval, as well
183as in the *scratch* and *ielm* buffers.
184
181--- 185---
182** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text 186** The new option 'tooltip-resize-echo-area' avoids truncating tooltip text
183on GUI frames when tooltips are displayed in the echo area. Instead, 187on GUI frames when tooltips are displayed in the echo area. Instead,
diff --git a/lisp/ielm.el b/lisp/ielm.el
index 82aff9901ba..c7a31a23e68 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -559,10 +559,11 @@ Customized bindings may be defined in `ielm-map', which currently contains:
559 ;; Useful for `hs-minor-mode'. 559 ;; Useful for `hs-minor-mode'.
560 (setq-local comment-start ";") 560 (setq-local comment-start ";")
561 (setq-local comment-use-syntax t) 561 (setq-local comment-use-syntax t)
562 (setq-local lexical-binding t)
562 563
563 (set (make-local-variable 'indent-line-function) 'ielm-indent-line) 564 (set (make-local-variable 'indent-line-function) #'ielm-indent-line)
564 (set (make-local-variable 'ielm-working-buffer) (current-buffer)) 565 (set (make-local-variable 'ielm-working-buffer) (current-buffer))
565 (set (make-local-variable 'fill-paragraph-function) 'lisp-fill-paragraph) 566 (set (make-local-variable 'fill-paragraph-function) #'lisp-fill-paragraph)
566 567
567 ;; Value holders 568 ;; Value holders
568 (set (make-local-variable '*) nil) 569 (set (make-local-variable '*) nil)
diff --git a/lisp/server.el b/lisp/server.el
index c38fdf84835..1e5c57a1c52 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -807,7 +807,7 @@ Server mode runs a process that accepts commands from the
807 ;; intended it to interrupt us rather than interrupt whatever Emacs 807 ;; intended it to interrupt us rather than interrupt whatever Emacs
808 ;; was doing before it started handling the process filter. 808 ;; was doing before it started handling the process filter.
809 ;; Hence `with-local-quit' (bug#6585). 809 ;; Hence `with-local-quit' (bug#6585).
810 (let ((v (with-local-quit (eval (car (read-from-string expr)))))) 810 (let ((v (with-local-quit (eval (car (read-from-string expr)) t))))
811 (when proc 811 (when proc
812 (with-temp-buffer 812 (with-temp-buffer
813 (let ((standard-output (current-buffer))) 813 (let ((standard-output (current-buffer)))
@@ -1329,7 +1329,7 @@ The following commands are accepted by the client:
1329 (find-file-noselect initial-buffer-choice)) 1329 (find-file-noselect initial-buffer-choice))
1330 ((functionp initial-buffer-choice) 1330 ((functionp initial-buffer-choice)
1331 (funcall initial-buffer-choice))))) 1331 (funcall initial-buffer-choice)))))
1332 (if (buffer-live-p buf) buf (get-buffer-create "*scratch*"))))) 1332 (if (buffer-live-p buf) buf (startup--get-buffer-create-scratch)))))
1333 ;; Set current buffer so that newly created tty frames 1333 ;; Set current buffer so that newly created tty frames
1334 ;; show the correct buffer initially. 1334 ;; show the correct buffer initially.
1335 (frame (with-current-buffer (or (car buffers) 1335 (frame (with-current-buffer (or (car buffers)
diff --git a/lisp/simple.el b/lisp/simple.el
index 160c4338452..79db712105a 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1646,12 +1646,14 @@ this command arranges for all errors to enter the debugger."
1646 (eval-expression-get-print-arguments current-prefix-arg))) 1646 (eval-expression-get-print-arguments current-prefix-arg)))
1647 1647
1648 (if (null eval-expression-debug-on-error) 1648 (if (null eval-expression-debug-on-error)
1649 (push (eval (macroexpand-all exp) lexical-binding) values) 1649 (push (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)
1650 values))
1650 (let ((old-value (make-symbol "t")) new-value) 1651 (let ((old-value (make-symbol "t")) new-value)
1651 ;; Bind debug-on-error to something unique so that we can 1652 ;; Bind debug-on-error to something unique so that we can
1652 ;; detect when evalled code changes it. 1653 ;; detect when evalled code changes it.
1653 (let ((debug-on-error old-value)) 1654 (let ((debug-on-error old-value))
1654 (push (eval (macroexpand-all exp) lexical-binding) values) 1655 (push (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)
1656 values)
1655 (setq new-value debug-on-error)) 1657 (setq new-value debug-on-error))
1656 ;; If evalled code has changed the value of debug-on-error, 1658 ;; If evalled code has changed the value of debug-on-error,
1657 ;; propagate that change to the global binding. 1659 ;; propagate that change to the global binding.
diff --git a/lisp/startup.el b/lisp/startup.el
index a9b58c5e013..421a6ea37db 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1378,7 +1378,8 @@ please check its value")
1378 (if (get-buffer "*scratch*") 1378 (if (get-buffer "*scratch*")
1379 (with-current-buffer "*scratch*" 1379 (with-current-buffer "*scratch*"
1380 (if (eq major-mode 'fundamental-mode) 1380 (if (eq major-mode 'fundamental-mode)
1381 (funcall initial-major-mode)))) 1381 (funcall initial-major-mode))
1382 (setq-local lexical-binding t)))
1382 1383
1383 ;; Load library for our terminal type. 1384 ;; Load library for our terminal type.
1384 ;; User init file can set term-file-prefix to nil to prevent this. 1385 ;; 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.)"))
2124 (insert "\t\t") 2125 (insert "\t\t")
2125 (insert-button "Open *scratch* buffer" 2126 (insert-button "Open *scratch* buffer"
2126 'action (lambda (_button) (switch-to-buffer 2127 'action (lambda (_button) (switch-to-buffer
2127 (get-buffer-create "*scratch*"))) 2128 (startup--get-buffer-create-scratch)))
2128 'follow-link t) 2129 'follow-link t)
2129 (insert "\n") 2130 (insert "\n")
2130 (insert "\n" (emacs-version) "\n" emacs-copyright "\n") 2131 (insert "\n" (emacs-version) "\n" emacs-copyright "\n")
@@ -2250,6 +2251,13 @@ A fancy display is used on graphic displays, normal otherwise."
2250(defalias 'about-emacs 'display-about-screen) 2251(defalias 'about-emacs 'display-about-screen)
2251(defalias 'display-splash-screen 'display-startup-screen) 2252(defalias 'display-splash-screen 'display-startup-screen)
2252 2253
2254(defun startup--get-buffer-create-scratch ()
2255 (or (get-buffer "*scratch*")
2256 (with-current-buffer (get-buffer-create "*scratch*")
2257 (set-buffer-major-mode (current-buffer))
2258 (setq-local lexical-binding t)
2259 (current-buffer))))
2260
2253(defun command-line-1 (args-left) 2261(defun command-line-1 (args-left)
2254 "A subroutine of `command-line'." 2262 "A subroutine of `command-line'."
2255 (display-startup-echo-area-message) 2263 (display-startup-echo-area-message)
@@ -2399,7 +2407,7 @@ nil default-directory" name)
2399 (unless (= end (length str-expr)) 2407 (unless (= end (length str-expr))
2400 (error "Trailing garbage following expression: %s" 2408 (error "Trailing garbage following expression: %s"
2401 (substring str-expr end))) 2409 (substring str-expr end)))
2402 (eval expr))) 2410 (eval expr t)))
2403 2411
2404 ((member argi '("-L" "-directory")) 2412 ((member argi '("-L" "-directory"))
2405 ;; -L :/foo adds /foo to the _end_ of load-path. 2413 ;; -L :/foo adds /foo to the _end_ of load-path.
@@ -2514,7 +2522,7 @@ nil default-directory" name)
2514 (when (eq initial-buffer-choice t) 2522 (when (eq initial-buffer-choice t)
2515 ;; When `initial-buffer-choice' equals t make sure that *scratch* 2523 ;; When `initial-buffer-choice' equals t make sure that *scratch*
2516 ;; exists. 2524 ;; exists.
2517 (get-buffer-create "*scratch*")) 2525 (startup--get-buffer-create-scratch))
2518 2526
2519 ;; If *scratch* exists and is empty, insert initial-scratch-message. 2527 ;; If *scratch* exists and is empty, insert initial-scratch-message.
2520 ;; Do this before switching to *scratch* below to handle bug#9605. 2528 ;; Do this before switching to *scratch* below to handle bug#9605.
@@ -2538,7 +2546,7 @@ nil default-directory" name)
2538 ((functionp initial-buffer-choice) 2546 ((functionp initial-buffer-choice)
2539 (funcall initial-buffer-choice)) 2547 (funcall initial-buffer-choice))
2540 ((eq initial-buffer-choice t) 2548 ((eq initial-buffer-choice t)
2541 (get-buffer-create "*scratch*")) 2549 (startup--get-buffer-create-scratch))
2542 (t 2550 (t
2543 (error "`initial-buffer-choice' must be a string, a function, or t"))))) 2551 (error "`initial-buffer-choice' must be a string, a function, or t")))))
2544 (unless (buffer-live-p buf) 2552 (unless (buffer-live-p buf)