>From 7b953b3ec64b26edd812d0ad3e4e01bad4f94193 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Thu, 22 Sep 2016 23:01:21 +0200 Subject: [PATCH] Make backtraces great again --- lisp/emacs-lisp/debug.el | 4 +++- lisp/emacs-lisp/edebug.el | 4 +++- src/eval.c | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/debug.el b/lisp/emacs-lisp/debug.el index 22a3f39..c481ee2 100644 --- a/lisp/emacs-lisp/debug.el +++ b/lisp/emacs-lisp/debug.el @@ -279,7 +279,9 @@ That buffer should be current already." (goto-char (point-min)) (delete-region (point) (progn - (search-forward "\n debug(") + (search-forward (if debugger-lispy-backtrace + "\n (debug " + "\n debug(")) (forward-line (if (eq (car args) 'debug) ;; Remove debug--implement-debug-on-entry ;; and the advice's `apply' frame. diff --git a/lisp/emacs-lisp/edebug.el b/lisp/emacs-lisp/edebug.el index c283c16..a2e9c00 100644 --- a/lisp/emacs-lisp/edebug.el +++ b/lisp/emacs-lisp/edebug.el @@ -3797,7 +3797,9 @@ Otherwise call `debug' normally." (forward-line 1) (delete-region last-ok-point (point))) - ((looking-at "^ edebug") + ((looking-at (if debugger-lispy-backtrace + "^ (edebug" + "^ edebug")) (forward-line 1) (delete-region last-ok-point (point)) ))) diff --git a/src/eval.c b/src/eval.c index 72facd5..fc6e5a6 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3409,13 +3409,17 @@ Output stream used is value of `standard-output'. */) else { tem = backtrace_function (pdl); + if (debugger_lispy_backtrace) + write_string ("("); Fprin1 (tem, Qnil); /* This can QUIT. */ - write_string ("("); + if (!debugger_lispy_backtrace) + write_string ("("); { ptrdiff_t i; for (i = 0; i < backtrace_nargs (pdl); i++) { - if (i) write_string (" "); + if (i || debugger_lispy_backtrace) + write_string(" "); Fprin1 (backtrace_args (pdl)[i], Qnil); } } @@ -3838,6 +3842,10 @@ This is nil when the debugger is called under circumstances where it might not be safe to continue. */); debugger_may_continue = 1; + DEFVAR_BOOL ("debugger-lispy-backtrace", debugger_lispy_backtrace, + doc: /* Non-nil means display call stack frames as lists. */); + debugger_lispy_backtrace = 0; + DEFVAR_LISP ("debugger", Vdebugger, doc: /* Function to call to invoke debugger. If due to frame exit, args are `exit' and the value being returned; -- 2.9.3