shdqcdsn / counterclockwise

Automatically exported from code.google.com/p/counterclockwise
0 stars 0 forks source link

Support for custom shortcuts that run clojure code #559

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In vim (and emacs, I'm sure) there's an eval function so I can easily script 
new actions. For examples, I can map the sequence 'c p t' to run 
(clojure.core/run-tests) in the current ns. It would be nice to have this 
facility in CCW.

Short of supporting arbitrary scripting, one simple approach is a dialog that 
lets you enter a key sequence and a "template" for the clojure code to execute. 
For example, require/reload-all: (clojure.core/require '${ns} :reload-all).  Or 
something like that.

Original issue reported on code.google.com by dave...@gmail.com on 28 Mar 2013 at 6:46

GoogleCodeExporter commented 9 years ago
It seems from the example you're providing that what you want is templates in 
the REPL input area to ease writing common code, is that it ?
I mean, this would then only work in the REPL input area (no additional 
dialog), be added to the command line history.

We could have a different set of templates for Clojure Editors and for Clojure 
REPL Input areas.

If I'm misunderstanding, please feel free to expand the set of use case 
examples.

Original comment by laurent....@gmail.com on 28 Mar 2013 at 9:39

GoogleCodeExporter commented 9 years ago
My main use case is: I'm editing code in a test namespace and I want to run the 
tests without having to manually switch to the repl and execute 
(clojure.test/run-tests). A more general framework for adding shortcuts like 
this would be nice though. The key thing is for common tasks like running 
tests, I shouldn't have to leave the editor or use the mouse at all.

The example above is a little contrived, but I wanted something that would show 
using the ${ns} template var.

Original comment by dave...@gmail.com on 28 Mar 2013 at 11:33

GoogleCodeExporter commented 9 years ago
I also would like to provide a general way for users to extend Counterclockwise.
Either because they have something really specific to their environment.
Or else to help share / sandbox new features (I could well use it myself, 
throwing new features in the wild by means of Gists, etc.).

For instance, there could be a way to register for editions, file saves, 
getting the current repl, registering new commands, etc.

For instance, you could then be able to add a custom listener for file saves 
and react to them by automatically launching (clojure.core/run-tests) : 

(declare run-tests)

(eclipse/register-editor-save-editors ;; whatever would make sense, didn't 
think about all this that much
  (fn [saved-files context] 
    (when-let  [namespaces (seq (filter #(.endsWith (.getName %)  ".clj") saved-files))]
      (run-tests namespaces (:repl context))))

(defn run-tests [namespaces repl]
  (doseq [n namespaces]
    (nrepl/eval repl `(clojure.core/run-tests ~n))))

Something like that

Original comment by laurent....@gmail.com on 3 Apr 2013 at 1:36

GoogleCodeExporter commented 9 years ago

Original comment by laurent....@gmail.com on 18 Nov 2014 at 9:25