]> git.eshelyaron.com Git - emacs.git/commitdiff
Restore some public debugging functions removed in Emacs 27
authorGemini Lasswell <gazally@runbox.com>
Thu, 1 Oct 2020 17:59:58 +0000 (19:59 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 1 Oct 2020 18:00:19 +0000 (20:00 +0200)
* lisp/emacs-lisp/backtrace.el (backtrace--to-string): New function.
(backtrace-to-string): Use it.  Fix whitespace (bug#40728).
* lisp/emacs-lisp/debug.el (debugger-insert-backtrace): New function.
Mark it as obsolete.
(debugger-toggle-locals, debug-help-follow): New aliases.

lisp/emacs-lisp/backtrace.el
lisp/emacs-lisp/debug.el

index 37dad8db16261ba20add63e6ed17caa474c9880e..5874ba72fcde0321e800d5d0abc34b2f394a9706 100644 (file)
@@ -922,11 +922,15 @@ Output stream used is value of `standard-output'."
   (princ (backtrace-to-string (backtrace-get-frames 'backtrace)))
   nil)
 
-(defun backtrace-to-string(&optional frames)
+(defun backtrace-to-string (&optional frames)
   "Format FRAMES, a list of `backtrace-frame' objects, for output.
 Return the result as a string.  If FRAMES is nil, use all
 function calls currently active."
-  (unless frames (setq frames (backtrace-get-frames 'backtrace-to-string)))
+  (substring-no-properties
+   (backtrace--to-string
+    (or frames (backtrace-get-frames 'backtrace-to-string)))))
+
+(defun backtrace--to-string (frames)
   (let ((backtrace-fontify nil))
     (with-temp-buffer
       (backtrace-mode)
@@ -934,8 +938,7 @@ function calls currently active."
             backtrace-frames frames
             backtrace-print-function #'cl-prin1)
       (backtrace-print)
-      (substring-no-properties (filter-buffer-substring (point-min)
-                                                        (point-max))))))
+      (filter-buffer-substring (point-min) (point-max)))))
 
 (provide 'backtrace)
 
index ed28997292f96d7f9c1ea1445d83eabfe2804f49..14957eae0f22b2fec4f99d897e9a9358a88913f6 100644 (file)
@@ -320,6 +320,17 @@ the debugger will not be entered."
      (message "Error in debug printer: %S" err)
      (prin1 obj stream))))
 
+(make-obsolete 'debugger-insert-backtrace
+               "use a `backtrace-mode' buffer or `backtrace-to-string'."
+               "Emacs 27.1")
+
+(defun debugger-insert-backtrace (frames do-xrefs)
+  "Format and insert the backtrace FRAMES at point.
+Make functions into cross-reference buttons if DO-XREFS is non-nil."
+  (insert (if do-xrefs
+              (backtrace--to-string frames)
+            (backtrace-to-string frames))))
+
 (defun debugger-setup-buffer (args)
   "Initialize the `*Backtrace*' buffer for entry to the debugger.
 That buffer should be current already and in debugger-mode."
@@ -527,6 +538,8 @@ The environment used is the one when entering the activation frame at point."
           (let ((str (eval-expression-print-format val)))
             (if str (princ str t))))))))
 
+(defalias 'debugger-toggle-locals 'backtrace-toggle-locals)
+
 \f
 (defvar debugger-mode-map
   (let ((map (make-keymap)))
@@ -621,6 +634,8 @@ Complete list of commands:
             (buffer-substring (line-beginning-position 0)
                               (line-end-position 0)))))
 
+(defalias 'debug-help-follow 'backtrace-help-follow-symbol)
+
 \f
 ;; When you change this, you may also need to change the number of
 ;; frames that the debugger skips.