Clojurians
#cljsfiddle
<
2016-03-08
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

escherize05:03:16

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?

chrisoakman05:03:08

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

chrisoakman05:03:48

Is that like a language-pack setting?

escherize05:03:34

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

escherize05:03:03

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

escherize05:03:12

I'll remove it and find out :simple_smile:

escherize05:03:10

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

chrisoakman05:03:05

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

chrisoakman05:03:19

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

chrisoakman05:03:47

less verbose :simple_smile:

escherize05:03:12

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.

shaunlebron06:03:02

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

shaunlebron06:03:54

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

shaunlebron06:03:23

regardless it’s what we have...

shaunlebron06:03:41

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

escherize06:03:10

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

shaunlebron06:03:15

cm.setOption(“mode”, …)

escherize06:03:15

I'll give it a go :]

escherize06:03:35

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

shaunlebron06:03:12

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

shaunlebron06:03:04

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

shaunlebron07:03:48

(-> @state editor-key :cm)

escherize07:03:15

:+1::skin-tone-3:

shaunlebron07:03:47

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

shaunlebron07:03:01

great stuff man!

escherize07:03:29

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

richiardiandrea15:03:02

@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?

shaunlebron17:03:57

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

shaunlebron17:03:19

all the parinfer events are manually attached to the cm events

shaunlebron17:03:55

parinfer is not a proper codemirror mode