diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-04 22:07:48 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2021-11-04 22:07:48 +0100 |
commit | fb1267d90a5c25a29dbdae170ea065e017b05d29 (patch) | |
tree | d87efef56054f081bf8b59598d6ea3f8ee38fe85 /lisp/emacs-lisp | |
parent | 292f50d27b399370809ccb6bbabc365120fc2256 (diff) | |
download | emacs-fb1267d90a5c25a29dbdae170ea065e017b05d29.tar.gz emacs-fb1267d90a5c25a29dbdae170ea065e017b05d29.tar.bz2 emacs-fb1267d90a5c25a29dbdae170ea065e017b05d29.zip |
Indent lambdas/closures better
* lisp/emacs-lisp/pp.el (pp--format-function): Indent lambdas and
closures better.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/pp.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el index ca3f2a270e2..1d7b935b6d9 100644 --- a/lisp/emacs-lisp/pp.el +++ b/lisp/emacs-lisp/pp.el @@ -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. |