================ @@ -312,15 +335,35 @@ diffs from HEAD in the buffer. If no STYLE is given uses file. If no ASSUME-FILE-NAME is given uses the function ‘buffer-file-name’." (interactive) - (let ((diff-lines (clang-format--vc-diff-get-diff-lines))) - ;; If we have any diffs, format them. - (when diff-lines - (clang-format--region-impl - (point-min) - (point-max) - style - assume-file-name - diff-lines)))) + (let ((tmpfile-vc-head nil) + (tmpfile-curbuf nil)) + (unwind-protect ---------------- ideasman42 wrote:
\*picky\* I find it often works better to wrap `unwind-protect` in a macro. Example usage ``` (clang-format--with-delete-files-guard files-to-delete ... snip ... (push (setq tmpfile-curbuf (make-temp-file "clang-format-vc-tmp")) temp-files) (push tmpfile-curbuf temp-files)) ```k Here is a macro that does this: ``` (defmacro clang-format--with-advice (bind-files-to-delete &rest body) "Execute BODY which may add temp files to BIND-FILES-TO-DELETE." (declare (indent 1)) `(let ((,bind-files-to-delete nil)) (unwind-protect (progn ,@body) (while ,bind-files-to-delete (with-demoted-errors "failed to remove file: %S" (delete-file (pop ,bind-files-to-delete))))))) ``` https://github.com/llvm/llvm-project/pull/112792 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits