parinfer

cfleming 2017-08-10T01:40:47.186353Z

Ok, no problem. I don’t think the changes are that conceptual to be honest, but there’s a lot of changes to all the bookkeeping which needs some thought.

cfleming 2017-08-10T01:41:38.196674Z

Assuming this looks mostly ok, I’m going to get it into a dev build of Cursive people can try - there are too many cases I can’t simulate in CodeMirror (renaming vars etc)

cfleming 2017-08-10T02:21:17.673015Z

@doglooksgood Here’s an alpha version of what I was talking about last week: https://github.com/cursive-ide/parinfer/tree/process-buffer

cfleming 2017-08-10T02:24:58.715346Z

Here is the main loop - this is where you would integrate whatever Emacs offers for a char iterator over the buffer: https://github.com/cursive-ide/parinfer/blob/process-buffer/lib/parinfer.js#L1296-L1316

shaunlebron 2017-08-10T02:30:00.771227Z

@cfleming: all tests are passing?

cfleming 2017-08-10T02:30:53.782295Z

No, I’m trying the test cases in the editor. The one we discussed the other day doesn’t actually seem to be an issue with the new functionality to warn on unbalanced close parens.

shaunlebron 2017-08-10T02:30:59.783483Z

and tangentially: is the race condition in Cursive that prevents files from being pre-processed by paren mode fixed?

cfleming 2017-08-10T02:31:14.786566Z

No, I’m planning to look at that at the same time as fixing this.

shaunlebron 2017-08-10T02:31:16.786916Z

my survey showed that to be a problem

cfleming 2017-08-10T02:31:25.788835Z

It’s definitely a problem.

shaunlebron 2017-08-10T02:31:49.793459Z

seems critical honestly

cfleming 2017-08-10T02:31:53.794373Z

Yup.

shaunlebron 2017-08-10T02:32:36.802752Z

in the #clojurescript channel, i think it’s more than a few people’s perception that parinfer can break your code if not indented correctly

shaunlebron 2017-08-10T02:33:29.812531Z

could there be a redundant safety check to not run indent mode on a file until paren mode does?

cfleming 2017-08-10T02:34:09.820523Z

I’d need to go back and look at the details of how I implemented that. I remember it was hard, but I don’t remember all the details.

shaunlebron 2017-08-10T02:34:27.824119Z

this is the comment I saw: https://clojurians.slack.com/archives/C03S1L9DN/p1501185363764216

cfleming 2017-08-10T02:34:33.825264Z

So the second failing test case also appears to not be an issue in the actual editor, I’m not sure why.

shaunlebron 2017-08-10T02:36:50.851383Z

i have to step out for an hour

cfleming 2017-08-10T02:40:08.887622Z

I lie, it is a problem, Chrome had cached the old version.

tianshu 2017-08-10T02:53:24.034942Z

Can I change buffer step by step, instead of process-text -> public-result? I am not very familiar with the algorithm for now.

cfleming 2017-08-10T03:04:59.162819Z

Yes, that is what the edit changes tries to do. It’s not fully working yet, though.

cfleming 2017-08-10T03:50:13.623115Z

I fixed the last smart mode bug, and a bug in the CodeMirror integration. After some initial playing, it seems good now.

cfleming 2017-08-10T03:51:03.631414Z

The indent mode test is still failing, and I don’t have a good solution for that. I’ll file an issue with the details from earlier in this chat so they don’t get lost.

cfleming 2017-08-10T03:53:01.651718Z

There’s one issue - I no longer return the new cursor value from parinfer in this version, and just rely on CodeMirror to push the caret around based on the edits. There’s one very common case where that’s a problem: entering new parens.

cfleming 2017-08-10T03:54:04.662428Z

So if open a new paren, I end up with ()| because of the way that the edits are created. This isn’t a problem in Cursive because I explicitly create both parens and put the caret between them - I suspect most actual editors will do that.

cfleming 2017-08-10T09:09:14.302400Z

BTW that issue is just an edge case in what to do when an edit inserts exactly at the caret - it could be worked around in CodeMirror too with no problem.

tianshu 2017-08-10T09:15:21.435546Z

I think a article in detail how this algorithm works will help a lot, since every editor have different plugin system.

cfleming 2017-08-10T09:23:43.621491Z

@doglooksgood Do you mean parinfer itself?

tianshu 2017-08-10T11:38:29.213586Z

yes,I want to rewrite to let parinfer process buffer directly. not a function to function port.

shaunlebron 2017-08-10T19:07:56.025371Z

i will have to update this document with smart mode changes: https://github.com/shaunlebron/parinfer/blob/master/lib/doc/code.md

shaunlebron 2017-08-10T19:09:06.062472Z

@doglooksgood it doesn’t make sense to move forward on documenting and porting something that we are not yet sure people will like

cfleming 2017-08-10T21:50:05.874739Z

@doglooksgood That is exactly what the branch/fork that I sent you does - if you want to do something different to that, I don’t understand what you mean.

cfleming 2017-08-10T21:50:31.885450Z

That change may become parinfer mainline at some point, but that’s not decided yet.

cfleming 2017-08-10T21:52:36.936763Z

FWIW this is one of the best-documented projects I’ve ever been involved with. There are conceptual docs in the webpages, the code is well documented and there is a lot of very useful discussion in the issues. The doc isn’t currently up to date with smart mode, but like Shaun says that’s still experimental.

❤️ 1
cfleming 2017-08-10T21:53:08.949843Z

It is a complicated algorithm now, and the code takes some time to understand, but it’s doing a lot these days.

cfleming 2017-08-10T21:53:39.962047Z

It’s probably not something you can port to elisp in a weekend.

🙃 1
cfleming 2017-08-10T22:02:22.172253Z

@chrisoakman Now that Atom has smart mode, do you still expose Indent and Paren mode to the user?

cfleming 2017-08-10T22:02:46.181524Z

Are you actively using it at the moment? Do you have a feeling for whether they’re still necessary?

cfleming 2017-08-10T22:03:18.193366Z

Or rather, will be if smart mode works out?

cfleming 2017-08-10T22:04:13.213393Z

Anyone else using the latest Atom version have opinions on that?

rgdelato 2017-08-10T22:11:42.373680Z

The options in Atom now have a checkbox for replacing Indent Mode with Smart Mode (with Smart Mode off by default), so the user can still use Indent Mode

cfleming 2017-08-10T22:15:36.452834Z

@rgdelato If you have smart mode, do you think you’d still need indent mode?

rgdelato 2017-08-10T22:17:00.481028Z

probably not? But I think they're hedging because Smart Mode has some behavior that people might not like

cfleming 2017-08-10T22:17:25.489561Z

Sure, I understand it’s still experimental, just interested in the experiences of people actually using it.

rgdelato 2017-08-10T22:19:05.522362Z

If Indent Mode had at least kept the cursorDx thing, then maybe it'd be kind of a choice for me, but since Smart Mode is the only one that currently preserves the structure underneath my edit, I'm 100% Smart Mode all the way

cfleming 2017-08-10T22:19:39.533665Z

That’s good to hear, thanks!

rgdelato 2017-08-10T22:27:00.677982Z

Probably my biggest complaint with the current Smart Mode is that you can't delete from certain states: https://github.com/shaunlebron/parinfer/issues/59#issuecomment-313469378

rgdelato 2017-08-10T22:29:34.726266Z

(which is like multiple orders of magnitude smaller than the previous complaint of "I need to switch modes when making certain edits", so still a huge win)

cfleming 2017-08-10T22:30:03.735138Z

Interesting, that is tricky.

cfleming 2017-08-10T22:30:35.745840Z

I’m hoping to get a dev build of Cursive out with smart mode soon so people can test it.

chrisoakman 2017-08-10T22:45:16.010984Z

@cfleming I haven't been using atom-parinfer enough this week to really have an opinion on smartMode. I'm generally bullish on it vs Indent Mode. But still evaluating it from usage.

chrisoakman 2017-08-10T22:45:42.018407Z

Like Ryan said, atom-parinfer basically still works the way it has always worked. Except now there is an option to use smartMode instead of Indent Mode.

chrisoakman 2017-08-10T22:46:35.033753Z

The plan is to remove Indent Mode and only have Smart Mode once it is stable / awesome.

chrisoakman 2017-08-10T22:47:31.049728Z

atom-parinfer v2.0.0 should hopefully be Smart Mode by default

chrisoakman 2017-08-10T22:48:05.059375Z

I think Paren Mode will always exist in some form. Even if only to run on the file when it is first opened.

cfleming 2017-08-10T22:48:41.069780Z

Yeah, I can definitely see that the modes need to exist internally, but was curious if users still had a need for them.

chrisoakman 2017-08-10T23:40:58.902582Z

@doglooksgood I definitely want to keep parinfer-elisp up-to-date with parinfer.js. Have been waiting for it to stabilize.

chrisoakman 2017-08-10T23:42:02.918108Z

Also I read that thing about "buffer is faster than string" for the elisp docs. I went with strings for port clarity. I wonder how much the speed difference really is? In general, I would be wary of going that route unless we had some good metrics showing the difference between the two.

chrisoakman 2017-08-10T23:42:59.931286Z

All that said, I am not an emacs user. And not opposed to that approach if it is better. It's just important that the ports all pass the same test suite as parinfer.js

chrisoakman 2017-08-10T23:48:01.001990Z

@cfleming I don't really know how confusing the two modes are for users. Ideally: there would be no modes. But I think in practice people are in Indent (or now Smart) mode 99% of the time.