-
-
Notifications
You must be signed in to change notification settings - Fork 247
Define a variable for locally customizing indentation #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
clojure-backtracking-indent is still optional (the option still works), but instead of using its own symbol property, it uses clojure-indent-function instead. The clojure-backtracking-indent symbol property actually still works, but is obsolete.
The first commit merged the two symbol properties into one. |
This variable provides a way of overriding the clojure-indent-function symbol property on a buffer-local basis.
Ok, I see now that merging the two like this is not backwards compatible. |
Wish I could. :-) This is where we see the failure of lack of documentation and tests. |
Btw, I wrote a bit more about this on gitter. This whole functionality has a funny story - it was introduced in the very first version of You have carte blanche to deal with this as you see fit, as long we simplify the inner workings in the process. |
Ok, I may have abused your carte blanche here. |
Haven't went through the changes in great detail, but they look good to me. You'll definitely won't get much feedback about the quality of new code on the Clojure mailing list, but might receive some comments about the structure of the indentation spec at least. |
Oh yes, that's what I meant. |
Fixed the docstring and added some tests for The other commit didn't actually change any functionality. So the existing tests should be a great way to verify it's validity. :-) |
There were zero tests for the backtracking indent... :-) Adding tests in an unavoidable task at this point. |
Ok. I've added a couple of tests and I think I'm ready to merge this. |
[Fix #282 Fix #296] Use custom-code to calculate normal-indent. Add tests for backtracking indent and several other scenarios. Support a new notation for indent specs. An indent spec can be: - `nil` (or absent), meaning “indent like a regular function”. - A list/vector meaning that this function/macro takes a number of “special” arguments which are indented by more spaces (in CIDER that's 4 spaces), and then all other arguments are indented like a body (in CIDER that's 2 spaces). - The first element is a number indicating how many "special" arguments this function/macro takes. - Each following element is an indent spec on its own, and it applies to the argument on the same position as this element. So, when the argument is a form, it specifies how to indent that argument internally (if it's not a form the spec is irrelevant). - If the function/macro has more aguments than the list has elements, the last element of the list applies to all remaining arguments. So, for instance, if I specify the `deftype` spec as `[2 nil nil fn]` (equivalent to `[2 nil nil [1]]`), it would be indented like this: ``` (deftype ImageSelection [data] Transferable (getTransferDataFlavors [this] (some-function)) SomethingElse (isDataFlavorSupported [this flavor] (= imageFlavor flavor))) ``` (I put `ImageSelection` and `[data]` on their own lines just to show the indentation). Another example, `reify` as `[1 nil fn]` ``` (reify Object (toString [this] (f) asodkaodkap)) ``` Or something more complicated, `letfn` as `[1 [fn] nil]` ``` (letfn [(twice [x] (* x 2)) (six-times [y] (* (twice y) 3))] (println "Twice 15 =" (twice 15)) (println "Six times 15 =" (six-times 15))) ```
Define a variable for locally customizing indentation
On a related note - the section in the README about indentation has to be updated/extended. |
No description provided.