parinfer

dominicm 2018-11-24T06:25:07.076400Z

I think maybe atom has this

pez 2018-11-24T08:04:45.079500Z

In the demo editor, what is indenting the cursor on the ned line when I type something like (-> foo|) and hit enter, to get

(-> foo
    |)
? Is it Parinfer?

pez 2018-11-24T09:01:37.080300Z

The closest I get with only Parinfer is:

(let [o (jsify {:cursorLine 1
                :cursorX 0
                :prevCursorLine 0
                :prevCursorX 8
                :changes [{:lineNo 0
                           :x 8
                           :oldText ")"
                           :newText "\n)"}]})
      result (parinfer/smartMode "(--> foo\n)" o)]
  (cljify result))
=> {:text "(--> foo\n )", :cursorX 1, :cursorLine 1, :success true, :tabStops [{:ch "(", :x 0, :lineNo 0, :argX 5}], :parenTrails [{:lineNo 1, :startX 0, :endX 2}]}

pez 2018-11-24T10:42:53.081300Z

Never mind, found this in clojure-parinfer.js:

*    This Clojure mode also has logic for where to indent the cursor when pressing enter.
 *    We do not modify this.

pez 2018-11-24T13:27:19.087300Z

As I am testing out processing the document on cursor move I find that I would like to have some option to get WIP-treatment of my code, where parinfer wouldn’t fold parens. So.

(foo
 
 |)
Would become, when I move the cursor up:
(foo
 |
 )
Instead of:
(foo)
 |

Is this very tricky to achieve, or would it break Parinfer in some way? I can file a feature request about it if it is a feasible thing to wish for.

pez 2018-11-24T13:35:16.090800Z

I have this need to get the parens out of the way while I enter some code, but I do want parinfer’s help to be my guardian of the balance. I get a bit distracted by the parens moving back up when I just moved them down, and then they reappear when I start typing. I guess it is a matter of getting used to trust parinfer, but anyway, I don’t want to have a paren fight with my editor.