cut debugger frames from backtraces
authorRobin Templeton <robin@terpri.org>
Tue, 23 Sep 2014 04:44:45 +0000 (00:44 -0400)
committerRobin Templeton <robin@terpri.org>
Mon, 20 Apr 2015 04:29:03 +0000 (00:29 -0400)
Thanks to Oleg Sivokon <olegsivokon@gmail.com> for the report.

* lisp/emacs-lisp/debug.el (debug-inner-cut): New variable.
  (debug-1): New function extracted from `debug'.
  (debug): Call `debug-1' in a new prompt, binding `debug-inner-cut'
  to the prompt tag.
  (debugger-setup-buffer): Cut the backtrace with `debug-inner-cut'.

lisp/emacs-lisp/debug.el

index e3d5cdc..61d8717 100644 (file)
@@ -125,6 +125,8 @@ where CAUSE can be:
 - exit: called because of exit of a flagged function.
 - error: called because of `debug-on-error'.")
 
+(defvar debug-inner-cut)
+
 ;;;###autoload
 (setq debugger 'debug)
 ;;;###autoload
@@ -137,6 +139,13 @@ You may call with no args, or you may pass nil as the first arg and
 any other args you like.  In that case, the list of args after the
 first will be printed into the backtrace buffer."
   (interactive)
+  (let ((debug-inner-cut (funcall (@ (guile) make-prompt-tag))))
+    (funcall (@ (guile) call-with-prompt)
+             debug-inner-cut
+             (lambda () (apply #'debug-1 args))
+             (lambda (k &rest ignore) nil))))
+
+(defun debug-1 (&rest args)
   (if inhibit-redisplay
       ;; Don't really try to enter debugger within an eval from redisplay.
       debugger-value
@@ -274,7 +283,7 @@ That buffer should be current already."
        (print-escape-newlines t)
        (print-level 8)
        (print-length 50))
-    (backtrace))
+    (guile-backtrace debug-inner-cut 0 1))
   (goto-char (point-min))
   (insert "Debugger entered")
   ;; lambda is for debug-on-call when a function call is next.