Function: pp-emacs-lisp-code

pp-emacs-lisp-code is an autoloaded and byte-compiled function defined in pp.el.gz.

Signature

(pp-emacs-lisp-code SEXP &optional END)

Documentation

Insert SEXP into the current buffer, formatted as Emacs Lisp code.

Use the pp-max-width variable to control the desired line length. Note that this could be slow for large SEXPs. Can also be called with two arguments, in which case they're taken to be the bounds of a region containing Lisp code to pretty-print.

Probably introduced at or before Emacs version 29.1.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/pp.el.gz
;;;###autoload
(defun pp-emacs-lisp-code (sexp &optional end)
  "Insert SEXP into the current buffer, formatted as Emacs Lisp code.
Use the `pp-max-width' variable to control the desired line length.
Note that this could be slow for large SEXPs.
Can also be called with two arguments, in which case they're taken to be
the bounds of a region containing Lisp code to pretty-print."
  (require 'edebug)
  (if end (pp--region sexp end #'pp-emacs-lisp-code)
    (let ((obuf (current-buffer)))
      (with-temp-buffer
        (emacs-lisp-mode)
        (pp--insert-lisp sexp)
        (insert "\n")
        (goto-char (point-min))
        (indent-sexp)
        (while (re-search-forward " +$" nil t)
          (replace-match ""))
        (insert-into-buffer obuf)))))