[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 15 09:09:28 PST 2025
goldsteinn wrote:
> > Checking again and am still considering this patch too spesific/incomplete, checking vc's diff calls to git - they are considerably more involved than in this PR, meaning this PR will likely require follow up commits to fix problems _(see `vc-diff-internal`, inlined below for reference, it deals with EOL conversion, added files, coding systems... things this PR doesn't really handle)._
>
> I'm not sure why the complexity of `vc-diff-internal` is really related to the complexity. We only use `vc-root-dir` and `vc-backend`. Further, the `vc` system is not some unstable new feature, its core since 25.1. I don't see why we would expect this to fall over all of a sudden.
>
> Can you expand on what is incomplete or too specific about it. We have `git-clang-format`, this is essentially just porting that functionality to emacs. Is the issue that we only support "git"? Or something else?
>
> > Attached a patch that allows for formatting line-ranges, the line range generation must be implemented externally.
> > ```
> > * The `clang-format-modified-fn` customizable function is used to return a list of "modified" line ranges, this can be set by 3rd party packages - VC implementation independent.
> >
> > * This function simply returns a list of integer pairs (line ranges).
> >
> > * An error is raised if the function isn't set.
> > ```
>
> That seems far more specific and incomplete... but ultimately if its the only part that can be accepted its better than nothing.
>
> > Patch files:
> > ```
> > * Patch on the main branch
> > [pr-112792-update.diff.txt](https://github.com/user-attachments/files/18309256/pr-112792-update.diff.txt)
> >
> > * The whole file (for convenience).
> > [clang-format.el.update.txt](https://github.com/user-attachments/files/18309260/clang-format.el.update.txt)
> >
> > * The git/diff logic extracted into a separate file - which would not be applied to the LLVM project, just use for testing.
> > [clang-format-git-vc-diff.el.txt](https://github.com/user-attachments/files/18309263/clang-format-git-vc-diff.el.txt)
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Perhaps support for version control diff's can be supported by [clang-format-plus](https://github.com/SavchenkoValeriy/emacs-clang-format-plus).
>
> Ultimately I really want to get this into actual clang-format where it will be maintained (by myself included) and kept up to date.
>
> I also think this functionality will be useful for other developers (lukel97 at least seemed to express he would find it useful). Having it in some tertiary repo seems liable to have it end up 1) not much used and 2) in a state of decay in not to long.
@ideasman42
https://github.com/llvm/llvm-project/pull/112792
More information about the cfe-commits
mailing list