I’m still interested in feedback on the best way to select Clojure forms. Do people like CCW-style selection left/right extension? Something like mark-sexp? Move left/right while selecting?
IIRC the expanding selection was restricted to just the form? I would find it really useful if it then expanded to outer forms, so if cursor is between the ‘ll' (defn something  (println “hello”)) I could expand once to select “hello”, expand again to select (println “hello”), expand again to select (defn….)
(is that what you are asking?)
At the moment I tend to move to front of the form and Cntr-Alt-delete
You can do what you want there with repeated alt-up
That will select hello, “hello”, (println “hello”), (defn …) etc etc
The tricky bit is selecting two (or more) forms which are siblings
Emacs has mark-sexp, which marks the next sexp, and repeated invocations continues marking subsequent forms
CCW has expand selection left/right
A few people have asked for a version of move left/right which marks as you go, or if the movement commands could automatically expand/contract the selection.
I can’t see how I would use the left/right as that would surely mean your selection is unbalanced?
No - say you have:
(defn test  |(some-form) (some-other-form) (yet-another-form))
Where | is the caret
If you alt-up there, you’ll select (some-form). mark-sexp would select (some-form), then if you do it again you’d have (some-form)\n(some-other-form) selected, and so on.
So it’s for selecting multiple sibling forms. It’s something I want to do a surprising amount of the time. But all the options have a tricky balance between simplicity, flexibility, and adding a ton of commands (which all need keybindings etc)
ah OK, so you start outside the form. Yeah, I need that. The closest I have come is shift and down to highlight the lines and then shift+alt+left/right to end the selection. Muscle memory makes it not too painful
Yeah, it’s still pretty horrible, though - that’s what I end up doing too.
CCW style marking doesn’t require you to be outside the form - you could be inside (some-form), alt-up a couple of times to select it, then extend selection right.
I see. Yes from me then.
Not so fast. Note that you’ll need probably 4 new commands - extend/shrink left/right.
And keys for them.
oh I see. So the ‘native’ IntelliJ selection isn’t sexp aware. Right.
Well, it is because Cursive extends it. But it’s purely hierarchical, up/down the sexp tree, not laterally into siblings.
I am reacting here, rather than thinking deeply, but couldn’t you make the behaviour you described the default behaviour in Clojure files? When would you not want the behaviour you described when selecting?
The problem is that the expand/shrink selection is baked into IntelliJ. I use it all the time in Java, for example.
Anyone used to IntelliJ will go wild if that gets broken.
I can reasonably trivially add extend left/right, but then you also probably need shrink left/right in case you accidentally go too far.
And then you need 4 new keybindings.
Presumably in very convenient locations.
And not ‘wild’ in a good way I guess. It has been so long since I did anything in IntelliJ other than Clojure I forgot IntelliJ is used for other things 😉
In CCW, I guess Eclipse doesn’t have the expand/contract baked in, so there up is expand selection, left and right extend left and right, and down is “undo what I last did”.
Which would be really nice but I can’t do it.
Yeah, a few people also use it for other stuff :simple_smile:
and you can’t use this as a reason to get them to drop Java and pick up Clojure….. yeah OK, maybe not 😉
Additionally “undo what I last did” in IntelliJ is tricky because selection is complicated - multiple cursors, column selection mode, ugh
Yeah - undo-tree in emacs has spoilt all editors for me on that front. IntelliJ’s history is pretty close
Yeah, something like undo-tree would be really nice.
Although this is a different kind of undo that only works on selections, since in IntelliJ at least undo doesn’t undo selection actions.
Anyway, I’m just moaning now - I’m going to try a few things and see how they work.
well for me, I could live in selection behaving one way in a Clojure file and a different way in a non-Clojure file as long as the semantics were the same.
I am sure what you come up with will be excellent based on previous experience Colin - I really don’t think I/we can say thank you enough.
Here’s hoping - thanks!
Paredit is much nicer in the next build.