emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 08108a856a: debug-early: Print bytecode in a more manageable way


From: Stefan Monnier
Subject: master 08108a856a: debug-early: Print bytecode in a more manageable way
Date: Fri, 29 Apr 2022 22:18:16 -0400 (EDT)

branch: master
commit 08108a856a544a80d11b1e9e437fe6c45e25adec
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    debug-early: Print bytecode in a more manageable way
    
    * lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
    Escape newlines to and bytecodes to make backtraces slightly more
    readable.  Use `cl-prin1` when available.
---
 lisp/emacs-lisp/debug-early.el | 44 +++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/lisp/emacs-lisp/debug-early.el b/lisp/emacs-lisp/debug-early.el
index 85ed5f2176..4f1f4b8155 100644
--- a/lisp/emacs-lisp/debug-early.el
+++ b/lisp/emacs-lisp/debug-early.el
@@ -35,30 +35,34 @@
 
 (defalias 'debug-early-backtrace
   #'(lambda ()
-  "Print a trace of Lisp function calls currently active.
+      "Print a trace of Lisp function calls currently active.
 The output stream used is the value of `standard-output'.
 
 This is a simplified version of the standard `backtrace'
 function, intended for use in debugging the early parts
 of the build process."
-  (princ "\n")
-  (mapbacktrace
-   #'(lambda (evald func args _flags)
-       (let ((args args))
-        (if evald
-            (progn
-              (princ "  ")
-              (prin1 func)
-              (princ "("))
-          (progn
-            (princ "  (")
-            (setq args (cons func args))))
-        (if args
-            (while (progn
-                     (prin1 (car args))
-                     (setq args (cdr args)))
-              (princ " ")))
-        (princ ")\n"))))))
+      (princ "\n")
+      (let ((print-escape-newlines t)
+            (print-escape-control-characters t)
+            (print-escape-nonascii t)
+            (prin1 (if (fboundp 'cl-prin1) #'cl-prin1 #'prin1)))
+        (mapbacktrace
+         #'(lambda (evald func args _flags)
+             (let ((args args))
+              (if evald
+                  (progn
+                    (princ "  ")
+                    (funcall prin1 func)
+                    (princ "("))
+                (progn
+                  (princ "  (")
+                  (setq args (cons func args))))
+              (if args
+                  (while (progn
+                           (funcall prin1 (car args))
+                           (setq args (cdr args)))
+                    (princ " ")))
+              (princ ")\n")))))))
 
 (defalias 'debug-early
   #'(lambda (&rest args)
@@ -76,7 +80,7 @@ superseded by `debug' after enough Lisp has been loaded to
 support the latter, except in batch mode which always uses
 `debug-early'.
 
-(In versions of Emacs prior to Emacs 29, no backtrace was
+\(In versions of Emacs prior to Emacs 29, no backtrace was
 available before `debug' was usable.)"
   (princ "\nError: ")
   (prin1 (car (car (cdr args))))       ; The error symbol.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]