Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PPRINT in Emacs Lisp?

Tags:

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?

like image 257
anthonyf Avatar asked Aug 23 '10 22:08

anthonyf


2 Answers

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

like image 139
Jérôme Radix Avatar answered Jan 06 '23 02:01

Jérôme Radix


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)) 
like image 44
Gilles 'SO- stop being evil' Avatar answered Jan 06 '23 04:01

Gilles 'SO- stop being evil'