parinfer

shaunlebron 2019-01-09T21:28:25.011500Z

@cfleming interesting, smart mode should handle that well, but again it’s probably the editor integration that isn’t notifying parinfer of the nature of the change to help it do the right thing

cfleming 2019-01-09T21:29:20.012200Z

I don’t think it’s that, it’s that IntelliJ sometimes produces very complex lists of overlapping changes.

shaunlebron 2019-01-09T21:29:52.012400Z

ah, that’s actually what I meant

shaunlebron 2019-01-09T21:31:12.014Z

i’ll have to talk about state of parinfer on sunday for the repl podcast, maybe we can catch up on how it’s been working in cursive before then?

👍 1
❤️ 1
cfleming 2019-01-09T21:31:53.014800Z

We’ve talked about this before, and IIRC the conclusion at the time was “it can’t be expected to handle all the potential edge cases for changes like that”, which I think is reasonable.

cfleming 2019-01-09T21:32:06.015Z

Sure, that sounds good.

shaunlebron 2019-01-09T21:33:03.015800Z

i caught up with chris (atom) and jason (vim/kakoune) and they said the exact same thing about the editor integrations they’re maintaining

shaunlebron 2019-01-09T21:33:50.017Z

resorting to diffs for the changes they need

shaunlebron 2019-01-09T21:33:57.017300Z

but only a partial solution

cfleming 2019-01-09T21:34:04.017600Z

So what really made the difference was the change I made which doesn’t run paren mode on file open, but marks the problems instead and lets the user fix them.

cfleming 2019-01-09T21:34:57.018500Z

Then it doesn’t matter if parinfer breaks something in a really crazy change list because the user can then fix it to what they meant.

shaunlebron 2019-01-09T21:36:02.018800Z

because the breaking change is isolated to a single function?

cfleming 2019-01-09T21:36:25.019300Z

No, a change may span various functions.

cfleming 2019-01-09T21:36:36.019600Z

But at least it’s clearly marked where the problems are.

shaunlebron 2019-01-09T21:37:42.020300Z

i suppose there’s different kinds of problems to think about

shaunlebron 2019-01-09T21:37:53.020600Z

but you’re marking incorrect indentation

shaunlebron 2019-01-09T21:38:02.020900Z

and not running indent/smart mode there

shaunlebron 2019-01-09T21:38:32.021800Z

other problems are related to unexpected changes to code with previously correct indentation

cfleming 2019-01-09T21:39:07.022500Z

Currently I don’t run it anywhere, so if the file is broken it’s broken, and there’s no parinfer until it’s fixed. I was planning to make a change to have that apply per top-level form, but I never got around to it and no-one has complained that it’s a problem.

shaunlebron 2019-01-09T21:40:11.023500Z

i see, yeah i assumed the top-level form isolation was part of it

shaunlebron 2019-01-09T21:41:29.024900Z

is smart mode on by default?

shaunlebron 2019-01-09T21:41:34.025100Z

and are many using it?

shaunlebron 2019-01-09T21:41:44.025500Z

and how’s the feedback?

shaunlebron 2019-01-09T21:41:56.026100Z

(smart mode hidden by flag in atom, but feedback has been nil)

cfleming 2019-01-09T21:42:39.026900Z

It’s actually not on by default, I meant to turn it on by default once it stabilised but never did. When I first brought it out a lot of people said they were using it and liking it, and I see occasional comments along those lines.

cfleming 2019-01-09T21:42:54.027300Z

I don’t do any tracking though so I don’t have any firm numbers.

shaunlebron 2019-01-09T21:43:45.027800Z

interesting, i suppose silence can be interpreted either way there

shaunlebron 2019-01-09T21:44:39.028300Z

alright, I think that’s all I need to know for giving an update

shaunlebron 2019-01-09T21:44:50.028700Z

thanks for pinging me on this

cfleming 2019-01-09T21:45:00.029Z

Generally, I’m super happy with it, and I use it all day myself.

cfleming 2019-01-09T21:45:20.029500Z

The integration was one of the most painful things I’ve done in Cursive, though.

cfleming 2019-01-09T21:45:35.029800Z

lein will always take top spot there, but this was probably second.

shaunlebron 2019-01-09T21:46:06.030200Z

haha, alright, i expected as much, i remember how that was going last year

shaunlebron 2019-01-09T21:46:28.030500Z

that might’ve been two years ago, idk anymore

cfleming 2019-01-09T21:46:40.030700Z

A year or so, I think.

shaunlebron 2019-01-09T21:46:59.031Z

copy/paste?

shaunlebron 2019-01-09T21:47:09.031400Z

is that a common thing, and is that alright in parinfer?

cfleming 2019-01-09T21:47:29.031800Z

Copy/paste is still a little painful sometimes. I have plans to make it better, but haven’t had time.

cfleming 2019-01-09T21:47:42.032100Z

It’s definitely a common thing, and mostly works ok.

cfleming 2019-01-09T21:48:00.032500Z

It’s complicated by the fact that IntelliJ likes to auto-indent pasted blocks.

cfleming 2019-01-09T21:48:44.033200Z

Which happens before parinfer gets to run. That occasionally leads to things you wouldn’t expect, but they’re generally easy issues to fix.

shaunlebron 2019-01-09T21:50:12.034100Z

yeah, i had weird things happen when doing some cljs work in atom, like it would dedent entire expressions after my cursor that i had to manually fix

shaunlebron 2019-01-09T21:50:38.035Z

never isolated the cause, but the root of this is that it is very delicate to the wrong change information from the editor

cfleming 2019-01-09T21:51:20.035800Z

I don’t think that’s always the cause, sometimes it makes sense if you think about it, but to a user who doesn’t understand the algorithm it’s going to be weird.

cfleming 2019-01-09T21:51:47.036400Z

e.g. if your editor looks like this:

(defn foo [bar])
  |

shaunlebron 2019-01-09T21:51:48.036500Z

there’s that, yeah

cfleming 2019-01-09T21:52:28.037Z

i.e. you’ve started a new function, and you want to paste the body

cfleming 2019-01-09T21:53:07.037800Z

Pasting there in Cursive will result in:

(defn foo [bar])
(your pasted form)|

cfleming 2019-01-09T21:54:20.039200Z

The user will have expected it to be inserted in the defn form, because their caret was indented when pasting. But IntelliJ pastes, then indents, and then at the end parinfer is run. The indent sees that the new block is outside the top-level form so it dedents it, and then parinfer doesn’t put it in because it’s no longer where the user thought they put it.

shaunlebron 2019-01-09T21:56:38.039500Z

right, editor interference

shaunlebron 2019-01-09T21:58:42.039900Z

@eraserhd how do i pronounce your last name? just wanna get that right

cfleming 2019-01-09T21:59:03.040400Z

Right, but there’s no step there which is obviously wrong, but the end result is confusing.

eraserhd 2019-01-09T22:04:34.041500Z

@shaunlebron fuh-LEASE

👍 1
eraserhd 2019-01-09T22:06:20.042600Z

btw, Kakoune apparently has almost exactly the change log we want, but it wasn't exposed. It wasn't the undo tree, but a monotonic change log that even records switches between branches of the undo tree.

eraserhd 2019-01-09T22:07:09.043200Z

Monotonic is probably the wrong word. Append-only. I will attempt to use it this week.

shaunlebron 2019-01-09T22:11:04.043900Z

huh, interesting, i’d be interested to see how that plays out

shaunlebron 2019-01-09T22:11:37.044500Z

e.g. i wonder if types of changes will have to be ignored or not

eraserhd 2019-01-09T22:14:53.046700Z

Well, there's two things to account for. The first is that this change log has only positional changes, not text. Internally, parinfer only needs positional changes, but it parses that out of text. So I'll need to change that somehow.

eraserhd 2019-01-09T22:15:21.047600Z

(I mean start and end line and column.)

eraserhd 2019-01-09T22:15:49.048600Z

The second is that parinfer wants changes as though they all happened simultaneously, and Kakoune's log has them stacked sequentially.

eraserhd 2019-01-09T22:16:38.049900Z

e.g. the log might say "insert 10 characters at position 2, then delete 3 at position 7"

eraserhd 2019-01-09T22:17:14.050400Z

so I'll need to flatten them

pez 2019-01-09T22:17:26.050700Z

@shaunlebron About the state of integration. For Calva I have so far fallen back on only doing parinfer (smart mode) on the user’s command. Main reason being that vscode is a bit lacking in its API:s. But we have started a change in the whole formatting approach in Calva that might open up for on-the-fly parinfer.

💯 1
eraserhd 2019-01-09T22:17:28.050800Z

or "squish" them, or whatever that operation should be called.

🤘 1
pez 2019-01-09T22:20:00.051900Z

(But so far the users who have talked to me about it are happy with doing smart mode at will.)

shaunlebron 2019-01-09T22:20:28.052Z

you mean running parinfer to format the file when the command is run for it?

shaunlebron 2019-01-09T22:21:38.052200Z

right, this sequential problem is seen in atom when we’re batching change events that can’t be fetched synchronously

shaunlebron 2019-01-09T22:21:57.052400Z

chris wrote some code to “merge” these change objects together in vscode

pez 2019-01-09T22:25:41.052700Z

Yes, Calva has a command Infer parens. (Since it has an on-the-fly formatter, things are most often correctly indented, so running smart mode means infer parens.)

shaunlebron 2019-01-09T22:26:49.052900Z

so it’s a one time run, not a toggle to run continuously thereafter

shaunlebron 2019-01-09T22:28:22.053200Z

if that’s the case, that smart mode = indent mode. the only thing that would make their effects different is the presence of the “changes” option

pez 2019-01-09T22:32:34.053400Z

Yes, one-off, not a toggle. And no changes passed. But there there are two other commands that use that option (also on-offs).

shaunlebron 2019-01-09T22:37:39.053600Z

just to be precise with the language here, your integration is just using “indent mode” if no changes object is being passed to “smart mode”

pez 2019-01-09T22:51:47.053800Z

Yes, so that’s the Infer parens command. There are also two commands that use the changes object, but they are doing it in a way that essentially makes it “paren mode”.