Indent ERT failure explanations rigidly

This also affects the listing of `should' forms produced by hitting
the L key on a test button in an ERT buffer.

* lisp/emacs-lisp/ert.el (ert--pp-with-indentation-and-newline):
Indent the pretty-printed result to match the caller's current column
as a reference indentation.
* test/lisp/emacs-lisp/ert-tests.el
(ert--pp-with-indentation-and-newline): New test.  (Bug#72561)
This commit is contained in:
F. Jason Park 2024-08-09 16:49:28 -07:00
parent 713069dd7a
commit 0a50019308
2 changed files with 56 additions and 3 deletions

View file

@ -1317,13 +1317,12 @@ empty string."
"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)
(print-escape-control-characters t))
(pp object (current-buffer))
(unless (bolp) (insert "\n"))
(save-excursion
(goto-char begin)
(indent-sexp))))
(indent-rigidly begin (point) cols)))
(defun ert--insert-infos (result)
"Insert `ert-info' infos from RESULT into current buffer.