Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Emacs Lisp 似乎没有 PPRINT 功能。如何像在 Common Lisp 中那样在 elisp 中漂亮地打印 S-EXP?
使用作为ppGNU Emacs 一部分的库。例如,您可以使用pp-macroexpand-last-sexp美化一个性别。
pp
pp-macroexpand-last-sexp
假设结果cl-prettyprint对您来说已经足够好,下面是如何在流中获取其输出。
cl-prettyprint
(defun pprint (form &optional output-stream) (princ (with-temp-buffer (cl-prettyprint form) (buffer-string)) output-stream))