-
-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat: make indentation of special arguments customisable #582
feat: make indentation of special arguments customisable #582
Conversation
Allow control of the indentation of special arguments through a defcustom. - introduces clojure-special-arg-indent-factor, which is used as a factor of lisp-body-ident to indent special arguments. Defaults to 2, the currently hard coded value for this.
What problem is this aiming to solve? I don't recall ever seeing someone use a different indent level for macro forms. |
At work we recently started using zprint to format code. zprint doesn't use a different indent for special arguments. This PR would allow achieving identical formatting with clojure-mode. |
Looking at the examples it seems to the that such forms use 2-space indent there as well https://github.com/kkinnear/zprint/blob/master/doc/options/community.md Can you share some examples so that I can understand better the difference? I guess you should add some examples to the README as well, if we want others to learn about this option and its potential usefulness. |
I don't see a relevant example in the zprint link above. The formatting in question is the handling of special arguments when they are on separate lines. I've added an example with |
Ah, now I see what you mean. I always place the special args on the first line, so it took me a while to process why something like this needed to be customized. I'll ruminate a bit more on this and I'll likely merge it over the weekend. |
Let me know if there is anything that I can do to facilitate this. |
@@ -216,6 +216,24 @@ For instructions on how to write these specifications, see | |||
[this document](https://docs.cider.mx/cider/indent_spec.html). | |||
The only difference is that you're allowed to use lists instead of vectors. | |||
|
|||
The indentation of special arguments is controlled by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this explanation to be a bit confusing, because I don't think we mention the meaning of special arguments anywhere in the readme and at least for me - the special argument is this case (and most of the time) is the body. I understand the examples, but I'm wondering if others won't be confused by them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, forget about this - https://docs.cider.mx/cider/indent_spec.html#special-arguments I no longer remember some of the things I wrote myself. :D
Allow control of the indentation of special arguments through a defcustom.
introduces clojure-special-arg-indent-factor, which is used as a factor of
lisp-body-ident to indent special arguments. Defaults to 2, the currently hard
coded value for this.
The commits are consistent with our [contribution guidelines][1].
You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
You've run
M-x checkdoc
and fixed any warnings in the code you've written.You've updated the changelog (if adding/changing user-visible functionality).
You've updated the readme (if adding/changing user-visible functionality).