Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we implement a format-modified-region with format-all-region #242

Open
xeechou opened this issue Oct 15, 2023 · 3 comments
Open

Comments

@xeechou
Copy link
Contributor

xeechou commented Oct 15, 2023

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 microsoft/vscode#104994 ?

@xeechou xeechou changed the title format-all-region modifies entire buffer anyway. How can we implement a format-modified-region with format-all-region Oct 15, 2023
@xeechou xeechou changed the title How can we implement a format-modified-region with format-all-region How can we implement a format-modified-region with format-all-region Oct 15, 2023
@lassik
Copy link
Owner

lassik commented Oct 18, 2023

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?

@xeechou
Copy link
Contributor Author

xeechou commented Oct 19, 2023

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

@xeechou
Copy link
Contributor Author

xeechou commented Oct 27, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants