On the subject of the style guide - PRs and issues are always welcome. It’s really hard to get a consensus on some points, so in the end there’s bound to be someone unhappy with certain decisions that were made. 🙂
> I tend to argue these things a lot, because it’s often the case that what people think of as “what lisp needs to do” often boils down to “that’s what emacs does, and it’s hard to change”
@cfleming I don’t believe this is a completely fair assessment of the situation, though. Nothing’s really hard to change, there’s simply no one to change it. I’m working on half the tooling projects for Clojure + all the Emacs stuff (for free) and there’s a hard limit to what I can do.
I get your perspective, but I also get very annoyed that many people just complain about the current situation and do nothing to help…
Lisp history and personal preferences aside I’m open to making whatever changes are needed for better cross-editor collaboration, but I simply don’t have time for all of this and have to focus on the most important things (e.g. rolling out the new nREPL to everyone, etc).
So it’s hard to change is more of a “it’s hard to find the time to change this”.
Btw, just released Orchard 0.3 - the only important change is the var info functionality from cider-nrepl was extracted to orchard.
And yeah - formatting is hard. Having worked a lot on Ruby and Clojure formatters I really hate dealing with this at this point. 😄 Btw, what is
clj-format? I’m normally using
cljformat and it seems to handle the 1-space indentation just fine.
(and that’s btw a good example of something non-standard in Emacs (every other lisp mode uses 1-space indent and that has been historically the norm for Elisp, Common Lisp, Scheme and Racket) we made configurable just in the spirit of collaboration with others)
clj-format might refer to
cljfmt which Calva Formatter is using.
What do you mean by
cljformat seems to handle 1-space indentations just fine, @bozhidar? Is
cljformat the same as
Ops, yeah - cljfmt.
Well, I use this in most of my projects and it doesn’t break the indentation, so I guess it handles this case fine.
I am trying to see how Cider handles it. It seems to be using
cljfmt defaults by default. Is that right? I am looking here: https://github.com/clojure-emacs/cider-nrepl/blob/b479d674e3261a9c067d163325bd2689eb8f7dc4/src/cider/nrepl/middleware/format.clj
The reason I want to know is to try make Calva Formatter format the same way as Cider does, by default. So that teams where both vscode and emacs is used should by default have the code formatted in the same way.
Yeah, although CIDER also has it’s own indentation engine, which you’d be using normally
The idea is that you can alternative rebind the indentation stuff to use
cljfmt if you work in some cross-tool environment.
I don’t really use cljfmt from CIDER, I just add it to the CI of my projects and fail the build on inconsistencies.
That sounds like it means that the indentation engine takes similar decisions as
Yes. That’s what I meant by - “seems it’s compatible with Emacs”. 🙂1😃
I think its author is an Emacs user, based on some presentations I’ve seen by him.
Where do I find Cider’s indentation engine?
You can see the section on “dynamic indentation” in
cider-mode.el, but it’s not just this. CIDER just builds indentation rules for
clojure-mode.el using this specification https://github.com/clojure-emacs/cider/blob/master/doc/indent_spec.md
(which we hope every editor will support some day)
clojure-mode.el’s indentation is partially derived from
lisp-mode.el, so the implementation is not self-contained.
Those are the highlights of the implementation.
Thanks! Code formatting really is more complex than one thinks even after having pondering it some time. :face_with_cowboy_hat:
One more question. This indentation engine. Does it do more than just indentation? I mean, does it reformat the code in other ways, than choosing the indentation for each line?
No, it doesn’t.1👍
It can’t prettify code or something like this.
@bozhidar Sure, I understand, and I understand that some stuff is just hard to change because it comes from the underlying lisp mode or whatever.
But I do think it’s important to distinguish what is the way it is because it’s good to have it that way, and what’s that way just because of historical accident, or because it’s hard to fix or whatever.