[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/handler-bind-2 19f1d2a9f51 02/16: (eval-expression): Fix bug#671
From: |
Stefan Monnier |
Subject: |
scratch/handler-bind-2 19f1d2a9f51 02/16: (eval-expression): Fix bug#67196 |
Date: |
Wed, 27 Dec 2023 23:53:30 -0500 (EST) |
branch: scratch/handler-bind-2
commit 19f1d2a9f5111a2f06003f45f3af2a39c7029047
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
(eval-expression): Fix bug#67196
* lisp/simple.el (eval-expression--debug): New function.
(eval-expression): Use it together with `handler-bind` instead of
let-binding `debug-on-error`.
---
lisp/simple.el | 29 +++++++++++++----------------
1 file changed, 13 insertions(+), 16 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index cee1ddac52f..6a9c15f30c1 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2087,6 +2087,9 @@ of the prefix argument for `eval-expression' and
((= num -1) most-positive-fixnum)
(t eval-expression-print-maximum-character)))))
+(defun eval-expression--debug (err)
+ (funcall debugger 'error err :backtrace-base #'eval-expression--debug))
+
;; We define this, rather than making `eval' interactive,
;; for the sake of completion of names like eval-region, eval-buffer.
(defun eval-expression (exp &optional insert-value no-truncate
char-print-limit)
@@ -2120,23 +2123,17 @@ this command arranges for all errors to enter the
debugger."
(cons (read--expression "Eval: ")
(eval-expression-get-print-arguments current-prefix-arg)))
- (let (result)
+ (let* (result
+ (runfun
+ (lambda ()
+ (setq result
+ (values--store-value
+ (eval (let ((lexical-binding t)) (macroexpand-all exp))
+ t))))))
(if (null eval-expression-debug-on-error)
- (setq result
- (values--store-value
- (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
- (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))
- (setq result
- (values--store-value
- (eval (let ((lexical-binding t)) (macroexpand-all exp)) t)))
- (setq new-value debug-on-error))
- ;; If evalled code has changed the value of debug-on-error,
- ;; propagate that change to the global binding.
- (unless (eq old-value new-value)
- (setq debug-on-error new-value))))
+ (funcall runfun)
+ (handler-bind ((error #'eval-expression--debug))
+ (funcall runfun)))
(let ((print-length (unless no-truncate eval-expression-print-length))
(print-level (unless no-truncate eval-expression-print-level))
- branch scratch/handler-bind-2 created (now 94b11fc0c9b), Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 a4efbe4c499 01/16: New special form `handler-bind`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 9f8ea786918 07/16: eval.c: Add new var `lisp-eval-depth-reserve`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 40437afc8ee 09/16: (signal_or_quit): Preserve error object identity, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 19f1d2a9f51 02/16: (eval-expression): Fix bug#67196,
Stefan Monnier <=
- scratch/handler-bind-2 10e04044c7b 06/16: (macroexp--with-extended-form-stack): Use plain `let`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 617d568f4b6 03/16: ert.el: Use `handler-bind` to record backtraces, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 b21a22c86cc 13/16: Allow the `error-message` property to be a function, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 5a3ed126ccc 14/16: tramp.el: Use `handler-bind` instead of `signal-hook-function`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 c03598f1323 11/16: src/eval.c (call_debugger): Don't bind `Qinhibit_changing_match_data`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 bb9e093a106 08/16: Use handler-bind to repair bytecomp-tests, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 bc5500be3b0 15/16: (edebug-format): Make it obsolete, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 d9f047e2da5 05/16: Move batch backtrace code to `top_level_2`, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 235907e1764 12/16: Add `redisplay-counter` to catched nested redisplays and abort outer one, Stefan Monnier, 2023/12/27
- scratch/handler-bind-2 857f1d37037 04/16: startup.el: Use `handler-bind` to implement `--debug-init`, Stefan Monnier, 2023/12/27