parinfer

mattly 2017-08-11T04:38:08.904756Z

as a user of parinfer in first emacs and now atom, the only time I switch to Paren mode is when I need to re-indent something because its place in the tree changed

mattly 2017-08-11T04:38:40.909020Z

though I’ve found atom’s lisp-paredit easier to grok than emacs’s, and so I’m using raise/splice/etc more often

tianshu 2017-08-11T05:16:57.226518Z

I can't get correct indentation on atom, I have lisp-paredit installed, but that not help. when I press enter, sometimes the indentation is correct, sometimes not.

rgdelato 2017-08-11T05:34:34.371892Z

If you go into the lisp-paredit settings, you can set your list of indentation forms, maybe that will help?

rgdelato 2017-08-11T05:41:34.429225Z

For example, if hello is in your indentation forms, then you get:

(hello :there
  |)
...and if it's not, then you get:
(hello :there
       |)

cfleming 2017-08-11T05:43:56.449149Z

@mattly Is that true with smart mode as well, or with the current indent mode?

cfleming 2017-08-11T05:44:19.452427Z

re: paren mode, that is.

rgdelato 2017-08-11T07:22:45.561532Z

I guess I should clarify... that "unable to delete" issue is actually an issue with having forceBalance set to "off", so it's not a problem with Smart Mode exactly (and atom-parinfer has forceBalance set to "on" by default)

cfleming 2017-08-11T09:25:57.758119Z

forceBalance is the new feature which flags an error when it finds an unmatched close paren instead of correcting it, is that right?

shaunlebron 2017-08-11T09:35:58.953699Z

it’s a blanket option for a couple things

shaunlebron 2017-08-11T09:36:13.958601Z

but when it’s on, you’re signaling that you want balanced parens no matter what

shaunlebron 2017-08-11T09:38:56.009619Z

v2 dialed back the aggression on unmatched close-parens and leading close-parens

shaunlebron 2017-08-11T09:39:59.029412Z

- unmatched close-parens are flagged rather than removed - leading close-parens are allowed by running Paren Mode when they are present

shaunlebron 2017-08-11T09:41:03.050320Z

since both behaviors allow temporary imbalance, they are not used when forceBalance is enabled

shaunlebron 2017-08-11T09:43:48.104494Z

for example, for leading close-parens:

(foo
  |) bar
if you reach the above state after pressing enter or deleting a word in Indent Mode, surprising things can happen

shaunlebron 2017-08-11T09:45:35.139481Z

so the leading close-paren => Paren Mode behavior was the best I could come up with. and since Paren Mode allows imbalance, this behavior can’t be used with forceBalance

shaunlebron 2017-08-11T16:54:30.230199Z

does that make sense?

shaunlebron 2017-08-11T16:56:19.287849Z

leading close-paren => Paren Mode needed => possible imbalance => cannot use when forceBalanced

shaunlebron 2017-08-11T17:08:09.665589Z

i’ll have to make a forceBalance section on the new page then

chrisoakman 2017-08-11T17:16:51.930483Z

Or just remove it entirely 😉

shaunlebron 2017-08-11T17:17:58.964475Z

if I removed it, I’d have to fork atom-parinfer 🙂

rgdelato 2017-08-11T17:35:27.516713Z

So Shaun has asked this a few times in the GitHub issue... does anyone have a good idea about what should be the result if the user presses "delete" in this situation?

(def m {:a 1
        |} bar)

timgilbert 2017-08-11T17:40:59.690284Z

I'd personally favor

(def m {:a 1|} bar)
...viewing delete as meaning "undo what I just typed"

👍 2
timgilbert 2017-08-11T17:42:49.749144Z

BTW, is there a 500-feet-up description of what the difference between smart mode and indent mode is (understanding that it's still a WIP) anywhere?

rgdelato 2017-08-11T17:43:51.781928Z

My original guess is that maybe you'd end up like this:

(def m {:a 1
       |} bar)
...and then when you move your cursor away, you'd be reformatted to:
(def m {:a 1}
       bar)
...but honestly, I like Tim's idea if it pans out

rgdelato 2017-08-11T17:44:42.809107Z

@timgilbert In my opinion, the biggest change is that expressions under you hold their shape: https://www.youtube.com/watch?v=9iZfdfsoC5o

timgilbert 2017-08-11T17:45:07.822445Z

Thanks @rgdelato, will check that out

rgdelato 2017-08-11T17:45:28.833193Z

so hopefully as a user, you'll never need to switch to Paren Mode anymore. From a more technical standpoint, Smart Mode takes a list of changes as well as the current state of the document to make decisions

shaunlebron 2017-08-11T19:11:56.511390Z

Pressing delete twice might be surprising here if it joins the two lines, since it doesn’t constitute “undo what I typed”:

(def m {:a 1
        x|} bar)