trace.el: use cl-print

Any non-trivial EIEO object in particular is impossible to read in the
*trace-output* buffer without this.  Functions, hash-tables, etc now
print as they do in backtrace buffers.

* lisp/emacs-lisp/trace.el (cl-print): Require it
(trace-entry-message, trace-exit-message): Use cl-prin1-to-string
This commit is contained in:
João Távora 2023-12-20 12:11:53 -06:00
parent 62bf0b7a57
commit 018cf86605

View file

@ -128,6 +128,8 @@
;;; Code: ;;; Code:
(require 'cl-print)
(defgroup trace nil (defgroup trace nil
"Tracing facility for Emacs Lisp functions." "Tracing facility for Emacs Lisp functions."
:prefix "trace-" :prefix "trace-"
@ -168,13 +170,13 @@ and CONTEXT is a string describing the dynamic context (e.g. values of
some global variables)." some global variables)."
(let ((print-circle t) (let ((print-circle t)
(print-escape-newlines t)) (print-escape-newlines t))
(format "%s%s%d -> %S%s\n" (format "%s%s%d -> %s%s\n"
(mapconcat #'char-to-string (make-string (max 0 (1- level)) ?|) " ") (mapconcat #'char-to-string (make-string (max 0 (1- level)) ?|) " ")
(if (> level 1) " " "") (if (> level 1) " " "")
level level
;; FIXME: Make it so we can click the function name to jump to its ;; FIXME: Make it so we can click the function name to jump to its
;; definition and/or untrace it. ;; definition and/or untrace it.
(cons function args) (cl-prin1-to-string (cons function args))
context))) context)))
(defun trace-exit-message (function level value context) (defun trace-exit-message (function level value context)
@ -184,13 +186,13 @@ and CONTEXT is a string describing the dynamic context (e.g. values of
some global variables)." some global variables)."
(let ((print-circle t) (let ((print-circle t)
(print-escape-newlines t)) (print-escape-newlines t))
(format "%s%s%d <- %s: %S%s\n" (format "%s%s%d <- %s: %s%s\n"
(mapconcat 'char-to-string (make-string (1- level) ?|) " ") (mapconcat 'char-to-string (make-string (1- level) ?|) " ")
(if (> level 1) " " "") (if (> level 1) " " "")
level level
function function
;; Do this so we'll see strings: ;; Do this so we'll see strings:
value (cl-prin1-to-string value)
context))) context)))
(defvar trace--timer nil) (defvar trace--timer nil)