Closed league closed 4 years ago
A small follow-up: I'm finding that the behavior of auto-revert-mode for maintaining buffer position is actually pretty good, so running ormolu via async-shell-command or compile-command is reasonable.
This would be solved, I believe, by using my reformatter.el
library to implement this one. It would reduce this library to just a few lines, and aims to correctly handle all the common details which are hard to get right when writing formatter wrappers like this.
If this project does not progress, I'll put together something else using @purcell 's reformatter thingy. I have some ideas of my own by now for Emacs integration.
https://github.com/raxod502/apheleia for some more ideas about solving this issue
@vyp That's a lot more machinery than reformatter.el
, for not much practical benefit IMO. (In writing reformatter
I reviewed a lot of reformatter libraries, many of which had cargo-culted very old RCS patch code around, and decided to omit it given that the Emacs built-ins do a pretty great job these days.)
@league thank you for starting this discussion. Sorry for delay. I didn't watch this repo for some reason... I like the approach of using the reformatter.el library, #2 looks pretty good :+1: @amesgen
Thanks for this elisp support! I thought I would want the before-save functionality, but what I found disappointing was that it jumps to the beginning of the buffer each time, causing me to lose context.
I realize (after I tried it) that the fix isn't as simple as adding a save-excursion, because it replaces the whole buffer. And it isn't as simple as restoring by line number because that can change substantially. But I wonder if there's a way to maintain the approximate position based on content… is it something you've thought about?