Add special lisp indent logic for add-hook

So that inline defun forms are indented like other body forms.
This commit is contained in:
Henrik Lissner 2019-07-21 14:55:33 +02:00
parent be789caa04
commit 18078dd160
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -48,6 +48,14 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;; variable-width indentation is superior in elisp
(add-to-list 'doom-detect-indentation-excluded-modes 'emacs-lisp-mode nil #'eq)
;; Special indentation behavior for `add-hook'; indent like a defun block if
;; it contains `defun' forms and like normal otherwise.
(defun +emacs-lisp--indent-add-hook-fn (indent-point state)
(goto-char indent-point)
(when (looking-at-p "\\s-*(defun ")
(lisp-indent-defform state indent-point)))
(put 'add-hook 'lisp-indent-function #'+emacs-lisp--indent-add-hook-fn)
(add-hook! 'emacs-lisp-mode-hook
#'(outline-minor-mode
;; fontificiation