emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 84f72f19e51: elisp-mode.el: Use `handler-bind` instead of `debug-


From: Stefan Monnier
Subject: master 84f72f19e51: elisp-mode.el: Use `handler-bind` instead of `debug-on-error`
Date: Fri, 23 Feb 2024 16:46:10 -0500 (EST)

branch: master
commit 84f72f19e514db8f8f6e469340fb5fa0719d40b6
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    elisp-mode.el: Use `handler-bind` instead of `debug-on-error`
    
    * lisp/progmodes/elisp-mode.el (elisp-enable-lexical-binding):
    Don't get fooled by a global binding of `lexical-binding` to t.
    (elisp--eval-last-sexp-fake-value): Delete var.
    (elisp--eval-defun): Don't let-bind `debug-on-error` since it's
    already arranged by the only caller.
    (eval-last-sexp, eval-defun): Use `handler-bind` instead of
    `debug-on-error`.
---
 lisp/progmodes/elisp-mode.el | 38 +++++++++++++-------------------------
 1 file changed, 13 insertions(+), 25 deletions(-)

diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index e0c18214ef7..4b1f8022f81 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -309,7 +309,7 @@ Comments in the form will be lost."
 INTERACTIVE non-nil means ask the user for confirmation; this
 happens in interactive invocations."
   (interactive "p")
-  (if lexical-binding
+  (if (and (local-variable-p 'lexical-binding) lexical-binding)
       (when interactive
         (message "lexical-binding already enabled!")
         (ding))
@@ -371,6 +371,12 @@ be used instead.
 
 ;; Font-locking support.
 
+(defun elisp--font-lock-shorthand (_limit)
+  ;; Add faces on shorthands between point and LIMIT.
+  ;; ...
+  ;; Return nil to tell font-lock, that there's nothing left to do.
+  nil)
+
 (defun elisp--font-lock-flush-elisp-buffers (&optional file)
   ;; We're only ever called from after-load-functions, load-in-progress can
   ;; still be t in case of nested loads.
@@ -1582,9 +1588,6 @@ character)."
                               (buffer-substring-no-properties beg end))
        ))))
 
-
-(defvar elisp--eval-last-sexp-fake-value (make-symbol "t"))
-
 (defun eval-sexp-add-defvars (exp &optional pos)
   "Prepend EXP with all the `defvar's that precede it in the buffer.
 POS specifies the starting position where EXP was found and defaults to point."
@@ -1626,16 +1629,9 @@ integer value is also printed as a character of that 
codepoint.
 If `eval-expression-debug-on-error' is non-nil, which is the default,
 this command arranges for all errors to enter the debugger."
   (interactive "P")
-  (if (null eval-expression-debug-on-error)
-      (values--store-value
-       (elisp--eval-last-sexp eval-last-sexp-arg-internal))
-    (let ((value
-          (let ((debug-on-error elisp--eval-last-sexp-fake-value))
-            (cons (elisp--eval-last-sexp eval-last-sexp-arg-internal)
-                  debug-on-error))))
-      (unless (eq (cdr value) elisp--eval-last-sexp-fake-value)
-       (setq debug-on-error (cdr value)))
-      (car value))))
+  (values--store-value
+   (handler-bind ((error (if #'eval-expression--debug #'ignore)))
+     (elisp--eval-last-sexp eval-last-sexp-arg-internal))))
 
 (defun elisp--eval-defun-1 (form)
   "Treat some expressions in FORM specially.
@@ -1694,8 +1690,7 @@ Return the result of evaluation."
   ;; FIXME: the print-length/level bindings should only be applied while
   ;; printing, not while evaluating.
   (defvar elisp--eval-defun-result)
-  (let ((debug-on-error eval-expression-debug-on-error)
-        (edebugging edebug-all-defs)
+  (let ((edebugging edebug-all-defs)
         elisp--eval-defun-result)
     (save-excursion
       ;; Arrange for eval-region to "read" the (possibly) altered form.
@@ -1774,15 +1769,8 @@ which see."
         (defvar edebug-all-defs)
         (eval-defun (not edebug-all-defs)))
        (t
-        (if (null eval-expression-debug-on-error)
-            (elisp--eval-defun)
-          (let (new-value value)
-            (let ((debug-on-error elisp--eval-last-sexp-fake-value))
-              (setq value (elisp--eval-defun))
-              (setq new-value debug-on-error))
-            (unless (eq elisp--eval-last-sexp-fake-value new-value)
-              (setq debug-on-error new-value))
-            value)))))
+        (handler-bind ((error (if #'eval-expression--debug #'ignore)))
+          (elisp--eval-defun)))))
 
 ;;; ElDoc Support
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]