Function: pp-28

pp-28 is an interactive and byte-compiled function defined in pp.el.gz.

Signature

(pp-28 BEG &optional END)

Documentation

Prettify the current region with printed representation of a Lisp object.

Uses the pretty-printing algorithm that was standard before Emacs 30. Non-interactively can also be called with a single argument, in which case that argument will be inserted pretty-printed at point.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/pp.el.gz
(defun pp-28 (beg &optional end)        ;FIXME: Better name?
  "Prettify the current region with printed representation of a Lisp object.
Uses the pretty-printing algorithm that was standard before Emacs 30.
Non-interactively can also be called with a single argument, in which
case that argument will be inserted pretty-printed at point."
  (interactive "r")
  (if (null end) (pp--object beg #'pp-29)
    (with-restriction beg end
      (goto-char (point-min))
      (while (not (eobp))
        (cond
         ((ignore-errors (down-list 1) t)
          (save-excursion
            (backward-char 1)
            (skip-chars-backward "'`#^")
            (when (and (not (bobp)) (memq (char-before) '(?\s ?\t ?\n)))
              (delete-region
               (point)
               (progn (skip-chars-backward " \t\n") (point)))
              (insert "\n"))))
         ((ignore-errors (up-list 1) t)
          (skip-syntax-forward ")")
          (delete-region
           (point)
           (progn (skip-chars-forward " \t\n") (point)))
          (insert ?\n))
         (t (goto-char (point-max)))))
      (goto-char (point-min))
      (indent-sexp))))