Fork me on GitHub
#parinfer
<
2016-03-23
>
sekao00:03:05

why not run paren mode when that happens?

cfleming00:03:32

I’m not sure I can. Those modifications are done on the AST, which is built over the text document. So the symbol for the name will be replaced in the AST, which will be synced back to the text document by magic. I don’t think I can intercept that at that point.

cfleming00:03:10

Besides, I’d have to ensure that I caught all possible operations which might make non-local edits which would break the code in this way.

sekao00:03:32

true, it has many implications. i’m not familiar with intellij

sekao00:03:38

with their API that is

sekao00:03:20

sucks if they don’t give you some kind of hook after the renaming action happens

cfleming00:03:55

They do, but it’s all based around the AST.

cfleming00:03:33

IntelliJ in general is not designed around non-local text-based manipulation, which has made getting parinfer in very hard.

cfleming02:03:54

So I’m interested what everyone thinks. In noctuid’s article, he argues basically (ignoring all the Emacs stuff) that a combination of auto-indentation and then an action which will indent and rebalance the parens will get most of parinfer’s advantages with none of the disadvantages. What does everyone think about this?

cfleming02:03:57

You miss the sort-of automatic paredit, but from shaunlebron's comment above it looks like that may not work as well as hoped due to the issues snoe has raised.

cfleming02:03:28

This means that the modifications are local rather than global, but I’m actually starting to think that that is an advantage.

cfleming02:03:00

It does not require running paren mode over the whole doc on file open, which has made this a non-starter for several people that I’ve seen.

cfleming02:03:34

Assuming the auto-indentation works correctly, I’m actually inclined to agree with him. I’m interested in feedback or counter arguments simple_smile

cfleming02:03:10

In fact, it has one big advantage over parinfer - it doesn’t require mode switching, but provides the main things that users seem to want from both modes (auto-indent from paren mode, and rebalancing based on indentation from indent mode).

shaunlebron02:03:40

few points here:

shaunlebron02:03:50

1. yeah, it’s sad to see the auto-paredit stuff crumbling

shaunlebron02:03:01

it remains true in some cases, obviously, but it’s certainly broken in enough cases that it can’t be advertised like that anymore

cfleming02:03:49

Yeah. I’m interested whether people using parinfer a lot actually use that. It always seemed to me like it doesn’t offer enough control - I don’t usually slurp or barf to the end of the line.

cfleming02:03:11

But again, I may not have used it enough.

cfleming02:03:18

From my POV, the hypothetical mode above has another huge advantage - it works much better with IntelliJ’s model.

cfleming02:03:40

It’s still quite a lot of work, but removes a lot of the edge cases.

shaunlebron02:03:44

2. the aggressive-indent + rebalance action based on indentation is another idea that will have tradeoffs that noctuid mentions

shaunlebron02:03:44

in the absence of modes, we must deduce user intention about what is to be preserved by the action the user is taking

shaunlebron02:03:10

there are multiple actions that make this tricky

shaunlebron02:03:31

tab/shift-tab can be wrapped to convey ‘rebalance based on indentation'

shaunlebron02:03:44

spacebar and backspace though?

cfleming02:03:44

Right, that was what I was thinking.

shaunlebron02:03:53

or pasting spaces

shaunlebron02:03:06

pasting code containing indentation

cfleming02:03:21

But pasting code containing indentation doesn’t work correctly with indent mode either.

shaunlebron02:03:15

it must work in Indent Mode because transformation is based on text not user action

shaunlebron02:03:40

however the text gets there, it will be transformed

cfleming02:03:43

Only if you’re pasting code with the caret at the start of the line.

shaunlebron02:03:13

full file transformation, unless the parent expression hack is used

cfleming02:03:25

If you’re pasting code after a bunch of spaces, which is pretty common, it won’t work.

shaunlebron02:03:10

sorry, never made this share snippets, but I think it’d be constructive to produce an example here

cfleming02:03:43

Ok, let me see if I can come up with one

shaunlebron02:03:57

I think you may be talking about the extra indentation of the first line

shaunlebron02:03:27

I’m referring to the fact that the indentation is parsed no matter how it gets there

cfleming02:03:12

What I mean is:

(let [x 10])

cfleming02:03:43

I’ve just closed the square brace, and I press enter, then I paste:

(when true
  (do-something))

cfleming02:03:06

That code gets broken. I mean, I understand why it happens, but it’s a very common case that will confuse users.

cfleming02:03:09

I have the additional problem I discussed above, where non-local changes like renames will currently break things badly.

shaunlebron02:03:19

so in the case of pasting this in this new hypothetical mode, it would be pasted, then aggressively indented

cfleming02:03:42

Yeah, Cursive actually already does that - newly pasted code gets reformatted.

shaunlebron02:03:09

how would you handle backspacing indentation

cfleming02:03:35

It probably would not be allowed, thinking about it - you’d have to dedent

shaunlebron02:03:46

I imagine aggressive indent would stop the cursor at the indentation threshold, similar to paren mode

cfleming02:03:12

I guess I’m just starting to get the feeling that indentation is actually more fragile than I had assumed.

cfleming02:03:26

Especially at transitional points while editing.

cfleming02:03:04

And I’m starting to think that perhaps changing parens around based on indentation should be the explicit action, not the automatic one.

shaunlebron02:03:49

I think it’s worth trying

cfleming02:03:29

If only because the refactoring problem I describe above is probably a deal-breaker for me.

shaunlebron02:03:35

we can hypothesize about new users, but we gotta build both and see how they respond

cfleming02:03:43

Definitely.

shaunlebron02:03:00

obviously, do what’s best for your sanity in Cursive especially

shaunlebron02:03:13

you’ve been battling terrible corner cases on that for a while

cfleming02:03:36

Yeah, it’s been painful.

shaunlebron02:03:13

(sorry to be the source of that…)

cfleming02:03:16

Ok, I’m going to patch this up for now, and then I think I’m going to try to implement hypothetical mode X for a test release that people can try out.

cfleming02:03:27

No worries, it’s all been very interesting.

cfleming02:03:53

Even if nothing else comes of it, having provoked people to think about it is really valuable.

shaunlebron02:03:21

marking off dead ends is still science I suppose

cfleming02:03:42

Hehe, definitely, although I wouldn’t say we’re at the point of marking off parinfer just yet.

shaunlebron02:03:01

haha, well if it comes to that

cfleming02:03:07

Think of it as just losing some theoretical purity simple_smile

cfleming02:03:17

As the edge cases come out.

snoe05:03:33

I think the issue I raised about tab stops is part of this too. In indent mode, if you are changing the indentation it means you want to change the structure of the code, that can be done imprecisely with spaces or tabs or rebinding tab to paredit slurp or barf. I needed to highlight cursor column to work in indent mode effectively but even then it's so easy to indent one off in, say, long hiccup forms that the number of mistakes i made was always relatively high in the five months i used it. so I've come around to thinking that the paredit functions really do capture structural edits well.

snoe05:03:21

In vim though, paredit or vimsexp, both have insert mappings that keep parens balanced. Parinfer's behavior when typing open or close parens, or removing them is however far better than vims paredit wrap, or indent mappings and I think slightly better than emacs'

cfleming08:03:35

@snoe: Yes, I definitely think that indent mode should snap to the right possible locations - that’s a change I’m planning to make tomorrow.