(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 ()
(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.
(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)))))
"Forms in backtrace frames can be on a single line or on multiple lines."
(ert-with-test-buffer (:name "single-multi-line")
(let* ((arg '(lambda (x) ; Quote this so it isn't made into a closure.
+ ;; Make the form long enough so `number' should not
+ ;; appear on the first line once pretty-printed.
+ (interactive (region-beginning))
(let ((number (1+ x)))
(+ x number))))
(header-string "Test header: ")
;; Verify that the form is now back on one line,
;; and that point is at the same place.
(should (string= (backtrace-tests--get-substring
- (- (point) 6) (point)) "number"))
+ (- (point) 6) (point))
+ "number"))
(should-not (= (point) (pos-bol)))
(should (string= (backtrace-tests--get-substring
(pos-bol) (1+ (pos-eol)))
(require 'ert-x)
(ert-deftest pp-print-quote ()
- (should (string= (pp-to-string 'quote) "quote"))
- (should (string= (pp-to-string ''quote) "'quote"))
+ (should (string= (pp-to-string 'quote) "quote\n"))
+ (should (string= (pp-to-string ''quote) "'quote\n"))
(should (string= (pp-to-string '('a 'b)) "('a 'b)\n"))
(should (string= (pp-to-string '(''quote 'quote)) "(''quote 'quote)\n"))
(should (string= (pp-to-string '(quote)) "(quote)\n"))