1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-06 03:40:56 -08:00

(pp-buffer): New fun created from the code in

`pp-to-string' modified to be able to format text with newlines.
(pp-to-string): Move the buffer-formatting part of the code to
`pp-buffer'.  Call `pp-buffer'.
This commit is contained in:
Juri Linkov 2004-05-28 21:05:17 +00:00
parent a82456f080
commit 575c3bca4c

View file

@ -50,6 +50,12 @@ to make output that `read' can handle, whenever this is possible."
(let ((print-escape-newlines pp-escape-newlines)
(print-quoted t))
(prin1 object (current-buffer)))
(pp-buffer)
(buffer-string))
(kill-buffer (current-buffer)))))
(defun pp-buffer ()
"Prettify the current buffer with printed representation of a Lisp object."
(goto-char (point-min))
(while (not (eobp))
;; (message "%06d" (- (point-max) (point)))
@ -60,8 +66,10 @@ to make output that `read' can handle, whenever this is possible."
(save-excursion
(backward-char 1)
(skip-chars-backward "'`#^")
(when (and (not (bobp)) (= ?\ (char-before)))
(delete-char -1)
(when (and (not (bobp)) (memq (char-before) '(?\ ?\t ?\n)))
(delete-region
(point)
(progn (skip-chars-backward " \t\n") (point)))
(insert "\n"))))
((condition-case err-var
(prog1 t (up-list 1))
@ -70,13 +78,11 @@ to make output that `read' can handle, whenever this is possible."
(forward-char 1))
(delete-region
(point)
(progn (skip-chars-forward " \t") (point)))
(progn (skip-chars-forward " \t\n") (point)))
(insert ?\n))
(t (goto-char (point-max)))))
(goto-char (point-min))
(indent-sexp)
(buffer-string))
(kill-buffer (current-buffer)))))
(indent-sexp))
;;;###autoload
(defun pp (object &optional stream)