yapfify-region also modifies outside the region
While expecting yapfify-region modifies selected region, it also removes trailing whitespaces outside the region.
So it actually modified the whole buffer instead of region
I see what you mean, but that must be yapf behaviour than :thinking:. No other formatting is applied.
Check yapf quickly. Seems yapf is using ast to do the formatting so it removes all trailing whitespace even before reformatting.
Maybe one workaround can be
- remember indentation of a region
- send that region for reformatting
- copy back and replace text between
startandend
This will increase the parsing speed for sure that we no longer need to parse the whole buffer for reformatting 10 lines of code. (Personally I tried to format 10 lines in a 30,000 line file which froze emacs instantly)
Drawback will be the selected region must not have syntax error