From 4997032c05e7929d6f306d5195da7c3accfad79f Mon Sep 17 00:00:00 2001
From: Gemini Lasswell <gazally@runbox.com>
Date: Thu, 1 Oct 2020 19:59:58 +0200
Subject: Restore some public debugging functions removed in Emacs 27

* 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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'lisp/emacs-lisp/backtrace.el')

diff --git a/lisp/emacs-lisp/backtrace.el b/lisp/emacs-lisp/backtrace.el
index 37dad8db162..5874ba72fcd 100644
--- a/lisp/emacs-lisp/backtrace.el
+++ b/lisp/emacs-lisp/backtrace.el
@@ -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)
 
-- 
cgit v1.2.3