[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4cf7af5: Tweak multi-line expressions in pp--format-function
From: |
Lars Ingebrigtsen |
Subject: |
master 4cf7af5: Tweak multi-line expressions in pp--format-function |
Date: |
Thu, 4 Nov 2021 18:16:55 -0400 (EDT) |
branch: master
commit 4cf7af5a2a9aecb067d95b96a5965cc74627e86b
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Tweak multi-line expressions in pp--format-function
* lisp/emacs-lisp/pp.el (pp--format-function): Fix up multi-line
expressions.
---
lisp/emacs-lisp/pp.el | 10 ++++++++--
test/lisp/emacs-lisp/pp-resources/code-formats.erts | 13 ++++++++++++-
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el
index 67a21c5..df837fa 100644
--- a/lisp/emacs-lisp/pp.el
+++ b/lisp/emacs-lisp/pp.el
@@ -267,8 +267,14 @@ Ignores leading comment characters."
;; Get the first entries on the first line.
(if indent
(pp--format-definition sexp indent edebug)
- (while sexp
- (pp--insert " " (pop sexp))))
+ (let ((prev 0))
+ (while sexp
+ (let ((start (point)))
+ ;; Don't put sexps on the same line as a multi-line sexp
+ ;; preceding it.
+ (pp--insert (if (> prev 1) "\n" " ")
+ (pop sexp))
+ (setq prev (count-lines start (point)))))))
(insert ")")))
(defun pp--format-definition (sexp indent edebug)
diff --git a/test/lisp/emacs-lisp/pp-resources/code-formats.erts
b/test/lisp/emacs-lisp/pp-resources/code-formats.erts
index f48e262..c2733d8 100644
--- a/test/lisp/emacs-lisp/pp-resources/code-formats.erts
+++ b/test/lisp/emacs-lisp/pp-resources/code-formats.erts
@@ -40,7 +40,8 @@ Name: code-formats3
(let ((a 1)
(b 2))
(zot-zot-zot-zot-zot-zot 1 2 (funcall
- bar-bar-bar-bar-bar-bar-bar-bar-bar-bar 2))))
+ bar-bar-bar-bar-bar-bar-bar-bar-bar-bar
+ 2))))
=-=-=
@@ -103,3 +104,13 @@ Name: code-formats9
(interactive)
1)
=-=-=
+
+
+Name: code-formats10
+
+=-=
+(funcall foo (concat "zot" (if (length> site 0) site
+ "bar")
+ "+"
+ (string-replace " " "+" query)))
+=-=-=
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 4cf7af5: Tweak multi-line expressions in pp--format-function,
Lars Ingebrigtsen <=