1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Indent lambdas/closures better

* lisp/emacs-lisp/pp.el (pp--format-function): Indent lambdas and
closures better.
This commit is contained in:
Lars Ingebrigtsen 2021-11-04 22:07:48 +01:00
parent 292f50d27b
commit fb1267d90a
2 changed files with 20 additions and 1 deletions

View file

@ -236,9 +236,20 @@ Ignores leading comment characters."
(defun pp--format-function (sexp)
(let* ((sym (car sexp))
(edebug (get sym 'edebug-form-spec))
(indent (get sym 'lisp-indent-function)))
(indent (get sym 'lisp-indent-function))
(doc (get sym 'doc-string-elt)))
(when (eq indent 'defun)
(setq indent 2))
;; We probably want to keep all the elements before the doc string
;; on a single line.
(when doc
(setq indent (1- doc)))
;; Special-case closures -- these shouldn't really exist in actual
;; source code, so there's no indentation information. But make
;; them output slightly better.
(when (and (not indent)
(eq sym 'closure))
(setq indent 0))
(pp--insert "(" sym)
(pop sexp)
;; Get the first entries on the first line.