]> git.eshelyaron.com Git - emacs.git/commitdiff
New user option 'debugger-stack-frame-as-list'
authorVasilij Schneidermann <v.schneidermann@gmail.com>
Fri, 30 Sep 2016 13:22:26 +0000 (16:22 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 30 Sep 2016 13:22:26 +0000 (16:22 +0300)
* src/eval.c (syms_of_eval) <debugger-stack-frame-as-list>: New
variable.
* lisp/cus-start.el (standard): Add debugger-stack-frame-as-list.
* lisp/emacs-lisp/debug.el (debugger-setup-buffer): Adjust
backtrace processing for the value of debugger-stack-frame-as-list.
* lisp/emacs-lisp/edebug.el (edebug-backtrace): Adjust backtrace
processing for the value of debugger-stack-frame-as-list.
* doc/lispref/debugging.texi (Internals of Debugger): Document
debugger-stack-frame-as-list.
* etc/NEWS: Mention 'debugger-stack-frame-as-list'.

doc/lispref/debugging.texi
etc/NEWS
lisp/cus-start.el
lisp/emacs-lisp/debug.el
lisp/emacs-lisp/edebug.el
src/eval.c

index 2f83b4040fa05ee1fdd8a6428435968650171bcb..710ab92fda5d97de15224546aa773b28423e8d0a 100644 (file)
@@ -623,6 +623,37 @@ forms are elided.
 @end smallexample
 @end deffn
 
+@defvar debugger-stack-frame-as-list
+If this variable is non-@code{nil}, every stack frame of the backtrace
+is displayed as a list.  This aims at improving the backtrace
+readability at the cost of special forms no longer being visually
+different from regular function calls.
+
+With @code{debugger-stack-frame-as-list} non-@code{nil}, the above
+example would look as follows:
+
+@smallexample
+@group
+----------- Buffer: backtrace-output ------------
+  (backtrace)
+  (list ...computing arguments...)
+@end group
+  (progn ...)
+  (eval (progn (1+ var) (list (quote testing) (backtrace))))
+  (setq ...)
+  (save-excursion ...)
+  (let ...)
+  (with-output-to-temp-buffer ...)
+  (eval (with-output-to-temp-buffer ...))
+  (eval-last-sexp-1 nil)
+@group
+  (eval-last-sexp nil)
+  (call-interactively eval-last-sexp)
+----------- Buffer: backtrace-output ------------
+@end group
+@end smallexample
+@end defvar
+
 @defvar debug-on-next-call
 @cindex @code{eval}, and debugging
 @cindex @code{apply}, and debugging
index c3f4cf01b26cc87f5fde951b1e830147ab1218ee..dffbac8df65f6e1d8b6492bbee80c3f34555d0f8 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -205,6 +205,11 @@ questions, with a handy way to display help texts.
 +++
 ** 'switch-to-buffer-preserve-window-point' now defaults to t.
 
++++
+** The new variable 'debugger-stack-frame-as-list' allows displaying
+all call stack frames in a Lisp backtrace buffer as lists.  Both
+debug.el and edebug.el have been updated to heed to this variable.
+
 \f
 * Editing Changes in Emacs 25.3
 
index 2b79bbbfda1e8ffd66b9b12acbd45211d83a9264..d9ad0a5971e9768d5ba5e9f5eb85a02cbcad8e0f 100644 (file)
@@ -246,6 +246,7 @@ Leaving \"Default\" unchecked is equivalent with specifying a default of
             (debug-ignored-errors debug (repeat (choice symbol regexp)))
             (debug-on-quit debug boolean)
             (debug-on-signal debug boolean)
+             (debugger-stack-frame-as-list debugger boolean)
             ;; fileio.c
             (delete-by-moving-to-trash auto-save boolean "23.1")
             (auto-save-visited-file-name auto-save boolean)
index 22a3f3935f275d9490bd03642c82e784f208fc1c..7d273809fcddd170f205a6c4963da4ef62634c15 100644 (file)
@@ -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-stack-frame-as-list
+                                       "\n  (debug "
+                                     "\n  debug("))
                   (forward-line (if (eq (car args) 'debug)
                                      ;; Remove debug--implement-debug-on-entry
                                      ;; and the advice's `apply' frame.
index 1a00c45447ca6544cb236d2209bfd740142f23a8..6918539e229b503e9bfadab09cbf7de0e92af2ed 100644 (file)
@@ -3798,7 +3798,9 @@ Otherwise call `debug' normally."
          (forward-line 1)
          (delete-region last-ok-point (point)))
 
-        ((looking-at "^  edebug")
+        ((looking-at (if debugger-stack-frame-as-list
+                          "^  (edebug"
+                        "^  edebug"))
          (forward-line 1)
          (delete-region last-ok-point (point))
          )))
index e08a25a31a084c11ff43a44a65df9bc74d802e53..407561082d12d598c91ef8d16ed91448245390c2 100644 (file)
@@ -3421,13 +3421,17 @@ Output stream used is value of `standard-output'.  */)
       else
        {
          tem = backtrace_function (pdl);
+         if (debugger_stack_frame_as_list)
+           write_string ("(");
          Fprin1 (tem, Qnil);   /* This can QUIT.  */
-         write_string ("(");
+         if (!debugger_stack_frame_as_list)
+           write_string ("(");
          {
            ptrdiff_t i;
            for (i = 0; i < backtrace_nargs (pdl); i++)
              {
-               if (i) write_string (" ");
+               if (i || debugger_stack_frame_as_list)
+                 write_string(" ");
                Fprin1 (backtrace_args (pdl)[i], Qnil);
              }
          }
@@ -3850,6 +3854,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-stack-frame-as-list", debugger_stack_frame_as_list,
+              doc: /* Non-nil means display call stack frames as lists. */);
+  debugger_stack_frame_as_list = 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;