comparison clang-tools-extra/clang-include-fixer/tool/clang-include-fixer.el @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents 1d019706d866
children
comparison
equal deleted inserted replaced
237:c80f45b162ad 252:1f2b6ac9f198
166 "Return a process sentinel for clang-include-fixer processes. 166 "Return a process sentinel for clang-include-fixer processes.
167 STDIN, STDOUT, and STDERR are buffers for the standard streams; 167 STDIN, STDOUT, and STDERR are buffers for the standard streams;
168 only STDERR may be nil. CALLBACK is called in the case of 168 only STDERR may be nil. CALLBACK is called in the case of
169 success; it is called with a single argument, STDOUT. On 169 success; it is called with a single argument, STDOUT. On
170 failure, a buffer containing the error output is displayed." 170 failure, a buffer containing the error output is displayed."
171 (cl-check-type stdin buffer-live) 171 (cl-check-type stdin buffer)
172 (cl-check-type stdout buffer-live) 172 (cl-check-type stdout buffer)
173 (cl-check-type stderr (or null buffer-live)) 173 (cl-check-type stderr (or null buffer))
174 (cl-check-type callback function) 174 (cl-check-type callback function)
175 (lambda (process event) 175 (lambda (process event)
176 (cl-check-type process process) 176 (cl-check-type process process)
177 (cl-check-type event string) 177 (cl-check-type event string)
178 (unwind-protect 178 (unwind-protect
190 (display-buffer (or stderr stdout)))) 190 (display-buffer (or stderr stdout))))
191 nil)) 191 nil))
192 192
193 (defun clang-include-fixer--replace-buffer (stdout) 193 (defun clang-include-fixer--replace-buffer (stdout)
194 "Replace current buffer by content of STDOUT." 194 "Replace current buffer by content of STDOUT."
195 (cl-check-type stdout buffer-live) 195 (cl-check-type stdout buffer)
196 (barf-if-buffer-read-only) 196 (barf-if-buffer-read-only)
197 (cond ((fboundp 'replace-buffer-contents) (replace-buffer-contents stdout)) 197 (cond ((fboundp 'replace-buffer-contents) (replace-buffer-contents stdout))
198 ((clang-include-fixer--insert-line stdout (current-buffer))) 198 ((clang-include-fixer--insert-line stdout (current-buffer)))
199 (t (erase-buffer) (insert-buffer-substring stdout))) 199 (t (erase-buffer) (insert-buffer-substring stdout)))
200 (message "Fix applied") 200 (message "Fix applied")
205 FROM and TO must be buffers. If the contents of FROM and TO are 205 FROM and TO must be buffers. If the contents of FROM and TO are
206 equal, do nothing and return non-nil. If FROM contains a single 206 equal, do nothing and return non-nil. If FROM contains a single
207 line missing from TO, insert that line into TO so that the buffer 207 line missing from TO, insert that line into TO so that the buffer
208 contents are equal and return non-nil. Otherwise, do nothing and 208 contents are equal and return non-nil. Otherwise, do nothing and
209 return nil. Buffer restrictions are ignored." 209 return nil. Buffer restrictions are ignored."
210 (cl-check-type from buffer-live) 210 (cl-check-type from buffer)
211 (cl-check-type to buffer-live) 211 (cl-check-type to buffer)
212 (with-current-buffer from 212 (with-current-buffer from
213 (save-excursion 213 (save-excursion
214 (save-restriction 214 (save-restriction
215 (widen) 215 (widen)
216 (with-current-buffer to 216 (with-current-buffer to