Fork me on GitHub
#parinfer
<
2018-02-09
>
cfleming02:02:03

@shaunlebron What is the best place to point people to when they ask what smart mode is?

cfleming02:02:23

The home page is still mostly about the dual modes.

cfleming02:02:44

Is there a summary documented anywhere public?

shaunlebron02:02:04

i was just about to record a quick video summary

shaunlebron02:02:16

but I wanted to demonstrate it in cursive

cfleming02:02:23

That would be great, a few people have asked about it.

shaunlebron02:02:29

but it doesn’t work here yet

cfleming02:02:38

In Cursive?

shaunlebron02:02:01

i probably just got the wrong version? intellij versions are confusing

cfleming02:02:00

That’s weird, it sounds like what @dave.dixon was reporting.

cfleming02:02:06

Versions look good, Cursive wouldn’t be enabled otherwise.

taylor02:02:43

I think I’m seeing the same behavior, seemed like it was working for a while then ☝️

cfleming02:02:03

I’m going to try with the repo that Dave said was failing for him

shaunlebron02:02:23

hmm, i’ll try a new clojure project then

cfleming02:02:11

@taylor So it was working for you, then it started failing on the same code, or you opened some new code and it didn’t work there?

taylor02:02:07

I was editing a large CLJS file and it was definitely (maybe?) working when I started, but then eventually it ran into some issues with unmatched parens/brackets that I had to manually fix, and after that it seemed to have stopped working?

cfleming02:02:36

Hmm, I wonder if the problem is that it’s not re-enabling after things break

taylor02:02:34

ok so if I open said file, it doesn’t work. If I work on a new/trivial file, it works

cfleming02:02:43

@shaunlebron Does it work if you’re editing the main code of that project rather than a test file?

shaunlebron02:02:58

that was what I first tried

cfleming02:02:08

@taylor Could you restart IntelliJ and see if it starts working on that same file?

shaunlebron02:02:10

I tried it in a new clojure project generated by intellij, and it worked in the core.clj file

taylor02:02:19

I just restarted before testing @cfleming

shaunlebron02:02:33

then I pasted a long clojurescript file into a new cljs namespace in the project, and it didn’t work

taylor02:02:47

oddly, it doesn’t seem to work on any CLJS files in my project at all now, not even a new blank one

taylor02:02:56

it works for CLJ files in same project

cfleming02:02:10

I wonder if CLJS is the problem for some reason, I’ll see if I can reproduce that.

cfleming02:02:17

I only really work on CLJ.

shaunlebron02:02:20

should we move this to #cursive?

cfleming02:02:27

Probably, yeah.

shaunlebron06:02:34

@cfleming can you review this 60 second video before I tweet it? https://www.youtube.com/watch?v=sl6d9M8jkvU

shaunlebron06:02:48

or anyone awake in this channel wanna look at it?

shaunlebron06:02:07

cool, thanks for checking

shaunlebron06:02:28

wanted to make sure i wasn’t leaving anything out important

shaunlebron06:02:42

@cfleming: looks good in cursive

shaunlebron06:02:26

only thing I found missing was the last part of the video—selecting a line to correct indentation in isolation

shaunlebron06:02:42

@cfleming: this is the line that just turns off smart mode when any line is selected: https://github.com/shaunlebron/parinfer/blob/3.12.0/lib/parinfer.js#L1543

cfleming07:02:24

@shaunlebron Ok, I’ll check that.

cfleming07:02:41

Cursive doesn’t currently do that, you’re right.

shaunlebron08:02:00

@doglooksgood i was thinking about the performance problem with your elisp port

shaunlebron08:02:46

180ms for 2k lines doesn’t sound too bad if we just process top-level forms only

shaunlebron08:02:26

atom-parinfer still doesn’t process the whole file, despite it being able to

shaunlebron08:02:12

it just assumes that lines starting with ( are top-level forms

shaunlebron08:02:32

could be a quick workaround for now

tianshu08:02:32

It currently does like this. so in the most cases, it's okay. but in a project.clj it may cause problem.

tianshu08:02:41

I'm wondering the dynamic module feature of emacs, that allow it load .so or .dll. If port parinfer.js to C, the performance should be good enough.

tianshu15:02:00

I believe that, parinfer should also work for XML or HTML

shaunlebron15:02:47

ha, I don’t see how that would work. thoughts?

tianshu15:02:34

I think they are same.

tianshu15:02:10

for XML and HTML, the close tag can be inferred by the indentation and open tag.

tianshu15:02:09

no theory to prove this.

tianshu15:02:20

I saw people who write JSX are painful for the close things. especially when they in some scopes like

xxxlist.map(x -> {
  <div>
    <h1>{x}</h1>
  </div>
})

shaunlebron15:02:38

maybe if html was written this way:

<div>
    <h1>{x}</h1></div>

tianshu15:02:54

no, they won't:joy:

shaunlebron15:02:12

I’m just saying if we want to extend parinfer to other syntaxes, the closing tags have to be consistently placed (according to my current understanding)

shaunlebron15:02:48

maybe not though, i can already look at that and see how the closing tags can be correctly placed based on indentation, according to how people want it

shaunlebron15:02:18

yeah, maybe you’re on to something

tianshu15:02:19

I just think the close tag in xml can be inferred, no saying that parinfer should extended to do this stuff. but if we can determine where we put the closers, for most of the languages, this is the only difference I think.

tianshu15:02:31

the truth is , for most of the language, the indentation and the code block is relevant.

shaunlebron15:02:24

we can mock out this idea by replacing <div> => ( and </div> => )

shaunlebron15:02:33

assume divs for all tags

shaunlebron15:02:11

so now:

<div>
  <h1>{x}
is equal to:
(
  ({x}
which should evaluate to:
(
  ({x})
)
and converting back:
<div>
  <h1>{x}</h1>
</div>

shaunlebron15:02:01

that would be a fun experiment 🙂

shaunlebron15:02:18

@doglooksgood cool idea, good insight

tianshu15:02:32

{x} is just like the string in lisp

shaunlebron15:02:01

it could be anything, I didn’t mean its brackets would be inferred

tianshu15:02:44

the code inside {} can have jsx tag too, so should wait { closed first. it's bit complex than lisp maybe

shaunlebron15:02:16

haha, we should probably just do HTML first

shaunlebron15:02:04

i wonder if it could work for JS too

shaunlebron15:02:29

it wouldn’t need anything from Smart Mode to work

tianshu15:02:09

1. determine where we put closer. 2. custom the opener and closer type. with these two enhancement, I think it will work for html at least.

shaunlebron15:02:24

to clarify why JS wouldn’t need Smart Mode stuff, replacing if with for below wouldn’t require the body to shift, since the body is always fixed indentation regardless of the position of the curly:

if (true) {
  foo()
}

shaunlebron16:02:07

yeah, i think you’re right, that could be pretty simple to make work for html

shaunlebron16:02:10

parinfer-html could be a pretty quick project 🙂

tianshu16:02:11

the smart-parens in emacs has these kind of work, it handle whatever thing you call them parens, not limited in normal parens.

tianshu16:02:56

If parinfer work both in JS and HTML, it will help JSX a lot

tianshu16:02:12

I always think, write JSX is a pain.

shaunlebron16:02:22

JSX is nicer than HTML in terms of closing tag consistency

shaunlebron16:02:49

<input> vs <input /> and <div></div> vs <div />

tianshu16:02:48

yes, it is

shaunlebron16:02:32

honestly, I don’t struggle with writing JSX

shaunlebron16:02:08

easy to align the tags vertically, people like that. it’s just a bit verbose

tianshu16:02:11

but I struggle and a lot of my workmates struggled. I don't have to write JSX, we prefer clojurescript.

shaunlebron16:02:15

because it’s too much to type? or the fact that it doesn’t compose well with JS?

shaunlebron16:02:31

the JS interpolation is very awkward

tianshu16:02:48

I think the reason why I don't like it, I have to move the cursor here and there, you have to edit both begin and end, just like edit lisp without parinfer or paredit.

tianshu16:02:47

especially when you do wrap and raise from

<div>
  x
</div>
to
<div>
  <span>x</span>
</div>

shaunlebron16:02:23

ah okay, so it’s just the tag manipulation that you don’t like

tianshu16:02:21

another thing, i think why my parser in elisp is slow is that I try to save parse result in a vector

tianshu16:02:47

I should combine parsing and processing. for now, if I save result, parsing will cost 140ms, If I don't, will cost 50ms.

tianshu16:02:59

I think 50ms is good enough