This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-27
Channels
- # beginners (106)
- # boot (124)
- # cider (11)
- # clojure (105)
- # clojure-poland (2)
- # clojure-russia (28)
- # clojurescript (89)
- # core-async (14)
- # cursive (10)
- # datomic (7)
- # emacs (12)
- # garden (5)
- # hoplon (345)
- # immutant (127)
- # mount (2)
- # off-topic (24)
- # om (24)
- # onyx (8)
- # parinfer (51)
- # proton (2)
- # slack-help (4)
- # spacemacs (1)
@sekao: This confused me as well at first. I don’t think paren mode is actually useful as an editing mode to expose to the user.
vs
Paren mode just corrects the file so that it’s within the invariants required by indent mode.
I think it’s mostly useful for that that correction.
@cfleming that makes sense, there is a lot of subtlety to indentation. it does however mean that this will be more challenging to integrate into my ide than I thought ;) it will be hard to post-process the output of paren mode, especially since indent mode may misinterpret it
I don't actually expose paren mode to the user except for pre processing files and handling enter, btw
@sekao: I'm not sure about "running paren mode on enter"; I don't think other plugins are doing that
have you tried atom-parinfer at all?
@sekao: I'm not convinced that paren mode will do a good enough job on enter for that purpose for the reasons above. I think you'll need some custom indentation code.
It'll work in a lot of cases but in some important ones it won't
@sekao: I use the “indent-on-enter” pattern in Replete and Planck, and I just live with the 1-space indent (and the lack of semantic indentation as @cfleming points out)
catching up from yesterday now
@sekao: paren mode only does one-space indentation because it clamps indentation to valid thresholds
for example, it will clamp:
(defn foo [a b]
c)
to:
(defn foo [a b]
c)
I mean clamping: https://en.wikipedia.org/wiki/Clamping_(graphics)
So the above example is not one-space indentation, because it clamped to max not min
For completeness, here’s one-space indentation responding to clamp min:
(defn foo [a b]
c)
to:
(defn foo [a b]
c)
This has been a stopgap solution for setting indentation since auto-indent is something provided by most editors I thought
precise auto-indent inside thresholds becomes subjective in a few cases. for example, david nolen only ever uses two-space indentation:
(println a
b
c)
not:
(println a
b
c)
and the clojure style guide calls on one-space indentation if a newline comes directly after the first symbol of a call:
(println
a
b
c)
which is something I’ve never done
my point is that Paren Mode allows ALL of the styles above since it only clamps to threshold. It's my intention to not destroy people’s preferred indentation as long as it fits in the threshold.
this means that auto-indentation length must be decided by a thing separate from Paren Mode
I have been working for the past couple days on adding auto-indent on enter for Indent Mode
I thought it would be straight forward since mfikes has been doing the Paren Mode on enter thing
But this case caused me to reevaluate:
(foo|) bar
After pressing enter in Paren Mode:
(foo
|) bar
Then re-enabling Indent Mode:
(foo)
| bar
which is not what we wantMy current opinion is that pressing enter below should produce the following output in Indent Mode.
(foo|) bar
(foo
|)
bar
if the cursor were to move to another line above, then bar
is not at risk of being reabsorbed into the foo
expression
this is the first instance of an explicit action in Parinfer, whereas all other actions are implicit on the text inserted in respective modes.
@cfleming: your idea to run Paren Mode when inserting a )
could be a second explicit that may lead us to an Auto Mode
i’ve been spelunking on this issue pretty hard, you can read more if you really want to: https://github.com/shaunlebron/parinfer/issues/98
@shaunlebron: By the way, Planck and Replete with Parinfer will likely both be released within a week, so we may get good real-world feedback.
@mfikes: cool, thanks. I’ll ping you when this new enter
stuff is implemented
thanks @shaunlebron for the explanation. in the process of adding parinfer i removed the code which was providing me auto-indentation previously. i can try combining them, but my fear is that they will clash
nightcode’s current auto-indentation code makes the inner functions indent with two spaces, so hitting enter at ([arg1 arg2]|)
leads to ([arg1 arg2]\n |)
but with parinfer’s indent mode this would mean anything i type at that point would be added to my arg list rather than the body of the function
@sekao: good point
clojure style guide recommends against that. bozhidar batsov was adamant about that convention stemming from a clojure-mode bug in emacs
source: https://github.com/bbatsov/clojure-style-guide/pull/95#issuecomment-148742659
I ran Paren Mode on many core clojure libraries to pickup on things that would be in conflict with Indent Mode
the only thing Indent Mode is in conflict with is the multi-arity convention you mentioned
@sekao, so if you modify nightcode's auto-indentation to not indent multi-arity bodies, auto-indent would be safe to use with Indent Mode
with the exception of the special line-splitting case I mentioned above, which I should have fixed next week
interesting, if that’s the only one then i’ll look into combining them. it’s already usable enough that i’m editing nightcode with the latest master build of nightcode using parinfer 😃
nice! cant wait to play with it