This was adapted from
https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_indentation_of_quoted_lists/.
It fixes the indentation of quoted data (and plist keywords) so they're
indented like data, rather than function arguments, like so:
BEFORE:
`(foo bar baz
doom emacs)
'(:foo 1
:bar 2
:baz 3)
'(:foo 1
2
3
:bar 4)
(:foo 1
:bar 2)
(:foo 1
;; test comment
:bar 2)
(:foo 1
2
:bar 3)
AFTER:
`(foo bar baz
doom emacs)
'(:foo 1
:bar 2
:baz 3)
'(:foo 1
2
3
:bar 4)
;; only align unquoted keywords if keywords start each line:
(:foo 1
:bar 2)
(:foo 1
;; test comment
:bar 2)
(:foo 1
2
:bar 3)
Also, I added a way to declare that plists in an macro's arguments
should be indented like data:
(put 'map! 'indent-plists-as-data t)
BEFORE:
(map! :localleader
:map emacs-lisp-mode-map
(:prefix ("d" . "debug")
"f" #'+emacs-lisp/edebug-instrument-defun-on
"F" #'+emacs-lisp/edebug-instrument-defun-off))
AFTER:
(map! :localleader
:map emacs-lisp-mode-map
(:prefix ("d" . "debug")
"f" #'+emacs-lisp/edebug-instrument-defun-on
"F" #'+emacs-lisp/edebug-instrument-defun-off))
There was a third improvement I was hoping to include, namely,
proper indentation of interpolated forms:
BEFORE:
`(foo
bar
,(if t
'baz
'boo))
`(foo
bar
(if t
baz
boo))
AFTER:
`(foo
bar
,(if t
'baz
'boo))
`(foo
bar
(if t
baz
boo))
But this was removed because it breaks indentation for quoted macro
forms (or dynamic elisp programming):
BEFORE: (good)
`(with-temp-buffer
(if (always)
(message
"Hello %s"
user-login-name)
(message
"Goodbye %s"
user-login-name)))
AFTER: (bad)
`(with-temp-buffer
(if (always)
(message
"Hello %s"
user-login-name)
(message
"Goodbye %s"
user-login-name)))
Ref: https://www.reddit.com/r/emacs/comments/d7x7x8/finally_fixing_indentation_of_quoted_lists/'