Fork me on GitHub
#parinfer
<
2017-07-18
>
cfleming00:07:21

@shaunlebron Depends on the form unfortunately. I guess that will only be an issue if renaming a symbol by deleting the whole thing - it would have to get down to 1 char wide for that to be an issue.

cfleming00:07:50

So I think I’m ok requiring some manual rearrangement in that case, since it’s likely to be far less common than other edits to leading forms - I think stickiness should be the default.

cfleming00:07:21

Again, my initial impression without having actually used it yet - still debugging the port, and haven’t had much time this last couple of days.

tianshu00:07:55

@shaunlebron IMO, when you want to edit some symbols, literals, etc, parens should never be changed. the indentation of bar, shouldn't affect the code struct.

rgdelato01:07:53

I think what @shaunlebron means is if you have:

(println {:a 1
          :b 2}
   bar)
...and then you delete the println to get:
({:a 1
  :b 2}
 bar)
...what do you expect if you put the println back? This?
(println {:a 1
          :b 2}
         bar)
Or maybe this?
(println {:a 1
          :b 2}
 bar)

tianshu02:07:16

I think both is okay, but when I have

(println {:a 1
          :b 2}
         bar)
when I change println -> print It becomes
(print {:a 1
        :b 2
        bar})

tianshu02:07:57

it's likely a bug?

shaunlebron06:07:42

I agree that the current behavior should be changed to prevent surprising structure changes

shaunlebron06:07:42

thought about a minimal fix for this today. The problem happens when an open-paren moves backward. my first draft for a rule: when an open-paren moves backward, the next line should be moved backward by same amount only to prevent being newly absorbed into the list. applying this recursively for any subsequently shifted open-parens will prevent structure changes without worrying about sibling alignment, a la Paren Mode

shaunlebron06:07:52

pushing forms around sokoban-style is as minimal a method as I can think of right now. will need more time to understand what stickiness might do and how to implement it

shaunlebron07:07:25

a weird edge case:

(defn foo
  |[a b]
  bar
  baz)
what happens when you press backspace until [a b] is moved to previous line?

shaunlebron07:07:34

1. with nudging:

(defn foo |[a b])
bar
  baz

shaunlebron07:07:38

2. with stickiness:

(defn foo |[a b])
bar
baz
3. with adoption:
(defn foo |[a b
            bar
            baz])

tianshu08:07:49

unfortunately, none of these three is what we want.

tianshu08:07:10

I will choose 3, because when I edit indentation, usually I wish I can change the structure. If I want to achieve

(defn foo |[a b]
  bar
  baz)
I will use some command to pull this line up. but It's likely parinfer is designed for no shortcut.

shaunlebron12:07:35

I will think about how to allow this intermediate state then:

(defn foo
|[a b]
   bar
   baz)

shaunlebron13:07:47

we would have to use the cursor position to deduce when to prevent the close-paren from moving, like it already does in this case:

(defn foo
 [a b]|
   bar
   baz)

shaunlebron13:07:33

structure can still change the moment you move the cursor to another line. (for example, in the original gif case—when deleting println and typing print, bar would still be absorbed by the map, unless it was indented by just two spaces)

shaunlebron13:07:07

so, a fourth option: 4. always hold paren-trail of cursor line:

(defn foo |[a b]
  bar
  baz)

shaunlebron13:07:47

I don’t think I can prevent structural damage in all cases, but I think I can prevent it for intermediate states—which seems most important

shaunlebron15:07:27

we could do either of the following extra things to improve the UX around this: a) return a warning for parens that would be displaced when cursor is moved to another line—so editors can highlight them b) apply Paren Mode to prevent paren-displacement when cursor is moved to another line—can be done if we pass in previous cursor position