aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/debug.el26
1 files changed, 18 insertions, 8 deletions
diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el
index 7db0f91b746..726005af9b1 100644
--- a/lisp/emacs-lisp/debug.el
+++ b/lisp/emacs-lisp/debug.el
@@ -49,6 +49,12 @@ the middle is discarded, and just the beginning and end are displayed."
49 :group 'debugger 49 :group 'debugger
50 :version "21.1") 50 :version "21.1")
51 51
52(defcustom debugger-print-function #'cl-prin1
53 "Function used to print values in the debugger backtraces."
54 :type 'function
55 :options '(cl-prin1 prin1)
56 :version "26.1")
57
52(defcustom debugger-bury-or-kill 'bury 58(defcustom debugger-bury-or-kill 'bury
53 "What to do with the debugger buffer when exiting `debug'. 59 "What to do with the debugger buffer when exiting `debug'.
54The value affects the behavior of operations on any window 60The value affects the behavior of operations on any window
@@ -265,10 +271,13 @@ first will be printed into the backtrace buffer."
265 debugger-value))) 271 debugger-value)))
266 272
267 273
274(defvar cl-print-compiled-button)
275
268(defun debugger-insert-backtrace (frames do-xrefs) 276(defun debugger-insert-backtrace (frames do-xrefs)
269 "Format and insert the backtrace FRAMES at point. 277 "Format and insert the backtrace FRAMES at point.
270Make functions into cross-reference buttons if DO-XREFS is non-nil." 278Make functions into cross-reference buttons if DO-XREFS is non-nil."
271 (let ((standard-output (current-buffer)) 279 (let ((standard-output (current-buffer))
280 (cl-print-compiled-button t)
272 (eval-buffers eval-buffer-list)) 281 (eval-buffers eval-buffer-list))
273 (require 'help-mode) ; Define `help-function-def' button type. 282 (require 'help-mode) ; Define `help-function-def' button type.
274 (pcase-dolist (`(,evald ,fun ,args ,flags) frames) 283 (pcase-dolist (`(,evald ,fun ,args ,flags) frames)
@@ -278,10 +287,10 @@ Make functions into cross-reference buttons if DO-XREFS is non-nil."
278 (fun-pt (point))) 287 (fun-pt (point)))
279 (cond 288 (cond
280 ((and evald (not debugger-stack-frame-as-list)) 289 ((and evald (not debugger-stack-frame-as-list))
281 (prin1 fun) 290 (funcall debugger-print-function fun)
282 (if args (prin1 args) (princ "()"))) 291 (if args (funcall debugger-print-function args) (princ "()")))
283 (t 292 (t
284 (prin1 (cons fun args)) 293 (funcall debugger-print-function (cons fun args))
285 (cl-incf fun-pt))) 294 (cl-incf fun-pt)))
286 (when fun-file 295 (when fun-file
287 (make-text-button fun-pt (+ fun-pt (length (symbol-name fun))) 296 (make-text-button fun-pt (+ fun-pt (length (symbol-name fun)))
@@ -327,7 +336,7 @@ That buffer should be current already."
327 (insert "--returning value: ") 336 (insert "--returning value: ")
328 (setq pos (point)) 337 (setq pos (point))
329 (setq debugger-value (nth 1 args)) 338 (setq debugger-value (nth 1 args))
330 (prin1 debugger-value (current-buffer)) 339 (funcall debugger-print-function debugger-value (current-buffer))
331 (setf (cl-getf (nth 3 (car frames)) :debug-on-exit) nil) 340 (setf (cl-getf (nth 3 (car frames)) :debug-on-exit) nil)
332 (insert ?\n)) 341 (insert ?\n))
333 ;; Watchpoint triggered. 342 ;; Watchpoint triggered.
@@ -352,7 +361,7 @@ That buffer should be current already."
352 (`error 361 (`error
353 (insert "--Lisp error: ") 362 (insert "--Lisp error: ")
354 (setq pos (point)) 363 (setq pos (point))
355 (prin1 (nth 1 args) (current-buffer)) 364 (funcall debugger-print-function (nth 1 args) (current-buffer))
356 (insert ?\n)) 365 (insert ?\n))
357 ;; debug-on-call, when the next thing is an eval. 366 ;; debug-on-call, when the next thing is an eval.
358 (`t 367 (`t
@@ -362,9 +371,10 @@ That buffer should be current already."
362 (_ 371 (_
363 (insert ": ") 372 (insert ": ")
364 (setq pos (point)) 373 (setq pos (point))
365 (prin1 (if (eq (car args) 'nil) 374 (funcall debugger-print-function
366 (cdr args) args) 375 (if (eq (car args) 'nil)
367 (current-buffer)) 376 (cdr args) args)
377 (current-buffer))
368 (insert ?\n))) 378 (insert ?\n)))
369 (debugger-insert-backtrace frames t) 379 (debugger-insert-backtrace frames t)
370 ;; Place point on "stack frame 0" (bug#15101). 380 ;; Place point on "stack frame 0" (bug#15101).