Fuco1 / smartparens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
GNU General Public License v3.0
1.82k stars 195 forks source link

Indenting on wrap? #833

Open xendk opened 6 years ago

xendk commented 6 years ago

sp-unwrap-sexp re-indents the contents of the unwrapped pair. sp-wrap-with-pair with a region will reindent the region wrapped. However, manually wrapping (selecting a region and typing {) doesn't reindent the region.

Indenting is a bit out of smartparens domain, but auto-indents support for pairs doesn't work (or I don't get how it's supposed to) and aggressive-indent doesn't work particularly well for me.

So how about and option that'll make smartparens reindent wrapped region? Or is there an easy way to add a post-handler to all pairs?

Fuco1 commented 6 years ago

I think right now you would have to loop through all your pairs at the end of the setup and add some hook manually. Or maybe it can work as a hook in major mode or something. I will think about some cool way to do this.

xendk commented 6 years ago

There seems to be a lot of code dealing with indentation in smartparens. I was wondering if it wouldn't be more elegant if smartparens implemented a sort of after-change hook, and re-indentation was handled in such a hook? Pair management and indentation seems to me to be two separate things. My guess is (I could be wrong) that a generic "re-indent affected region" would be sufficient in most cases.

Seems that I've fixed my issue by creating yet another auto-indent mode: https://github.com/xendk/indentinator

Fuco1 commented 6 years ago

I agree completely. There's quite a log of things still tangled together which could be separate. I've been slowly untangling stuff but this did not come up yet.