开发者

PPRINT in Emacs Lisp?

开发者 https://www.devze.com 2023-01-13 06:41 出处:网络
Emacs Lisp does not seem to have a PPRINT function.开发者_运维技巧How do you pretty print an S-EXP in elisp the way you can in Common Lisp?Use the pp library which is part of GNU Emacs. For example yo

Emacs Lisp does not seem to have a PPRINT function. 开发者_运维技巧How do you pretty print an S-EXP in elisp the way you can in Common Lisp?


Use the pp library which is part of GNU Emacs. For example you can use pp-macroexpand-last-sexp for prettifying an sexp.


Assuming that the result of cl-prettyprint is good enough for you, here's how to get its output in a stream.

(defun pprint (form &optional output-stream)
  (princ (with-temp-buffer
           (cl-prettyprint form)
           (buffer-string))
         output-stream))
0

精彩评论

暂无评论...
验证码 换一张
取 消