<p dir="ltr">I have a prototype based on -output-replacements-xml, that needs some cleaning up but basically does this. I could not find a built-in difflib equivalent, so I chose to go down that road.<br>
See <a href="https://github.com/kljohann/clang-format.el/tree/xml">https://github.com/kljohann/clang-format.el/tree/xml</a><br>
Note that, when using this option, the JSON-header containing the<br>
'-cursor' information is not returned, so I have to rely on markers<br>
inserted into the buffer to keep the cursor position. At the moment I create one marker for every window, which is most probably unnecessary and can be removed.</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Note that the version deletes all content of a file in case of an error (for example, when the cursor is past the end of the file), so I wouldn't point melpa at it yet.<div>I'm working on an improved version.</div><br><div class="gmail_quote">On Thu Jan 08 2015 at 4:32:22 PM Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>+cfe-commits (please do not cut that out during code review, the list is the source of truth for code reviews)<br></div><div><br></div>Landed as r225447. Note that I'm planning to adapt it soon to not replace the whole buffer, but just apply the diffs (I'll cc' you on the patch for review, unless you object :)<div><br></div><div>Cheers & thx!</div><div></div><div>/Manuel</div><div><br><div><br><div class="gmail_quote">On Wed Jan 07 2015 at 6:06:08 PM Johann Klähn <<a href="mailto:kljohann@gmail.com" target="_blank">kljohann@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Jan 7, 2015 at 5:14 PM, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
> +If called interactively uses the region or the current buffer if there<br>
> +is no active region.  If no style is given uses `clang-format-style'."<br>
><br>
> Doing full-buffer if nothing is selected is a usability problem if one works<br>
> in an existing codebase; if no region is selected, it should just use the<br>
> cursor position (which will get the current statement reflowed).<br>
> The idea is that the user can do clang-format-buffer if they insist.<br>
Excellent point.<br>
<br>
> +(put 'clang-format-executable 'risky-local-variable t)<br>
><br>
> Any reason not to use :risky in the defcustom?<br>
Oh, I thought I already did so. I must have accidently reverted that change.<br>
<br>
Thanks for your feedback, find attached an updated patch.<br>
</blockquote></div></div></div></blockquote></div>
</div>