Fork me on GitHub
#parinfer
<
2015-12-09
>
shaunlebron01:12:24

my god, that’s cool

shaunlebron01:12:37

i was just reading your email

shaunlebron01:12:07

it’s been a while since I’ve seen cljs-devtools, looks like it’s come really far since then

darwin01:12:32

I just discovered this channel after sending the email

darwin01:12:42

we can communicate here in the open

darwin01:12:23

I just want to add few bits into devtools, to improve cljs experience a bit more with chrome

darwin01:12:54

nothing big, just few tweaks here and there, for example using custom formatters for inline values in source code view

shaunlebron01:12:12

yeah, that’s a big deal

shaunlebron01:12:33

the local scope view is especially nice

darwin01:12:27

yeah, speaking about local scope, I will sort local scope view to put nice variables at the top, and macro generated below

darwin01:12:43

you know, all the garbage with underscores and dollars

shaunlebron01:12:03

yeah, that’s a good idea, I guess they all end with #

darwin01:12:26

not really, pounds are cljs names, they get mangled into underscores

darwin01:12:30

double underscores

darwin01:12:14

there will have to be some heuristics, but is is proabably doable

darwin01:12:36

things with underscore+number are also candidates

darwin01:12:57

this will be just sorting and maybe applying some opacity, so no big deal

darwin01:12:20

there can be some mistakes

darwin01:12:04

would be nice to get auto-completions from REPL, but that looks like a bigger project

darwin01:12:26

figwheel does not offer this in its REPL

darwin01:12:34

for this proof-of-concept I want to just talk to figwheel, I don’t want to invest time into making it more general (nREPL compatible)

shaunlebron01:12:25

does evaluating an expression in figwheel’s repl usually result in it being logged to chrome’s devconsole?

shaunlebron01:12:43

or is this leveraging something new in figwheel

shaunlebron01:12:39

i think I’m missing something here with how the two are interacting

darwin01:12:45

normal scenario: you type someting into REPL, figwheel wraps it into (pr-str (your-code)), figwheel compiles it from cljs into js,, then sends it into chrome, there it gets exectuted as javascript, result is string, which gets delivered back to figwheel repl where it gets printed

darwin01:12:19

this plugin, removes pr-str wrapping and prints the javascript result into devtools console as well

darwin01:12:47

cljs-devtools kicks in and shows cljs-related results in a friendly way

darwin01:12:02

so this is just one way REPL -> devtools, with my devtools fork, I will close the loop: you type something into devtools console, it gets sent to figwheel server, which treats it as it was entered in REPL directly, rest it normal scenario

darwin01:12:08

parinfer will help with that devtools clojure prompt, so great, like in planck

shaunlebron01:12:34

ok, I think I understand now. figwheel is the compiler, and cljs-devtools is adding a normal view over its values

shaunlebron01:12:17

and soon we won’t even have to look at figwheel’s terminal, since you’ll allow normal input straight from the devconsole

darwin01:12:43

and we can integrate more stuff into that devtools window

shaunlebron01:12:49

so the repl experience will be what JS developers already do in the console

darwin01:12:55

there can be test runner, there can be figwheel hud, or even cuttle

shaunlebron01:12:10

yeah, this is going to be a big UX win for cljs

darwin01:12:58

could be really good improvement

shaunlebron01:12:38

wow, cljs test results, figwheel hud, and build options straight from chrome devtools

darwin01:12:42

I want it for my own dev workflow, iTerm2 + figwheel repl is not bad, but I’m staring on devtools most of the time

darwin01:12:50

so why not having it integrated together

shaunlebron01:12:51

i don’t know much about react and redux devtools, but I think they’re tightly integrated like that

darwin01:12:18

and nice part is that most of this can be implemented in cljs, it is not a big problem to combine devtools javascript code and our custom cljs pieces

darwin01:12:54

yes, react devtools is actually a devtools extension, not a fork, they use extension points provided by devtools guys

darwin01:12:08

mostly adding new panels into the UI

shaunlebron01:12:33

so you’re forking

darwin01:12:39

recently I realized I don’t want to wait for them

darwin02:12:32

I can package whole thing as a chrome extension (which will include my fork), so people can have easy path for consuming it

darwin02:12:05

but you could also run a local server with the fork, devtools are just a SPA, communicating with chrome using websockets

darwin02:12:48

the only drawback will be keeping the fork up-to-date with upstream changes, and fixing conflictsw

darwin02:12:11

I hope it won’t be so bad

shaunlebron02:12:29

do you have a fork on github?

shaunlebron02:12:41

kinda wanna see what changes require the fork

darwin02:12:08

will give you access, it is just a private repo at this point

shaunlebron02:12:01

I’m kind of in awe that you integrated the codemirror stuff for parinfer straight into the console, with all the highlighting stuff

darwin02:12:39

@shaunlebron: it wasn’t hard, devtools use codemirror for source code view already, and codemirror is beautifully designed

darwin02:12:53

and parinfer as well simple_smile

shaunlebron02:12:03

you know I thought that about codemirror

shaunlebron02:12:12

idk about parinfer… haha

shaunlebron02:12:35

I’ve never seen beautiful JS before reading codemirror’s source

shaunlebron02:12:53

but I did have to modify codemirror in one spot, with the +indenthack and some other places to allow visual selections to not disappear when losing focus (just for playback of the demos)

darwin02:12:15

Marijn is/was a scheme guy simple_smile

darwin02:12:00

it took me some time to realize that bracket matching has some parinfer-related tweaks

shaunlebron02:12:07

anyway, I think all the edits have to do with playback features that you won’t care about

darwin02:12:19

you should pull that file out of codemirror directory, to make it more obvious

shaunlebron02:12:19

yeah, that too

shaunlebron02:12:04

yeah, not a bad idea, I think I might’ve thought it had to be in that directory

darwin02:12:41

ah, ok, I’m not sure

shaunlebron02:12:33

yeah, I never really intended for the codemirror stuff to be used external to this site demo since it was getting hacky in places

shaunlebron02:12:43

hence my surprise

darwin02:12:23

sure, I understand, it was easier than expected, maybe I will bend it to my needs in the future, but it was a good starting point

darwin02:12:42

btw. one discovery, "Shift-Tab" “indentLess” can be put into extraKeys

darwin02:12:09

you don’t have to alter global default keyMap

darwin02:12:25

but this is not really issue for your use case

darwin02:12:01

I should isolate my CodeMirror interactions from devtools guys, we share one js/CodeMirror

darwin02:12:59

maybe later we can extract independent parinfer+codemirror code, for other people to use

shaunlebron02:12:27

I think someone was working on a proper codemirror addon

darwin02:12:41

not a big priority, this all is just proof-of-concept code, it can be ugly

darwin02:12:10

I mean the parinfer integration on my side

shaunlebron02:12:31

oh, @hmadelaine said he might look at creating a proper codemirror addon, so you might be able to use that

shaunlebron02:12:05

alright, I gotta head out for the night

shaunlebron02:12:34

but yeah, great stuff, excited to see cljs tooling move into the devtools space

shaunlebron02:12:01

like i said, it’ll be a huge ux win to have a default-feel for cljs in browser dev

darwin02:12:09

cool, thanks for all your hard work on parinfer and other projects

darwin02:12:13

talk later

shaunlebron02:12:24

you too man, later

dongcarl05:12:20

@shaunlebron: when you have time, can you explain why you’d call `(select-keys state [:x-pos :ch])’?

dongcarl05:12:44

state doesn’t have keys :x-pos and :ch

shaunlebron05:12:31

@dongcarl the whole indent mode “state” is passed to push-char as the first argument

dongcarl05:12:26

which is then passed to push-char*

shaunlebron05:12:48

right, so x-pos is the column number, and ch is the current character we are on

shaunlebron05:12:00

these are set at process-char

dongcarl05:12:51

okay, so you added things onto the map that was originally initial-state?

shaunlebron05:12:55

select-keys just creates a new map from the given keys, a subset

shaunlebron05:12:37

yes, the process functions assoc the given state with new information

dongcarl05:12:59

okay so let me get this right

dongcarl06:12:38

there are :x-pos :ch :indent-delta keys in the large state

dongcarl06:12:02

but those keys are also in each element of the :stack key in the large state?

dongcarl06:12:30

exists, I mean, values aren’t the same obviously

dongcarl06:12:58

and the :x-pos :ch :indent-delta keys were added to the large state in process functions

shaunlebron06:12:05

so the large state has a lot of things, from initial-state

shaunlebron06:12:29

the stack needs to pull information from the current character to track them

shaunlebron06:12:55

so pushing a character involves pushing some info about that character (`x-pos`, ch and sometimes indent-delta)

dongcarl06:12:34

okay. Was what I said above correct though? Are there misconceptions?

dongcarl06:12:55

Awesome. Thanks for the help simple_smile

dongcarl06:12:17

shaunlebron: also I’ll have the repo set up sometime so you can keep your list updated

shaunlebron06:12:11

cool, feel free to call me on goog hangout for questions like this

shaunlebron06:12:39

though here on slack is fine too for public record

shaunlebron06:12:13

i usually find communication on these kinds of things easier through voice though

dongcarl06:12:47

shaunlebron: one more quick question

dongcarl06:12:55

is conj the same as merge?

shaunlebron06:12:15

it can be, that’s kind of confusing

shaunlebron06:12:30

conj means to add an element to a collection

shaunlebron06:12:39

merge merges two collections

shaunlebron06:12:54

in what context

shaunlebron06:12:47

[ {} {} {} {} ]

shaunlebron06:12:57

so the stack is just a vector of maps

dongcarl06:12:40

okay and it puts it at the front?

shaunlebron06:12:02

conj chooses the operation most efficient for the collection type

shaunlebron06:12:07

for vectors it is added to the end

dongcarl06:12:19

okay does it matter for our case if it’s at the front or the back?

shaunlebron06:12:48

the stack is a vector, so conj adds to the end, and pops from the end

shaunlebron06:12:07

(conj [a] b) => [a b]

shaunlebron06:12:19

(pop [a b]) => [a]

dongcarl06:12:43

I thought you said it pops from the end?

shaunlebron06:12:07

does the example contradict that

shaunlebron06:12:24

(peek [a b]) => b

shaunlebron06:12:40

yeah, pop returns the new stack

dongcarl06:12:00

awesome thanks!

shaunlebron06:12:19

yeah, I hope the push-char* makes sense

shaunlebron06:12:46

it’s reacting to different characters in different ways, hence the different defmethods

dongcarl06:12:59

yeah clojure provides some powerful syntax

shaunlebron06:12:01

anything returned from the push-char* is merged back into the state

shaunlebron06:12:18

that’s what push-char is essentially doing, without the asterisk

dongcarl06:12:40

awesome awesome

shaunlebron06:12:32

thanks again for playing with this simple_smile

shaunlebron06:12:44

good luck on finals!

hmadelaine08:12:32

Hi @shaunlebron @darwin ! I have read you conversation, it was very interesting. I begun to isolate code-mirror related code from Parinfer-site. There is two roadblocks at the moment : First, the codeMirror patch for +identhack. @shaunlebron, do you think it could be merged into CodeMirror.js directly ? The second is the question to extract the VCR from the editor. I have to dig a little deeper to better understand Parinfer and CodeMirror.

shaunlebron17:12:24

@hmadelaine the +indenthack may be an unnecessary workaround

hmadelaine17:12:58

@shaunlebron: OK, it should simplify the dependency on codemirror simple_smile

shaunlebron17:12:11

sorry, I’m having to look back at it

shaunlebron17:12:26

it’s only necessary for paren-mode

shaunlebron17:12:51

so if you type character, it preserves the indentation of the line below if the typed character shifts an open-paren after it

shaunlebron17:12:15

(foo (bar
       baz))

shaunlebron17:12:28

(food (bar
        baz))

shaunlebron17:12:51

so inserting the d will cause the second line to move forward one space to preserve the original relative indentation

shaunlebron17:12:51

but yeah, this is the use-case, but I can look at how codemirror batches changes, it drove me crazy for a little while. there may be another way

hmadelaine17:12:19

@shaunlebron: thanks for the explanation

shaunlebron17:12:37

the vcr could be completely removed right?

hmadelaine17:12:04

Yes at first look

shaunlebron17:12:04

we only care about the editing, not recording

hmadelaine17:12:41

@shaunlebron: I will do a first try tomorrow morning simple_smile

shaunlebron17:12:00

I think the only thing in editor.cljs that needs to be preserved is on-change and on-cursor-activity

hmadelaine17:12:30

@shaunlebron: you do not edit this code on Parinfer-site ?

shaunlebron17:12:14

sorry I don’t understand the question

hmadelaine17:12:30

@shaunlebron: I will put a first draft on github. What would be a great name ? The hardest part simple_smile

shaunlebron17:12:17

codemirror-parinfer probably

shaunlebron17:12:33

judging from the existing addon names

darwin23:12:05

everything was entered from devtools (with parinfer assitance), commands are simply echoed into figwheel REPL, @shaunlebron ^