Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

One keystroke cljs eval #29

Merged
merged 7 commits into from
Sep 18, 2015
Merged

One keystroke cljs eval #29

merged 7 commits into from
Sep 18, 2015

Conversation

cldwalker
Copy link
Member

This is an attempt to make a clojurescript eval that just works for your project, much like clojure's eval and inspired by realizations in #8. Try it out:

EDIT: Not working with new clojurescript versions until #52 lands:

  • Clone the Clojure plugin and checkout this branch.
  • lein new mies-om om-test
  • cd om-test && lein cljsbuild once
  • Open LightTable and eval a line e.g. (enable-console-print!)
  • An internal browser auto-opens and the line is evaled. You now have a cljs repl to your project (not LT's)!

The client auto-magically works by looking for a number of common places for index.html and opening it. We can make this a configurable behavior as well as disabling this feature entirely for power users. We could also make opening to an external browser a configurable behavior.

As for implementation, I resorted to a new connection as we may want to open an internal or external browser. We could reuse the existing internal browser connection and same for the external one. However, that will require changing their :connects to kick off behaviorw and this feature will block until the next release. As for placement of the :connect call, I tried placing it in :exec.cljs behavior to less success. Current placement seems reasonable. If we don't like the tag check, we could change :create to point to a trigger e.g. :create-eval-connection

@LightTable/committers Would love to get feedback. I'm also going to open this up to the community on a mailing list thread.

…ser input

By assuming common defaults for html files, cljs eval can be
automated. If none of the default paths are found, it reverts to
existing behavior.
* default-cljs-client could be configurable with a behavior
* Could add a behavior to disable this feature for more advanced users
@cldwalker
Copy link
Member Author

Once #52 lands we'll have modern clojurescript eval and I'd like to make this a part of that release. @rundis @tonsky @kenny-evitt @stephenbrady Any thoughts on or objections to this?

(defn find-default-html-file
"Searches browser-paths for first relative path to exist and returns it."
[ed]
(let [project-dir (files/parent (files/walk-up-find (get-in @ed [:info :path]) "project.clj"))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all great. A little love for build.boot would be a nice touch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed but boot only works for browser external connections and this currently only supports browser (internal) connections. I'll add boot if we ever add browser external support for 'ClojureScript Browser'

@kenny-evitt
Copy link

@cldwalker No objections – only happy thoughts!

@tonsky
Copy link
Contributor

tonsky commented Sep 16, 2015

Not sure why I’m in that list, but obviously I don’t mind :)

@cldwalker
Copy link
Member Author

Thanks for the feedback all. I've made both the default cljs client and the relative paths/urls to look for configurable via behaviors. I'll be releasing later today

cldwalker added a commit that referenced this pull request Sep 18, 2015
@cldwalker cldwalker merged commit 21c230d into master Sep 18, 2015
@rundis
Copy link
Contributor

rundis commented Sep 18, 2015

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants