cljsfiddle

escherize 2016-03-08T05:42:16.000046Z

I've finished installing parinfer.. It was tricky. I'm stuck however when it comes to being able to toggle between parinfer-clojure and clojure modes with CodeMirror. @chrisoakman @shaunlebron Do you guys have any pointers?

chrisoakman 2016-03-08T05:45:08.000047Z

Shaun would probably know; I haven't worked with CodeMirror

chrisoakman 2016-03-08T05:45:48.000048Z

Is that like a language-pack setting?

escherize 2016-03-08T05:49:34.000049Z

I'm not sure what a language-pack setting is, however those modes are codemirror options. When reloading the component that hosts the textarea I'm using to create the codemirror instance, the codemirror instantiation code doesn't run. I think it's because of this: https://gitlab.com/escherize/cljsfiddle/blob/codemirror-with-parinfer/src/cljs/cljsfiddle/parinfer_codemirror/example.cljs#L44

escherize 2016-03-08T05:50:03.000052Z

I'm curious about why it matters if the state is there or not.

escherize 2016-03-08T05:50:12.000053Z

I'll remove it and find out :simple_smile:

escherize 2016-03-08T05:51:10.000054Z

oh - it gets out of sync with its backing atom..

chrisoakman 2016-03-08T05:52:05.000055Z

small trick: I would replace (js/document.getElementById element-id) with (by-id element-id)

chrisoakman 2016-03-08T05:52:19.000056Z

and just create a by-id wrapper around the native DOM call

chrisoakman 2016-03-08T05:53:47.000057Z

less verbose :simple_smile:

escherize 2016-03-08T05:56:12.000058Z

sounds good. Untill I can toggle parinfer on/off (some of the repls do... I can't figure it out though), I'll keep the codemirror instance with clojure mode.

shaunlebron 2016-03-08T06:51:02.000059Z

hmm, I didn’t realize that parinfer-codemirror was just using code from the website

shaunlebron 2016-03-08T06:52:54.000060Z

I was hoping it was a proper codemirror plugin instead of the wrapper that I used to tightly control the state just for animations

shaunlebron 2016-03-08T06:55:23.000061Z

regardless it’s what we have...

shaunlebron 2016-03-08T06:55:41.000062Z

@escherize: use cm.setOption to change the mode: http://codemirror.net/doc/manual.html#setOption

escherize 2016-03-08T06:56:10.000063Z

hey @shaunlebron - oh wow is that really all it takes?

shaunlebron 2016-03-08T06:56:15.000064Z

cm.setOption(“mode”, …)

shaunlebron 2016-03-08T06:56:23.000065Z

I think so

escherize 2016-03-08T06:57:15.000066Z

I'll give it a go :]

escherize 2016-03-08T06:57:35.000067Z

Is there a good way to grab the cm instance from anywhere?

shaunlebron 2016-03-08T06:58:12.000068Z

I always kept a reference to it in a lookup atom by id

shaunlebron 2016-03-08T06:59:04.000069Z

but there’s only one in cljsfiddle, so just save the cm instance somewhere when creating it

shaunlebron 2016-03-08T07:01:48.000073Z

(-> @state editor-key :cm)

escherize 2016-03-08T07:02:15.000074Z

👍:skin-tone-3:

shaunlebron 2016-03-08T07:02:47.000075Z

I’ll look at this more tomorrow. gotta go to bed

shaunlebron 2016-03-08T07:03:01.000076Z

great stuff man!

escherize 2016-03-08T07:06:29.000077Z

Thanks - I've noticed that changing the mode didn't actually change the parinfer-y behavior of the editor, though. We'll catchup on it tomorrow

richiardiandrea 2016-03-08T15:42:02.000078Z

@escherize we have a code mirror + re-frame lib coming out soon but still in the making, hopefully next week we will publish it ok?

shaunlebron 2016-03-08T17:31:57.000079Z

parinfer-clojure is just a modification of clojure that allows us to highlight close-parens at the end of a line differently

shaunlebron 2016-03-08T17:32:19.000080Z

all the parinfer events are manually attached to the cm events

shaunlebron 2016-03-08T17:32:55.000081Z

parinfer is not a proper codemirror mode