mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-03 10:31:37 -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:
parent
da6e4a8625
commit
d331149933
3 changed files with 21 additions and 18 deletions
|
|
@ -308,17 +308,24 @@ can handle, whenever this is possible.
|
|||
Uses the pretty-printing code specified in `pp-default-function'.
|
||||
|
||||
Output stream is STREAM, or value of `standard-output' (which see)."
|
||||
(cond
|
||||
((and (eq (or stream standard-output) (current-buffer))
|
||||
;; Make sure the current buffer is setup sanely.
|
||||
(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)
|
||||
;; Preserve old behavior of (usually) finishing with a newline.
|
||||
(unless (bolp) (insert "\n")))
|
||||
(t
|
||||
(princ (pp-to-string object) (or stream standard-output)))))
|
||||
(let ((stream (or stream standard-output)))
|
||||
(cond
|
||||
((and (eq stream (current-buffer))
|
||||
;; Make sure the current buffer is setup sanely.
|
||||
(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)
|
||||
;; Preserve old behavior of (usually) finishing with a newline.
|
||||
(unless (bolp) (insert "\n")))
|
||||
(t
|
||||
(save-current-buffer
|
||||
(when (bufferp stream) (set-buffer stream))
|
||||
(let ((begin (point))
|
||||
(cols (current-column)))
|
||||
(princ (pp-to-string object) (or stream standard-output))
|
||||
(when (and (> cols 0) (bufferp stream))
|
||||
(indent-rigidly begin (point) cols))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun pp-display-expression (expression out-buffer-name &optional lisp)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue