Closed jeremyheiler closed 9 years ago
That's likely a bug in clojure-mode I haven't noticed. I'll look into it.
OTOH Clojure itself uses 1 space so perhaps we should standardize on 1 space.
@aviflax Clojure itself is known to have the most nonsensical indentation and code style in the industry, so I'd not be so keen to see the entire community do the same.
Also, clojure/core repeatedly tells people to not treat clojure.core
as a golden standard for anything, e.g. code readability. It takes some gnarly parts to bootstrap a homoiconic language.
@aviflax I think that @michaelklishin is right - having something in Clojure's own source code doesn't make it automatically good style. Personally I can't think of a single idea to indent cond
differently (and AFAIK no other Lisp does so).
I see this happening for many functions. At first I thought something else in my emacs config might be causing problems, but now I've found this bug I'm thinking perhaps not.
For example, using Stuart Sierra's component library:
(component/using
(app/app-component app-options)
[:some-stuff :some-other-stuff])
also I'm seeing the same thing for clojure.core
functions:
(repeatedly
#(Math/random))
I thought that maybe clojure-defun-style-default-indent
might be good enough, but that also impacts clojure.core
functions, causing functions like map
(or I guess any function I pass an arg on the same line, then a second arg on the next line) to be indented wrongly (IMO - correct me if it is intended behaviour).
It's been a while since the last comment on this - is it still regarded as a bug? If so is there an issue open on clojure-emacs/clojure-mode?
Feels like bug in clojure-mode to me.
Yeah, I'd say it's a bug. I'm planning to work on improving font-locking and indentation in clojure-mode
. Hopefully I'll get to fixing this as well.
In light of the discussion in https://github.com/clojure-emacs/clojure-mode/issues/235 should we update clojure-mode
or the guide? I'm on the fence about this given all the CL baggage, but using 2-space indent seems more sensible.
+1 for two-space indent and updating clojure-mode
.
Another vote for 2-space indent and updating clojure-mode
.
Here's another vote for 2-space indentation. IMHO the goal of increasing indentation levels is to visually demarcate the segment. I don't believe that 1-space indentation does so effectively.
OK, I've updated clojure-mode
.
Now https://github.com/bbatsov/clojure-style-guide#one-space-indent rule is quite confusing for me as a clojure novice.
What is the difference between or/and
and cond
? clojure-emacs discussion ended up in
Lists get a single space indent unless it's a known macro form, in which case it gets two?
Isn't or
well known?
@nashbridges it's not about whether or not a macro is well known, but about if the macros is taking a body form (which is indented by 2 spaces, and not aligned with preceding arguments, e.g. bindings). Many of these macros are well known, but don't have to be. E.g. you can write your own macros which take body forms which should be indented accordingly. The macros or
and and
don't take body forms and are therefore formatted like normal functions.
cond
is controversial since it objectively doesn't take a body form but a list of clauses. But since this list can get quite long it kind of feels like a body form.
The indentation for
cond
in the guide uses two spaces, but clojure-mode enforces one space. Given that clojure-mode is actively used, should we update the guide?