[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-29 Thread Philipp via Phabricator via cfe-commits
phst added inline comments.



Comment at: tools/clang-format/clang-format.el:122
 ;;;###autoload
-(defun clang-format-region (start end &optional style assume-file-name)
-  "Use clang-format to format the code between START and END according to STYLE
-using ASSUME-FILE-NAME to locate a style config file. If called interactively
-uses the region or the current statement if there is no active region. If no
-style is given uses `clang-format-style'. If no assume-file-name is given uses
-`buffer-file-name'."
+(defun clang-format-region (start end &optional style)
+  "Use clang-format to format the code between START and END according to 
STYLE.

Hmm, somehow your patch got reverted?


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-10-03 Thread Philipp via Phabricator via cfe-commits
phst accepted this revision.
phst added inline comments.



Comment at: tools/clang-format/clang-format.el:126
+no active region. If no style is given uses `clang-format-style'. Use
+ASSUME-FILE-NAME to locate a style config file, if no  assume-file-name is 
given
+uses the function `buffer-file-name'."

nit: write arguments in docstrings always in caps: ASSUME-FILE-NAME



Comment at: tools/clang-format/clang-format.el:197
+If no style is given uses `clang-format-style'. Use ASSUME-FILE-NAME
+to locate a style config file. If no assume-file-name is given uses
+the function `buffer-file-name'."

Write the argument in the docstring as ASSUME-FILE-NAME


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43969: Improve completion experience for headers

2018-03-01 Thread Philipp via Phabricator via cfe-commits
phst created this revision.
phst added a reviewer: klimek.
Herald added a subscriber: cfe-commits.

When calling `completing-read', we should provide a default to prevent the 
behavior described in 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
  Also, don't use an assertion to check whether the user selected a header; 
raise a proper signal instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43969

Files:
  include-fixer/tool/clang-include-fixer.el
  tools/
  tools/clang-format/


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43969: Improve completion experience for headers

2018-03-01 Thread Philipp via Phabricator via cfe-commits
phst updated this revision to Diff 136597.
phst added a comment.

Revert bogus additions


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43969

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43969: Improve completion experience for headers

2018-03-01 Thread Philipp via Phabricator via cfe-commits
phst updated this revision to Diff 136598.
phst added a comment.

Fix condition


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43969

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless info (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless info (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54672: clang-include-fixer.el: support remote files

2018-11-17 Thread Philipp via Phabricator via cfe-commits
phst created this revision.
phst added a reviewer: klimek.
Herald added a subscriber: cfe-commits.

Support remote files (e.g., Tramp) in the Emacs integration for 
clang-include-fixer


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54672

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -93,8 +93,12 @@
 buffer as only argument."
   (unless buffer-file-name
 (user-error "clang-include-fixer works only in buffers that visit a file"))
-  (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+  (let ((process (if (and (fboundp 'make-process)
+  ;; ‘make-process’ doesn’t support remote files
+  ;; 
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+  (not (find-file-name-handler default-directory
+   'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
  ;; ‘start-process’ doesn’t allow us to separate the
  ;; standard error from the output.
  (clang-include-fixer--make-process callback args)
@@ -125,15 +129,15 @@
   :stderr stderr)))
 
 (defun clang-include-fixer--start-process (callback args)
-  "Start a new clang-incude-fixer process using `start-process'.
+  "Start a new clang-incude-fixer process using `start-file-process'.
 CALLBACK is called after the process finishes successfully; it is
 called with a single argument, the buffer where standard output
 has been inserted.  ARGS is a list of additional command line
 arguments.  Return the new process object."
   (let* ((stdin (current-buffer))
  (stdout (generate-new-buffer "*clang-include-fixer output*"))
  (process-connection-type nil)
- (process (apply #'start-process "clang-include-fixer" stdout
+ (process (apply #'start-file-process "clang-include-fixer" stdout
  (clang-include-fixer--command args
 (set-process-coding-system process 'utf-8-unix 'utf-8-unix)
 (set-process-query-on-exit-flag process nil)
@@ -156,7 +160,7 @@
 ,(format "-input=%s" clang-include-fixer-init-string)
 "-stdin"
 ,@args
-,(buffer-file-name)))
+,(clang-include-fixer--file-local-name buffer-file-name)))
 
 (defun clang-include-fixer--sentinel (stdin stdout stderr callback)
   "Return a process sentinel for clang-include-fixer processes.
@@ -446,5 +450,11 @@
 (defalias 'clang-include-fixer--format-message
   (if (fboundp 'format-message) 'format-message 'format))
 
+;; ‘file-local-name’ is new in Emacs 26.1.  Provide a fallback for older
+;; versions.
+(defalias 'clang-include-fixer--file-local-name
+  (if (fboundp 'file-local-name) #'file-local-name
+(lambda (file) (or (file-remote-p file 'localname) file
+
 (provide 'clang-include-fixer)
 ;;; clang-include-fixer.el ends here


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -93,8 +93,12 @@
 buffer as only argument."
   (unless buffer-file-name
 (user-error "clang-include-fixer works only in buffers that visit a file"))
-  (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+  (let ((process (if (and (fboundp 'make-process)
+  ;; ‘make-process’ doesn’t support remote files
+  ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+  (not (find-file-name-handler default-directory
+   'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
  ;; ‘start-process’ doesn’t allow us to separate the
  ;; standard error from the output.
  (clang-include-fixer--make-process callback args)
@@ -125,15 +129,15 @@
   :stderr stderr)))
 
 (defun clang-include-fixer--start-process (callback args)
-  "Start a new clang-incude-fixer process using `start-process'.
+  "Start a new clang-incude-fixer process using `start-file-process'.
 CALLBACK is called after the process finishes successfully; it is
 called with a single argument, the buffer where standard output
 has been inserted.  ARGS is a list of additional command line
 arguments.  Return the new process object."
   (let* ((stdin (current-buffer))
  (stdout (generate-new-buffer "*clang-include-fixer output*"))
  (process-connection-type nil)
- (process (apply #'star

[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-18 Thread Philipp via Phabricator via cfe-commits
phst added a comment.

Thanks, generally looks good, but a couple of notes:

- This is actually a bug in clang-format, which can easily be triggered with 
`clang-format -output-replacements-xml -assume-filename '' -offset 0 -length 10 
-cursor 5 <<< ' = 1234;'`

  It's fine to work around bugs, but please file a bug against clang-format 
itself and reference it in a comment.

- Not sure whether the `assume-filename` parameter is actually needed. If 
there's no known use case, please don't add it ("YAGNI").

- Prefer quoting function symbols with `#'`: `#'call-process-region`. The 
byte-compiler will then warn if such a symbol is not defined as a function.

- It's more readable to write the non-varying arguments to call-process-region 
as direct arguments to `apply`, like so: `(apply #'call-process-region nil ... 
nil (append '("-output-replacements ...`. The result is equivalent, but this 
structure makes it more obvious which arguments are positional and which are 
rest arguments.

- You can combine the various lists with backquotes and get rid of `append`: 
``("-output-replacements-xml" ,@(and buffer-file-name (list (concat 
"-assume-filename=" buffer-file-name))) "-style" ...)`


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-19 Thread Philipp via Phabricator via cfe-commits
phst added inline comments.



Comment at: tools/clang-format/clang-format.el:125
 If called interactively uses the region or the current statement if there
 is no active region.  If no style is given uses `clang-format-style'."
   (interactive

Please document the ASSUME-FILE parameter.



Comment at: tools/clang-format/clang-format.el:187
 ;;;###autoload
-(defun clang-format-buffer (&optional style)
+(defun clang-format-buffer (&optional style assume-file)
   "Use clang-format to format the current buffer according to STYLE."

Nit: consider renaming the parameter to ASSUME-FILENAME so that it's clear that 
it's a filename. Same above.



Comment at: tools/clang-format/clang-format.el:188
+(defun clang-format-buffer (&optional style assume-file)
   "Use clang-format to format the current buffer according to STYLE."
   (interactive)

Please document the new parameter here as well.


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-19 Thread Philipp via Phabricator via cfe-commits
phst accepted this revision.
phst added a comment.
This revision is now accepted and ready to land.

Your use case sounds good to me. Please be sure to document the new parameter, 
though.




Comment at: tools/clang-format/clang-format.el:154
+ `("-output-replacements-xml"
+   ,@(and assume-file (list "-assume-filename" 
assume-file))
+   "-style" ,style

Please add a comment referencing the LLVM bug you've just filed so that others 
aren't surprised about this.


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-09-25 Thread Philipp via Phabricator via cfe-commits
phst added inline comments.



Comment at: tools/clang-format/clang-format.el:123
+(defun clang-format-region (start end &optional style assume-file-name)
+  "Use clang-format to format the code between START and END according to STYLE
+using ASSUME-FILE-NAME to locate a style config file. If called interactively

Please stick to the canonical format, i.e. the first line should be a complete 
sentence. See 
https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tips.html.
 You can use M-x checkdoc to detect such style issues automatically.
Here I'd just leave the docstring intact and add another sentence describing 
ASSUME-FILE-NAME at the end.



Comment at: tools/clang-format/clang-format.el:157
+   ;; Gaurd against a nil assume-file-name.
+   ;; If -assume-filename is given a blank string
+   ;; it will crash as per the following bug report

nit: "-assume-file-name"



Comment at: tools/clang-format/clang-format.el:194
+(defun clang-format-buffer (&optional style assume-file-name)
+  "Use clang-format to format the current buffer according to STYLE using
+ASSUME-FILE-NAME to locate a style config file. If no style is given uses

Same here, please make the first line a complete sentence.


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54672: clang-include-fixer.el: support remote files

2018-12-14 Thread Philipp via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE349150: clang-include-fixer.el: support remote files 
(authored by phst, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54672?vs=174522&id=178227#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54672/new/

https://reviews.llvm.org/D54672

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -93,8 +93,12 @@
 buffer as only argument."
   (unless buffer-file-name
 (user-error "clang-include-fixer works only in buffers that visit a file"))
-  (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+  (let ((process (if (and (fboundp 'make-process)
+  ;; ‘make-process’ doesn’t support remote files
+  ;; 
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+  (not (find-file-name-handler default-directory
+   'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
  ;; ‘start-process’ doesn’t allow us to separate the
  ;; standard error from the output.
  (clang-include-fixer--make-process callback args)
@@ -125,7 +129,7 @@
   :stderr stderr)))
 
 (defun clang-include-fixer--start-process (callback args)
-  "Start a new clang-incude-fixer process using `start-process'.
+  "Start a new clang-incude-fixer process using `start-file-process'.
 CALLBACK is called after the process finishes successfully; it is
 called with a single argument, the buffer where standard output
 has been inserted.  ARGS is a list of additional command line
@@ -133,7 +137,7 @@
   (let* ((stdin (current-buffer))
  (stdout (generate-new-buffer "*clang-include-fixer output*"))
  (process-connection-type nil)
- (process (apply #'start-process "clang-include-fixer" stdout
+ (process (apply #'start-file-process "clang-include-fixer" stdout
  (clang-include-fixer--command args
 (set-process-coding-system process 'utf-8-unix 'utf-8-unix)
 (set-process-query-on-exit-flag process nil)
@@ -156,7 +160,7 @@
 ,(format "-input=%s" clang-include-fixer-init-string)
 "-stdin"
 ,@args
-,(buffer-file-name)))
+,(clang-include-fixer--file-local-name buffer-file-name)))
 
 (defun clang-include-fixer--sentinel (stdin stdout stderr callback)
   "Return a process sentinel for clang-include-fixer processes.
@@ -446,5 +450,11 @@
 (defalias 'clang-include-fixer--format-message
   (if (fboundp 'format-message) 'format-message 'format))
 
+;; ‘file-local-name’ is new in Emacs 26.1.  Provide a fallback for older
+;; versions.
+(defalias 'clang-include-fixer--file-local-name
+  (if (fboundp 'file-local-name) #'file-local-name
+(lambda (file) (or (file-remote-p file 'localname) file
+
 (provide 'clang-include-fixer)
 ;;; clang-include-fixer.el ends here


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -93,8 +93,12 @@
 buffer as only argument."
   (unless buffer-file-name
 (user-error "clang-include-fixer works only in buffers that visit a file"))
-  (let ((process (if (fboundp 'make-process)
- ;; Prefer using ‘make-process’ if available, because
+  (let ((process (if (and (fboundp 'make-process)
+  ;; ‘make-process’ doesn’t support remote files
+  ;; (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28691).
+  (not (find-file-name-handler default-directory
+   'start-file-process)))
+ ;; Prefer using ‘make-process’ if possible, because
  ;; ‘start-process’ doesn’t allow us to separate the
  ;; standard error from the output.
  (clang-include-fixer--make-process callback args)
@@ -125,7 +129,7 @@
   :stderr stderr)))
 
 (defun clang-include-fixer--start-process (callback args)
-  "Start a new clang-incude-fixer process using `start-process'.
+  "Start a new clang-incude-fixer process using `start-file-process'.
 CALLBACK is called after the process finishes successfully; it is
 called with a single argument, the buffer where standard output
 has been inserted.  ARGS is a list of additional command line
@@ -133,7 +137,7 @@
   (let* ((stdin (current-buffer))
  (stdout (generate-new-buffer "*clang-inc

[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-12-02 Thread Philipp via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC319621: Fix assume-filename handling in clang-format.el 
(authored by phst).

Changed prior to commit:
  https://reviews.llvm.org/D37903?vs=124242&id=125274#toc

Repository:
  rC Clang

https://reviews.llvm.org/D37903

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


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,18 +119,23 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file-name)
   "Use clang-format to format the code between START and END according to 
STYLE.
-If called interactively uses the region or the current statement if there
-is no active region.  If no style is given uses `clang-format-style'."
+If called interactively uses the region or the current statement if there is no
+no active region. If no STYLE is given uses `clang-format-style'. Use
+ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
+uses the function `buffer-file-name'."
   (interactive
(if (use-region-p)
(list (region-beginning) (region-end))
  (list (point) (point
 
   (unless style
 (setq style clang-format-style))
 
+  (unless assume-file-name
+(setq assume-file-name buffer-file-name))
+
   (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
 'utf-8-unix))
 (file-end (clang-format--bufferpos-to-filepos end 'approximate
@@ -144,16 +149,21 @@
 ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
 (default-process-coding-system '(utf-8-unix . utf-8-unix)))
 (unwind-protect
-(let ((status (call-process-region
-   nil nil clang-format-executable
-   nil `(,temp-buffer ,temp-file) nil
-
-   "-output-replacements-xml"
-   "-assume-filename" (or (buffer-file-name) "")
-   "-style" style
-   "-offset" (number-to-string file-start)
-   "-length" (number-to-string (- file-end file-start))
-   "-cursor" (number-to-string cursor)))
+(let ((status (apply #'call-process-region
+ nil nil clang-format-executable
+ nil `(,temp-buffer ,temp-file) nil
+ `("-output-replacements-xml"
+   ;; Gaurd against a nil assume-file-name.
+   ;; If the clang-format option -assume-filename
+   ;; is given a blank string it will crash as per
+   ;; the following bug report
+   ;; https://bugs.llvm.org/show_bug.cgi?id=34667
+   ,@(and assume-file-name
+  (list "-assume-filename" 
assume-file-name))
+   "-style" ,style
+   "-offset" ,(number-to-string file-start)
+   "-length" ,(number-to-string (- file-end 
file-start))
+   "-cursor" ,(number-to-string cursor
   (stderr (with-temp-buffer
 (unless (zerop (cadr (insert-file-contents temp-file)))
   (insert ": "))
@@ -181,10 +191,13 @@
   (when (buffer-name temp-buffer) (kill-buffer temp-buffer)
 
 ;;;###autoload
-(defun clang-format-buffer (&optional style)
-  "Use clang-format to format the current buffer according to STYLE."
+(defun clang-format-buffer (&optional style assume-file-name)
+  "Use clang-format to format the current buffer according to STYLE.
+If no STYLE is given uses `clang-format-style'. Use ASSUME-FILE-NAME
+to locate a style config file. If no ASSUME-FILE-NAME is given uses
+the function `buffer-file-name'."
   (interactive)
-  (clang-format-region (point-min) (point-max) style))
+  (clang-format-region (point-min) (point-max) style assume-file-name))
 
 ;;;###autoload
 (defalias 'clang-format 'clang-format-region)


Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el
+++ tools/clang-format/clang-format.el
@@ -119,18 +119,23 @@
   (byte-to-position (1+ byte)
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file-name)
   "Use clang-format to format the code between START and END according to STYLE.
-If called interactively uses the region or the current statement if there
-is no active region.  If no style is given uses `clang-format-style'

[PATCH] D43969: Improve completion experience for headers

2018-04-09 Thread Philipp via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329566: Improve completion experience for headers (authored 
by phst, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43969

Files:
  clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el


Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless info (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
===
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless info (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-11-20 Thread Philipp via Phabricator via cfe-commits
phi added a comment.

Hi, do you need anything more from us? This patch looks fine and can be 
submitted.


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37903: Fix assume-filename handling in clang-format.el

2017-11-20 Thread Philipp via Phabricator via cfe-commits
phi added a comment.

The patch doesn't apply any more to upstream head:

  $ arc patch D37903
  patching file tools/clang-format/clang-format.el
  Hunk #1 FAILED at 122.
  Hunk #2 FAILED at 193.

Could you please rebase it?


https://reviews.llvm.org/D37903



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143560: clang-format.el: fix warnings

2023-02-08 Thread Philipp via Phabricator via cfe-commits
phst requested changes to this revision.
phst added inline comments.
This revision now requires changes to proceed.



Comment at: clang/tools/clang-format/clang-format.el:70
   (cl-case (xml-node-name node)
-('replacement
+((replacement quote)
  (let* ((offset (xml-get-attribute-or-nil node 'offset))

what's the change here?



Comment at: clang/tools/clang-format/clang-format.el:80
(push (list offset length text) replacements)))
-('cursor
+((cursor quote)
  (setq cursor (string-to-number text)))

same here, what is being changed?



Comment at: clang/tools/clang-format/clang-format.el:85
  (lambda (a b)
(or (> (car a) (car b))
(and (= (car a) (car b))

The intention here is that this should be just `replacement' since I'm pretty 
sure we don't have XML tags like 



Comment at: clang/tools/clang-format/clang-format.el:96
  'utf-8-unix)))
 (goto-char start)
 (delete-region start end)

same here, AIUI this should just be `quote'


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143560/new/

https://reviews.llvm.org/D143560

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143560: clang-format.el: fix warnings

2023-02-24 Thread Philipp via Phabricator via cfe-commits
phst added a comment.

I'm not super familiar with the process either, but IIRC @sammccall or @djasper 
have to merge this.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143560/new/

https://reviews.llvm.org/D143560

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148918: [Test] Regenerate checks using update_test_checks.py

2023-04-21 Thread Philipp via Phabricator via cfe-commits
phst updated this revision to Diff 515695.
phst added a comment.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

- Check for a ‘buffer’ type instead of ‘buffer-live’.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148918/new/

https://reviews.llvm.org/D148918

Files:
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
  llvm/test/Transforms/Util/flattencfg.ll

Index: llvm/test/Transforms/Util/flattencfg.ll
===
--- llvm/test/Transforms/Util/flattencfg.ll
+++ llvm/test/Transforms/Util/flattencfg.ll
@@ -1,11 +1,27 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
 ; RUN: opt -passes=flattencfg -S < %s | FileCheck %s
 
 
 ; This test checks whether the pass completes without a crash.
 ; The code is not transformed in any way
-;
-; CHECK-LABEL: @test_not_crash
 define void @test_not_crash(i32 %in_a) #0 {
+; CHECK-LABEL: define void @test_not_crash
+; CHECK-SAME: (i32 [[IN_A:%.*]]) {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1
+; CHECK-NEXT:[[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0
+; CHECK-NEXT:[[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]]
+; CHECK-NEXT:br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]]
+; CHECK:   b0:
+; CHECK-NEXT:[[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0
+; CHECK-NEXT:[[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1
+; CHECK-NEXT:[[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]]
+; CHECK-NEXT:br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]]
+; CHECK:   b1:
+; CHECK-NEXT:br label [[EXIT]]
+; CHECK:   exit:
+; CHECK-NEXT:ret void
+;
 entry:
   %cmp0 = icmp eq i32 %in_a, -1
   %cmp1 = icmp ne i32 %in_a, 0
@@ -25,17 +41,19 @@
   ret void
 }
 
-; CHECK-LABEL: @test_not_crash2
+define void @test_not_crash2(float %a, float %b) #0 {
+; CHECK-LABEL: define void @test_not_crash2
+; CHECK-SAME: (float [[A:%.*]], float [[B:%.*]]) {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:%0 = fcmp ult float %a
-; CHECK-NEXT:%1 = fcmp ult float %b
-; CHECK-NEXT:[[COND:%[a-z0-9]+]] = and i1 %0, %1
-; CHECK-NEXT:br i1 [[COND]], label %bb4, label %bb3
+; CHECK-NEXT:[[TMP0:%.*]] = fcmp ult float [[A]], 1.00e+00
+; CHECK-NEXT:[[TMP1:%.*]] = fcmp ult float [[B]], 1.00e+00
+; CHECK-NEXT:[[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]]
+; CHECK-NEXT:br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]]
 ; CHECK:   bb3:
-; CHECK-NEXT:br label %bb4
+; CHECK-NEXT:br label [[BB4]]
 ; CHECK:   bb4:
 ; CHECK-NEXT:ret void
-define void @test_not_crash2(float %a, float %b) #0 {
+;
 entry:
   %0 = fcmp ult float %a, 1.00e+00
   br i1 %0, label %bb0, label %bb1
@@ -54,18 +72,20 @@
   br i1 %1, label %bb4, label %bb3
 }
 
-; CHECK-LABEL: @test_not_crash3
+define void @test_not_crash3(i32 %a) #0 {
+; CHECK-LABEL: define void @test_not_crash3
+; CHECK-SAME: (i32 [[A:%.*]]) {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:%a_eq_0 = icmp eq i32 %a, 0
-; CHECK-NEXT:%a_eq_1 = icmp eq i32 %a, 1
-; CHECK-NEXT:[[COND:%[a-z0-9]+]] = or i1 %a_eq_0, %a_eq_1
-; CHECK-NEXT:br i1 [[COND]], label %bb2, label %bb3
+; CHECK-NEXT:[[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0
+; CHECK-NEXT:[[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1
+; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]]
+; CHECK-NEXT:br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]]
 ; CHECK:   bb2:
-; CHECK-NEXT:br label %bb3
+; CHECK-NEXT:br label [[BB3]]
 ; CHECK:   bb3:
-; CHECK-NEXT:%check_badref = phi i32 [ 17, %entry ], [ 11, %bb2 ]
+; CHECK-NEXT:[[CHECK_BADREF:%.*]] = phi i32 [ 17, [[ENTRY:%.*]] ], [ 11, [[BB2]] ]
 ; CHECK-NEXT:ret void
-define void @test_not_crash3(i32 %a) #0 {
+;
 entry:
   %a_eq_0 = icmp eq i32 %a, 0
   br i1 %a_eq_0, label %bb0, label %bb1
@@ -88,18 +108,20 @@
 
 @g = global i32 0, align 4
 
-; CHECK-LABEL: @test_then
+define void @test_then(i32 %x, i32 %y, i32 %z) {
+; CHECK-LABEL: define void @test_then
+; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {
 ; CHECK-NEXT:  entry.x:
-; CHECK-NEXT:%cmp.x = icmp ne i32 %x, 0
-; CHECK-NEXT:%cmp.y = icmp ne i32 %y, 0
-; CHECK-NEXT:[[COND:%[a-z0-9]+]] = or i1 %cmp.x, %cmp.y
-; CHECK-NEXT:br i1 [[COND]], label %if.then.y, label %exit
+; CHECK-NEXT:[[CMP_X:%.*]] = icmp ne i32 [[X]], 0
+; CHECK-NEXT:[[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0
+; CHECK-NEXT:[[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]]
+; CHECK-NEXT:br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]]
 ; CHECK:   if.then.y:
-; CHECK-NEXT:store i32 %z, ptr @g, align 4
-; CHECK-NEXT:br label %exit
+; CHECK-NEXT:store i32 [[Z]], ptr @g, align 4
+; CHECK-NEXT:br label [[EXIT]]
 ; CHECK:   exit:
 ; CHECK-NEXT:ret void
-define void @test_then(i32 %x, i32 %y, i32 %z) {
+;
 entry.x:
   %cmp.x = icmp ne i32 %x, 0
   br i1 %cmp.x, label %if.th

[PATCH] D148918: [Test] Regenerate checks using update_test_checks.py

2023-04-21 Thread Philipp via Phabricator via cfe-commits
phst updated this revision to Diff 515697.
phst added a comment.

Check for a ‘buffer’ type instead of ‘buffer-live’.

In Emacs 29, ‘buffer-live’ is no longer recognized as a type and generates a
compilation warning.  Every function that requires a live buffer already checks
whether the buffer is live, so we don’t need to check ourselves.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148918/new/

https://reviews.llvm.org/D148918

Files:
  clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
@@ -168,9 +168,9 @@
 only STDERR may be nil.  CALLBACK is called in the case of
 success; it is called with a single argument, STDOUT.  On
 failure, a buffer containing the error output is displayed."
-  (cl-check-type stdin buffer-live)
-  (cl-check-type stdout buffer-live)
-  (cl-check-type stderr (or null buffer-live))
+  (cl-check-type stdin buffer)
+  (cl-check-type stdout buffer)
+  (cl-check-type stderr (or null buffer))
   (cl-check-type callback function)
   (lambda (process event)
 (cl-check-type process process)
@@ -192,7 +192,7 @@
 
 (defun clang-include-fixer--replace-buffer (stdout)
   "Replace current buffer by content of STDOUT."
-  (cl-check-type stdout buffer-live)
+  (cl-check-type stdout buffer)
   (barf-if-buffer-read-only)
   (cond ((fboundp 'replace-buffer-contents) (replace-buffer-contents stdout))
 ((clang-include-fixer--insert-line stdout (current-buffer)))
@@ -207,8 +207,8 @@
 line missing from TO, insert that line into TO so that the buffer
 contents are equal and return non-nil.  Otherwise, do nothing and
 return nil.  Buffer restrictions are ignored."
-  (cl-check-type from buffer-live)
-  (cl-check-type to buffer-live)
+  (cl-check-type from buffer)
+  (cl-check-type to buffer)
   (with-current-buffer from
 (save-excursion
   (save-restriction


Index: clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
===
--- clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
+++ clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el
@@ -168,9 +168,9 @@
 only STDERR may be nil.  CALLBACK is called in the case of
 success; it is called with a single argument, STDOUT.  On
 failure, a buffer containing the error output is displayed."
-  (cl-check-type stdin buffer-live)
-  (cl-check-type stdout buffer-live)
-  (cl-check-type stderr (or null buffer-live))
+  (cl-check-type stdin buffer)
+  (cl-check-type stdout buffer)
+  (cl-check-type stderr (or null buffer))
   (cl-check-type callback function)
   (lambda (process event)
 (cl-check-type process process)
@@ -192,7 +192,7 @@
 
 (defun clang-include-fixer--replace-buffer (stdout)
   "Replace current buffer by content of STDOUT."
-  (cl-check-type stdout buffer-live)
+  (cl-check-type stdout buffer)
   (barf-if-buffer-read-only)
   (cond ((fboundp 'replace-buffer-contents) (replace-buffer-contents stdout))
 ((clang-include-fixer--insert-line stdout (current-buffer)))
@@ -207,8 +207,8 @@
 line missing from TO, insert that line into TO so that the buffer
 contents are equal and return non-nil.  Otherwise, do nothing and
 return nil.  Buffer restrictions are ignored."
-  (cl-check-type from buffer-live)
-  (cl-check-type to buffer-live)
+  (cl-check-type from buffer)
+  (cl-check-type to buffer)
   (with-current-buffer from
 (save-excursion
   (save-restriction
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148918: Check for a ‘buffer’ type instead of ‘buffer-live’.

2023-04-21 Thread Philipp via Phabricator via cfe-commits
phst added a comment.

Thanks for the review! I think you also need to land it (I don't seem to have 
the necessary permissions).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148918/new/

https://reviews.llvm.org/D148918

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2022-02-23 Thread Philipp via Phabricator via cfe-commits
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))


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))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2022-02-23 Thread Philipp via Phabricator via cfe-commits
phst added a comment.

Thanks for the review! I think you have to commit this (I don't have commit 
access).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120408/new/

https://reviews.llvm.org/D120408

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits