[PATCH] D120408: clang-format.el: Make clang-format work in indirect buffers.

Philipp via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 23 06:07:23 PST 2022


phst created this revision.
phst added a reviewer: sammccall.
phst requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In an indirect buffer, buffer-file-name is nil, so check the base buffer
instead.  This works fine in direct buffers where buffer-base-buffer returns
nil.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120408

Files:
  clang/tools/clang-format/clang-format.el


Index: clang/tools/clang-format/clang-format.el
===================================================================
--- clang/tools/clang-format/clang-format.el
+++ clang/tools/clang-format/clang-format.el
@@ -147,7 +147,7 @@
     (setq style clang-format-style))
 
   (unless assume-file-name
-    (setq assume-file-name buffer-file-name))
+    (setq assume-file-name (buffer-file-name (buffer-base-buffer))))
 
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
                                                         'utf-8-unix))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120408.410793.patch
Type: text/x-patch
Size: 560 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220223/77aa9ba7/attachment-0001.bin>


More information about the cfe-commits mailing list