chiark / gitweb /
el/dot-emacs.el: Indent `funcall' in a fancy way.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 1 Jul 2020 18:51:45 +0000 (19:51 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 9 Aug 2020 03:34:42 +0000 (04:34 +0100)
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

index fce80f41f7c342eb23cb44b862c70bb1678f9ed5..09da2d690f062274a4ec1f1a29d472eb0d37c1c0 100644 (file)
@@ -4310,6 +4310,23 @@ (setq lisp-simple-loop-indentation 2
       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]"