2 ms·
Your comment is a bit unclear. Can you give an example of what you think no Lisp-aware editor will produce? > They specify a couple core forms that have a body
by kazinator 6y ago
Your comment is a bit unclear. Can you give an example of what you think no Lisp-aware editor will produce?
> They specify a couple core forms that have a body, which is indented "semantically" and the rest is treated like functions where new lines are indented to the first argument.
Your "they" looks like it refers to "examples", which is the first (actually, only) plural word that we encounter in a leftward scan from the pronoun.
I think it's actually supposed to refer to "lisp-aware editors".
Firstly, that is not quite right. There is no fixed core of forms that have a body, because user-defined macros extend that repertoire. You have to teach that to your editor, in the light of what projects you are editing. For instance, in Vi, the ":set lisp" mode has an associated "lispwords" variable which holds a list of the symbol names that are to be treated as operators that have a body rather than functions.
But the code in the Semantic Clojure Formatting page linked to by the submission is in fact exemplifying this formatting. It shows operators that have a body being indented, and function calls exhibiting argument alignment.
Can you cite an example of what you think is wrong?
The only exception I see is the "narrow format" for function calls. But that's not an invention from the Clojure world. I've resorted to that narrow format myself, in code that is deeply nested and hitting the maximum column limit of the surrounding coding convention.
(deeply
(nested |___|___|
......................... (aargh |__|___|__
too |___|___| brick wall
cramped |_|___|__
here |___|___|
I don't like it very much; I prefer to refactor the code to avoid it, if possible. But if you put a line break immediately after the function name, then that is realy the only sensible indentation you can follow.