A few more suggestions
While I'm waiting for the next release of the clojure plugin I thought I'd chip in with a few more feature suggestions.
Suggestion 1:
Don't switch focus to the REPL when evaluting the current selection. I usually want to stay in the editor window after I evaluate a piece of code.
Suggestion 2:
Provide a easy way to evaluate the top-level expression. Perhaps when you have nothing selected and press Alt-S it could auto select the top level expression.
Suggestion 3:
Emacs has some nice extensions that lets you directly manipulate s-expressions. That'd be very handy.
Suggestion 4:
Ctrl-w should work with clojure tokens rules. For example take the variable my-clojure-symbol. If I pressed ctrl-w while positioned on clojure part it currently doesn't select the entire symbol.
请先登录再写评论。
I've got a build of the plugin working on Maia-IU-90.122 that I've altered to include your first suggestion (it bugged me as well!). I've also added an action to evaluate the last s-exp (i.e. the last s-exp behind the caret) as that seemed more natural than having to highlight the s-exp.
I'm going to try to get these changes handed over to the JetBrains guys but failing that I can post a build of the plugin somewhere for you to download.
As for #2 what's wrong with doing select-all followed by run-selected-text? it's only an additional key-chord.
As for #3 if you're thinking of paredit.el I'm looking into adding some of the structural editing commands at least (e.g. slurp & barf).
Cheers,
Ian.
Ian> As for #2 what's wrong with doing select-all followed by run-selected-text? it's only an additional key-chord.
That's not exactly what I was after. I don't want to select the entire buffer but rather just the top level expression.
For example take the following script:
(println "hello")
(println (+ 1 2))
(println "world)
if my carot was positioned inside the (+ 1 2) expression I would like a keybinding to evaluate the (println (+ 1 2)) since it's a top level form. Although I imagine something that evaluated just the (+ 1 2) part would be useful as well. At the moment I can repeat ctrl-w until I get the selection I want or manually select the region. A single keystroke would make things easier.
Ian> As for #3 if you're thinking of paredit.el I'm looking into adding some of the structural editing commands at least (e.g. slurp & barf).
Yes that's basically what I'm thinking about. Some of those sorts of changes could be very useful.
Ah, got you; consider it done ;-)
What does ctrl-w do? I must have a different keymap to you as that's bound to "Close Active Editor" for me! How about an ExpandSelection that works 1 form at a time? So if I have (the red bar is the caret position)
then running the action once would get me to
and running it again would get me to
and so on. Probably bound to alt-meta-up by default but open to suggestions.
ctrl-w on windows is bound to the action "Expand Selection" which does what you're suggesting: expands the selection structurally.
Hmm, odd; I can't find that command in the key map (using the 9.0 β on Mac OS X). Well, regardless of that I have a working version of the command locally, my only concern at this point is that it would clash with the existing command that you are talking about so you would have a different key chord based on whether you are in a Clojure editor or not (although it could be argued that the structural editing version does something different and so should use a different chord).
On the mac in the default keymap this is bound to Cmd-W by default. Best editing command ever. You definitely want to use the built-in since it will then act in a standard way. The Clojure plugin has code to support it, I believe the class was called ClojureSelectionExpander or something similar (based on my recollection of the code from some time ago).
Cheers,
Colin
Ah, thanks for the pointer! The action is actually the misleadingly named "Select Word at Caret" ;-) and yes, there does seem to be some support for it in La Clojure already. I'd agree with Glen in that it should be more Lisp-y though, I'll give it some thought and see what I can come up with.
Yeah, I'm actually developing a Scheme mode at the moment and I'm thinking about changing the semantics for this op a little too, but I'll have to try it to see if I like it. Currently if I have a let expression with several expressions in the body I don't always want to select the whole let, I'd probably like an intermediate step which selects all the body expressions first. Will need a little experimentation though.
My thinking is that if the caret or selection is inside an atom (symbol, literal, keyword) then it should expand to select the whole literal, if it is on a braced form (and for the purposes of this discussion I'm counting literal strings a braced forms) then it should expand to the content of the form, with the next expansion including the braces. So
and so on. Although it may be nice to have some special rules for certain forms such as your let example, that may be something that can be generalised as all of the examples that I can think of seem to be progn style forms (let, defn, defmacro, do).
Hmm, I'm not sure about that - when would you want to select the contents of a list, without selecting the list itself? I think I'd probably rather use fewer keystrokes to select the list forms, although it would be easy to make that an option.