Description
Here is a well-known problem: often we create a function or a macro which is
meant to be some kind of container for other elements, or some kind of control
structure, so we want the nested calls to be indented defun-style. One obvious
example is functions in Om's dom namespace:
;; how it is indented by default
(dom/div #js {:id "foo"}
(nested-stuff))
;; how it should be indented
(dom/div #js {:id "foo"}
(nested-stuff))
Currently, this issue is dealt with in a number of ways, one of which is to use
heuristics to determine the correct indentation (if first symbol starts with
def
, indent defun-style), and the other is to force users to maintain a giant
nasty list of define-clojure-indent
calls. It is quite obvious that these
solutions are nothing but hacks that do not really work.
Luckily, we already have a place where various source-related data (like
e.g. line number of a definition) are put: vars' metadata. So my proposal is to
make indentation of a form dependent on (explicitly specified by its author)
metadata of the var to which first symbol of the form resolves.
I understand that this issue is much broader in scope than clojure-mode itself
(other IDEs have to support this too in order for this to be useful), and even
within context of Emacs it maybe belongs to CIDER rather than clojure-mode
(since we need an nrepl connection to read metadata), so please feel free to
redirect me to the appropriate place to start the discussion.