From a0075a4a00bd02c188a134db90ba2682010668fe Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 1 Jul 2020 19:51:45 +0100 Subject: [PATCH] el/dot-emacs.el: Indent `funcall' in a fancy way. I generally want to see the actual arguments lined up, leaving the function name clear. Of course, if things don't fit then we have a single column. --- el/dot-emacs.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index fce80f4..09da2d6 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -4310,6 +4310,23 @@ that character only to be normal punctuation.") lisp-loop-keyword-indentation 6 lisp-loop-forms-indentation 6) +(defun mdw-indent-funcall (path state indent-point sexp-column normal-indent) + "Indent `funcall' more usefully. +Essentially, treat `funcall foo' as a function name, and align the arguments +to `foo'." + (and (null (cdr path)) + (save-excursion + (goto-char (cadr state)) + (forward-char 1) + (let ((start-line (line-number-at-pos))) + (and (condition-case nil (progn (forward-sexp 3) t) + (scan-error nil)) + (progn + (forward-sexp -1) + (and (= start-line (line-number-at-pos)) + (current-column)))))))) +(put 'funcall 'common-lisp-indent-function 'mdw-indent-funcall) + ;; SLIME setup. (defvar mdw-friendly-name "[mdw]" -- 2.11.0