emacs-format-all-the-code
emacs-format-all-the-code copied to clipboard
How can we implement a `format-modified-region` with `format-all-region`
Hi, it is nice to have format-all-region
that only format one region of the buffer. However I am not sure how useful it is. I tried to archive formatting only the modified regions (as it is already available feature in vscode, neovim, etc) for large code base with legacy code.
I try to implement this feature with (after-change-functions)
hook and format-all-region
but it is not possible since format-all-region
modifies the entire buffer anyway.
I am wondering how we can archive the similar feature as in https://github.com/microsoft/vscode/pull/104994 ?
it is not possible since
format-all-region
modifies the entire buffer anyway.
It should not modify the entire buffer. That sounds like a bug. Which formatter did you test it with?
it is not possible since
format-all-region
modifies the entire buffer anyway.It should not modify the entire buffer. That sounds like a bug. Which formatter did you test it with?
I don't meant it changed actual "content" of the entire buffer. If you turned on highlight-changes-mode and run a format-all-région you will see. I am using clang-format
I found the only reliable way to format only changed lines is relying on output from diff
. I created a small fmo-mode to apply format-all-region
on only changed lines.