Fix RET indent of elisp forms following properties

Only affects newline-and-indent, not reindent commands.

Before:

  (list :a 1
    :b 2
    :c 3)

After:

  (list :a 1
        :b 2
        :c 3)

This could use some refactoring...
This commit is contained in:
Henrik Lissner 2020-05-01 02:14:57 -04:00
parent 504d1388cf
commit 03ecfed1a7
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -242,7 +242,9 @@ verbosity when editing a file in `doom-private-dir' or `doom-emacs-dir'."
Indents plists more sensibly. Adapted from Indents plists more sensibly. Adapted from
https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned" https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
(let ((normal-indent (current-column)) (let ((normal-indent (current-column))
(orig-point (point))) (orig-point (point))
;; TODO Refactor `target' usage (ew!)
target)
(goto-char (1+ (elt state 1))) (goto-char (1+ (elt state 1)))
(parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t) (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)
(cond ((and (elt state 2) (cond ((and (elt state 2)
@ -261,10 +263,11 @@ https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
(not (eq (char-after) ?:))) (not (eq (char-after) ?:)))
(save-excursion (save-excursion
(goto-char orig-point) (goto-char orig-point)
(eq (char-after) ?:))) (and (eq (char-after) ?:)
(setq target (current-column)))))
(save-excursion (save-excursion
(goto-char (+ 2 (elt state 1))) (move-to-column target t)
(current-column))) target))
((let* ((function (buffer-substring (point) (progn (forward-sexp 1) (point)))) ((let* ((function (buffer-substring (point) (progn (forward-sexp 1) (point))))
(method (or (function-get (intern-soft function) 'lisp-indent-function) (method (or (function-get (intern-soft function) 'lisp-indent-function)
(get (intern-soft function) 'lisp-indent-hook)))) (get (intern-soft function) 'lisp-indent-hook))))
@ -274,8 +277,7 @@ https://emacs.stackexchange.com/questions/10230/how-to-indent-keywords-aligned"
(string-match-p "\\`def" function))) (string-match-p "\\`def" function)))
(lisp-indent-defform state indent-point)) (lisp-indent-defform state indent-point))
((integerp method) ((integerp method)
(lisp-indent-specform method state (lisp-indent-specform method state indent-point normal-indent))
indent-point normal-indent))
(method (method
(funcall method indent-point state)))))))) (funcall method indent-point state))))))))