Discussion about all editors used for Clojure/ClojureScript
colin.yates 2015-07-17T08:47:01.001616Z

thanks @cfleming

cfleming 2015-07-17T08:48:37.001617Z

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?

colin.yates 2015-07-17T08:50:35.001618Z

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….)

colin.yates 2015-07-17T08:50:40.001619Z

(is that what you are asking?)

colin.yates 2015-07-17T08:51:29.001620Z

At the moment I tend to move to front of the form and Cntr-Alt-delete

cfleming 2015-07-17T08:55:11.001621Z

You can do what you want there with repeated alt-up

cfleming 2015-07-17T08:55:42.001622Z

That will select hello, “hello”, (println “hello”), (defn …) etc etc

cfleming 2015-07-17T08:56:27.001623Z

The tricky bit is selecting two (or more) forms which are siblings

cfleming 2015-07-17T08:57:02.001624Z

Emacs has mark-sexp, which marks the next sexp, and repeated invocations continues marking subsequent forms

cfleming 2015-07-17T08:57:18.001625Z

CCW has expand selection left/right

cfleming 2015-07-17T08:57:59.001626Z

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.

colin.yates 2015-07-17T08:58:31.001627Z


colin.yates 2015-07-17T08:58:48.001628Z

I can’t see how I would use the left/right as that would surely mean your selection is unbalanced?

cfleming 2015-07-17T09:00:28.001629Z

No - say you have:

(defn test []

cfleming 2015-07-17T09:00:54.001631Z

Where | is the caret

cfleming 2015-07-17T09:01:52.001632Z

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.

cfleming 2015-07-17T09:03:08.001633Z

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)

colin.yates 2015-07-17T09:05:11.001634Z

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

cfleming 2015-07-17T09:07:46.001635Z

Yeah, it’s still pretty horrible, though - that’s what I end up doing too.

cfleming 2015-07-17T09:08:37.001636Z

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.

colin.yates 2015-07-17T09:09:11.001637Z

I see. Yes from me then.

cfleming 2015-07-17T09:09:46.001638Z

Not so fast. Note that you’ll need probably 4 new commands - extend/shrink left/right.

cfleming 2015-07-17T09:09:53.001639Z

And keys for them.

colin.yates 2015-07-17T09:10:34.001640Z

oh I see. So the ‘native’ IntelliJ selection isn’t sexp aware. Right.

cfleming 2015-07-17T09:11:06.001641Z

Well, it is because Cursive extends it. But it’s purely hierarchical, up/down the sexp tree, not laterally into siblings.

colin.yates 2015-07-17T09:13:04.001642Z

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?

cfleming 2015-07-17T09:15:30.001643Z

The problem is that the expand/shrink selection is baked into IntelliJ. I use it all the time in Java, for example.

cfleming 2015-07-17T09:15:46.001644Z

Anyone used to IntelliJ will go wild if that gets broken.

cfleming 2015-07-17T09:16:57.001645Z

I can reasonably trivially add extend left/right, but then you also probably need shrink left/right in case you accidentally go too far.

cfleming 2015-07-17T09:17:07.001646Z

And then you need 4 new keybindings.

cfleming 2015-07-17T09:17:22.001647Z

Presumably in very convenient locations.

colin.yates 2015-07-17T09:17:59.001648Z

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 😉

cfleming 2015-07-17T09:18:19.001649Z

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”.

cfleming 2015-07-17T09:18:30.001650Z

Which would be really nice but I can’t do it.

cfleming 2015-07-17T09:18:54.001651Z

Yeah, a few people also use it for other stuff :simple_smile:

colin.yates 2015-07-17T09:19:21.001652Z

and you can’t use this as a reason to get them to drop Java and pick up Clojure….. yeah OK, maybe not 😉

cfleming 2015-07-17T09:19:55.001654Z

Additionally “undo what I last did” in IntelliJ is tricky because selection is complicated - multiple cursors, column selection mode, ugh

colin.yates 2015-07-17T09:21:02.001655Z

Yeah - undo-tree in emacs has spoilt all editors for me on that front. IntelliJ’s history is pretty close

cfleming 2015-07-17T09:21:24.001656Z

Yeah, something like undo-tree would be really nice.

cfleming 2015-07-17T09:21:53.001657Z

Although this is a different kind of undo that only works on selections, since in IntelliJ at least undo doesn’t undo selection actions.

cfleming 2015-07-17T09:22:24.001658Z

Anyway, I’m just moaning now - I’m going to try a few things and see how they work.

colin.yates 2015-07-17T09:23:11.001659Z

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.

colin.yates 2015-07-17T09:23:46.001660Z

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.

cfleming 2015-07-17T09:24:05.001661Z

Here’s hoping - thanks!

cfleming 2015-07-17T09:24:17.001662Z

Paredit is much nicer in the next build.