summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-11-04 23:32:51 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-04 23:32:51 +0100
commita78ac0c5df74be6925f48896fd024f1f6f363c44 (patch)
tree480723b46c0467f5b969db0abf0fe2f089dc0fcb /lisp/emacs-lisp
parent4cf7af5a2a9aecb067d95b96a5965cc74627e86b (diff)
downloademacs-a78ac0c5df74be6925f48896fd024f1f6f363c44.tar.gz
emacs-a78ac0c5df74be6925f48896fd024f1f6f363c44.tar.bz2
emacs-a78ac0c5df74be6925f48896fd024f1f6f363c44.zip
Try harder to keep lines short in pp-emacs-lisp-code
* lisp/emacs-lisp/pp.el (pp--insert): Try harder to keep lines short.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/pp.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index df837fa691e..ffaa2aeb93a 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -333,7 +333,17 @@ Ignores leading comment characters."
(save-excursion
(goto-char start)
(unless (looking-at "[ \t]+$")
- (insert "\n"))))))
+ (insert "\n"))
+ (pp--indent-buffer)
+ (goto-char (point-max))
+ ;; If we're still too wide, then go up one step and try to
+ ;; insert a newline there.
+ (when (> (current-column) (window-width))
+ (condition-case ()
+ (backward-up-list 1)
+ (:success (when (looking-back " " 2)
+ (insert "\n")))
+ (error nil)))))))
(defun pp--indent-buffer ()
(goto-char (point-min))