werbitt updated this revision to Diff 115827. werbitt added a comment. Clean up call-process-region
- Quote call-process-region with #', this will cause a compile time error if call-process-region is undefined - Pass positional arguments normally (exclude from the list) - Instead of using append use a backquoted list - Use ,@ to splice the assume file logic into the list - Use 'and' instead of 'if' 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 @@ -147,16 +147,15 @@ ;; 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 (apply 'call-process-region - (append `(nil nil ,clang-format-executable - nil (,temp-buffer ,temp-file) nil) - '("-output-replacements-xml") - (if assume-file - `("-assume-filename" ,assume-file) nil) - `("-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" + ,@(and assume-file (list "-assume-filename" assume-file)) + "-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 ": "))
Index: tools/clang-format/clang-format.el =================================================================== --- tools/clang-format/clang-format.el +++ tools/clang-format/clang-format.el @@ -147,16 +147,15 @@ ;; 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 (apply 'call-process-region - (append `(nil nil ,clang-format-executable - nil (,temp-buffer ,temp-file) nil) - '("-output-replacements-xml") - (if assume-file - `("-assume-filename" ,assume-file) nil) - `("-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" + ,@(and assume-file (list "-assume-filename" assume-file)) + "-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 ": "))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits