1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-27 15:52:00 -08:00

pp-fill: Fix tests breakage

* lisp/emacs-lisp/pp.el (pp-to-string, pp-buffer, pp): Preserve old
behavior of (almost always) returning a trailing newline.

* test/lisp/emacs-lisp/pp-tests.el (pp-print-quote): Adjust tests, now
that `pp-to-string` always returns a trailing newline, rather than only
most of the time.

* test/lisp/emacs-lisp/backtrace-tests.el
(backtrace-tests--single-and-multi-line): Make the test less sensitive
to the choice of what is "pretty".
This commit is contained in:
Stefan Monnier 2023-06-17 18:05:33 -04:00
parent 017475a70e
commit a9c962be96
3 changed files with 18 additions and 5 deletions

View file

@ -142,6 +142,8 @@ Optional argument PP-FUNCTION overrides `pp-default-function'."
(lisp-mode-variables nil)
(set-syntax-table emacs-lisp-mode-syntax-table)
(funcall (or pp-function pp-default-function) object)
;; Preserve old behavior of (usually) finishing with a newline.
(unless (bolp) (insert "\n"))
(buffer-string)))
(defun pp--within-fill-column-p ()
@ -236,7 +238,12 @@ it inserts and pretty-prints that arg at point."
(defun pp-buffer ()
"Prettify the current buffer with printed representation of a Lisp object."
(interactive)
(funcall pp-default-function (point-min) (point-max)))
(funcall pp-default-function (point-min) (point-max))
;; Preserve old behavior of (usually) finishing with a newline and
;; with point at BOB.
(goto-char (point-max))
(unless (bolp) (insert "\n"))
(goto-char (point-min)))
(defun pp-28 (beg &optional end) ;FIXME: Better name?
"Prettify the current region with printed representation of a Lisp object.
@ -283,7 +290,9 @@ Output stream is STREAM, or value of `standard-output' (which see)."
(eq (syntax-table) emacs-lisp-mode-syntax-table)
(eq indent-line-function #'lisp-indent-line))
;; Skip the buffer->string->buffer middle man.
(funcall pp-default-function object))
(funcall pp-default-function object)
;; Preserve old behavior of (usually) finishing with a newline.
(unless (bolp) (insert "\n")))
(t
(princ (pp-to-string object) (or stream standard-output)))))