parinfer

shaunlebron 2018-02-14T08:41:03.000434Z

@cfleming: typed a response for this bug: https://twitter.com/CmdrDats/status/963346700357251072

shaunlebron 2018-02-14T08:41:32.000426Z

i wonder if the production Cursive build is still using v1 behavior

cfleming 2018-02-14T08:48:11.000028Z

@shaunlebron I actually can’t remember.

cfleming 2018-02-14T08:48:55.000403Z

In the parinfer demo editor, with forceBalance on I get this: [[{| []}]]

cfleming 2018-02-14T08:49:06.000050Z

Which is definitely not what you want.

shaunlebron 2018-02-14T08:56:43.000202Z

@cfleming: that is what v1 did

cfleming 2018-02-14T08:57:17.000337Z

I’m actually considering just always inserting balanced parens in parinfer mode.

shaunlebron 2018-02-14T08:57:54.000276Z

(|foo => ()|foo?

cfleming 2018-02-14T08:57:55.000413Z

You’d lose the slurp/barf-like functionality, but it seems a little unpredictable.

cfleming 2018-02-14T08:58:24.000267Z

I mean when the user types an opening paren, always inserting the balancing closing paren.

cfleming 2018-02-14T08:58:51.000033Z

So if the user types (, I’d add () and leave the caret between them.

cfleming 2018-02-14T08:59:13.000181Z

Parinfer is the only editing mode which doesn’t act like that, unless the user totally turns paren balancing off.

shaunlebron 2018-02-14T09:00:35.000354Z

So, typing ( at |foo => (|)foo

shaunlebron 2018-02-14T09:01:10.000322Z

that would turn off wrapping behavior of (|foo => (|foo)

cfleming 2018-02-14T09:02:25.000346Z

Right.

cfleming 2018-02-14T09:02:44.000204Z

So if the user wanted to wrap they’d have to use the wrapping commands from paredit.

cfleming 2018-02-14T09:02:59.000057Z

Those and Raise are almost the only ones I use still.

cfleming 2018-02-14T09:06:57.000144Z

The wrapping commands are easy to remember in Cursive, they’re just Ctrl/Cmd + the normal key.

shaunlebron 2018-02-14T09:11:35.000070Z

@cfleming: I think that’s a reasonable compromise to just auto-insert )

cfleming 2018-02-14T09:11:53.000470Z

At least as an option, I think so.

cfleming 2018-02-14T09:12:14.000414Z

The in-line inference doesn’t look like it has an easy solution.

shaunlebron 2018-02-14T09:12:35.000398Z

boy I tried

shaunlebron 2018-02-14T09:12:54.000316Z

i spent a long time last year thinking about that

cfleming 2018-02-14T09:13:03.000243Z

Hehe, yeah, I know - I can’t remember all the details, but it just seems really messy

shaunlebron 2018-02-14T09:13:36.000023Z

basically, it hit the boundary of what was possible by not looking at the content of the change

shaunlebron 2018-02-14T09:14:34.000138Z

anyway, will explore what to do when pasting (( or deleting a ), since those are the cases not solved by auto-insertion of ) when typing (

shaunlebron 2018-02-14T09:14:40.000435Z

that will be v4

cfleming 2018-02-14T09:15:19.000257Z

Yes, better inference will still be very useful, no doubt.

taylor 2018-02-14T14:26:13.000222Z

from my perspective as a user I think you’ve done a great job “hiding” all this intricate behavior/logic, because I had no idea this was so hard a problem until I started looking into the implementation. I guess I assumed because it was pretty intuitive to use, it was probably ~easy to pull off 😄

tianshu 2018-02-14T17:25:30.000758Z

process 2800 lines in 20ms

👏 2
tianshu 2018-02-14T17:25:39.000721Z

☺️

shaunlebron 2018-02-14T17:25:52.000673Z

@taylor thanks for saying that, it should probably easier to pull off than it was, but i’m still trying to figure it all out

shaunlebron 2018-02-14T17:26:09.000205Z

@doglooksgood whoa 🎉, what was the change?

tianshu 2018-02-14T17:29:02.000117Z

some functions in emacs are really slow, I just rewrite for avoid these functions. but it's not a completed implementation yet. I use lisp-indent-line to do indent instead of calculate delta x. but it's looks almost finished.

justinbarclay 2018-02-14T17:34:04.000663Z

I use parinfer everyday at work, and I am super excited for this new version to come out. Thanks for all the work you’re putting in.

tianshu 2018-02-14T17:34:37.000182Z

but I can still feel lag if on a file large than 1k lines. just don't know why. file with 1k lines only take 9ms to process(do all work, not parsing). so it's still need avoid process whole buffer. but it's much faster than the current parinfer-mode.

shaunlebron 2018-02-14T17:39:03.000461Z

but you’re still only processing top-level expressions right?

shaunlebron 2018-02-14T17:39:17.000453Z

and it’s still lagging on 1kloc files?

tianshu 2018-02-14T17:39:18.000422Z

no, whole buffer, 2800lines, 20ms

shaunlebron 2018-02-14T17:39:42.000168Z

ah, cool! so you can avoid the lag with the top-level form hack atom uses

tianshu 2018-02-14T17:40:13.000197Z

yes, that's pretty easy to achieve

shaunlebron 2018-02-14T17:40:24.000681Z

man that gif is fun to watch 🙂

1
shaunlebron 2018-02-14T17:41:17.000445Z

you even implemented the status message errors from parinfer?

tianshu 2018-02-14T17:42:17.000167Z

yes, error will display.

tianshu 2018-02-14T17:42:44.000269Z

It's better to show error position with overlay, but I haven't implement

tianshu 2018-02-14T17:48:23.000164Z

some behavior is different with parinfer demo, for I let emacs do indent instead of preserve. lot of work need to be done for this.

tianshu 2018-02-14T17:49:29.000595Z

I just want to update this as a new mode called parinfer-smart in current parinfer-mode when it's stable.

dominicm 2018-02-14T17:53:36.000302Z

I need to port neovim's parinfer implementation if emacs is getting smart mode. Can't have that kind of imbalance (pun intended)

tianshu 2018-02-14T17:55:12.000504Z

it's very nice that neovim can use javascript extension.

dominicm 2018-02-14T17:58:19.000325Z

Very convenient, yes.

dominicm 2018-02-14T17:58:41.000246Z

I think @eraserhd was working on this actually.

tianshu 2018-02-14T18:02:17.000834Z

new version will come soon:grinning:

tianshu 2018-02-14T18:17:41.000500Z

....I made mistake, is 160ms on 2800lines... no 16ms:sob:

tianshu 2018-02-14T18:18:08.000307Z

faster than the old version. but not so fast

tianshu 2018-02-14T18:21:08.000383Z

but after byte compile, it's fast again:sunglasses: