parinfer

grav 2020-10-15T22:41:25.001900Z

(Also posted in #emacs) I've been trying to get parinfer v3 (aka "smart-mode") to work in Emacs. I've been using it in Cursive. I've found two implementations: 1. parinfer-mode, the smart branch: https://github.com/DogLooksGood/parinfer-mode/tree/smart 2. parinfer-rust-mode: https://github.com/justinbarclay/parinfer-rust-mode I've been able to get both up and running, but none of them seem to work like the reference implementation: https://shaunlebron.github.io/parinfer/demo A test that I made is to type a ( in front of the {:sum ... map. Both implementations don't automatically "slurp" the hashmap into a pair of parens (ie turning it into

({:sum sum 
  :prod prod})
Anyone had other experiences?

seancorfield 2020-10-15T23:19:50.002800Z

@grav I would expect ( to just introduce () unless you are using paredit as well.

grav 2020-10-16T18:09:42.007100Z

That's not how the reference implementation which I linked to, as well as Cursive, which implements paredit smart-mode, behaves

grav 2020-10-16T18:12:07.007300Z

Or maybe I'm misunderstanding your comment

justinbarclay 2020-10-15T23:33:11.005300Z

For parinfer-rust, and parinfer-rust-mode, if paredit mode is on it forces parens to be balanced before parinfer operates on the buffer. Therefore, parinfer won't infer that it should wrap the following sexp. cc @grav

grav 2020-10-16T18:23:27.007500Z

Thanks, that makes sense! I'm pretty new to Emacs, and I apparently am not able to disable paredit in a simple way with prelude, so I am unable to test it.

grav 2020-10-16T18:28:41.007700Z

Ah, apparently it's called smartparens, and yes, disabling it does seem to make the specific scenario work!

justinbarclay 2020-10-16T18:31:13.007900Z

Awesome glad to here it 🙂 If you always want smartparens turned off in a particular major-mode, you could use something like: (add-hook 'clojure-mode-hook (lambda () (smartparens-mode -1)))

grav 2020-10-16T18:31:31.008100Z

Perfect, thanks! 🙂

justinbarclay 2020-10-15T23:37:41.006200Z

I assume that this holds true for smartparens as well.