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

(pp): Indent lines right when starting in col > 0

This refines the fix for bug#72561: commit 0a50019308 fixes
the bug by changing `ert--pp-with-indentation-and-newline`,
but it turns out that `pp` was inconsistent (it sometimes
indented the subsequent lines correctly and sometimes not,
depending on the current-buffer's major mode).
So the fix really should be in `pp`, which is what this patch does.

* lisp/emacs-lisp/pp.el (pp): Appropriately indent subsequent lines
if the first line is not inserted in column 0 (tho only when
printing into a buffer since otherwise it's somewhere between
ill-defined and impossible to implement).
* lisp/emacs-lisp/ert.el (ert--pp-with-indentation-and-newline):
Remove the indentation code after `pp` which was just working
around the bug in `pp`.  Also remove the redundant addition of
`\n` since `pp` always does it nowadays.
* test/lisp/help-mode-tests.el (help-mode-tests-xref-on-pp):
Fix thinko.
This commit is contained in:
Stefan Monnier 2024-08-26 11:26:11 -04:00
parent da6e4a8625
commit d331149933
3 changed files with 21 additions and 18 deletions

View file

@ -1316,13 +1316,9 @@ empty string."
(defun ert--pp-with-indentation-and-newline (object)
"Pretty-print OBJECT, indenting it to the current column of point.
Ensures a final newline is inserted."
(let ((begin (point))
(cols (current-column))
(pp-escape-newlines t)
(let ((pp-escape-newlines t)
(print-escape-control-characters t))
(pp object (current-buffer))
(unless (bolp) (insert "\n"))
(indent-rigidly begin (point) cols)))
(pp object (current-buffer))))
(defun ert--insert-infos (result)
"Insert `ert-info' infos from RESULT into current buffer.