[clang-tools-extra] r349150 - clang-include-fixer.el: support remote files

2018-12-14 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Fri Dec 14 05:56:05 2018
New Revision: 349150

URL: http://llvm.org/viewvc/llvm-project?rev=349150&view=rev
Log:
clang-include-fixer.el: support remote files

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

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D54672

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

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=349150&r1=349149&r2=349150&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Fri Dec 
14 05:56:05 2018
@@ -93,8 +93,12 @@ temporary buffer, and CALLBACK is called
 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 @@ arguments.  Return the new process objec
   :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 @@ arguments.  Return the new process objec
   (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 @@ file name; prepends ARGS directly in fro
 ,(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 @@ non-nil.  Otherwise return nil."
 (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


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


r319621 - Fix assume-filename handling in clang-format.el

2017-12-02 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Sat Dec  2 13:18:14 2017
New Revision: 319621

URL: http://llvm.org/viewvc/llvm-project?rev=319621&view=rev
Log:
Fix assume-filename handling in clang-format.el

Summary:
When 'buffer-file-name' is nil 'call-process-region' returned a segmentation 
fault error.

This was a problem when using clang-format-buffer on an orgmode source code 
editing buffer.

I fixed this problem by excluding the '-assume-filename' argument when 
'buffer-file-name' is nil.

To make it a bit more flexible I also added an optional argument, 
'assume-file-name', to specify an assume-filename that overrides 
'buffer-file-name'.

Reviewers: klimek, djasper, phst, phi

Reviewed By: phst, phi

Subscribers: phi, jholewinski, mgorny, javed.absar, eraman, cfe-commits

Differential Revision: https://reviews.llvm.org/D37903

Modified:
cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=319621&r1=319620&r2=319621&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Sat Dec  2 13:18:14 2017
@@ -119,10 +119,12 @@ is a zero-based file offset, assuming â
   (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))
@@ -131,6 +133,9 @@ is no active region.  If no style is giv
   (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 @@ is no active region.  If no style is giv
 ;; 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 @@ is no active region.  If no style is giv
   (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-NAM

[clang-tools-extra] r329566 - Improve completion experience for headers

2018-04-09 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Mon Apr  9 06:31:44 2018
New Revision: 329566

URL: http://llvm.org/viewvc/llvm-project?rev=329566&view=rev
Log:
Improve completion experience for headers

Summary: 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.

Reviewers: klimek

Reviewed By: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D43969

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

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=329566&r1=329565&r2=329566&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Mon Apr  
9 06:31:44 2018
@@ -314,14 +314,18 @@ They are replaced by the single element
   (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


Fix for https://llvm.org/bugs/show_bug.cgi?id=29073

2016-09-08 Thread Philipp Stephani via cfe-commits
Hi,

the attached patch fixes https://llvm.org/bugs/show_bug.cgi?id=29073.

Thanks,
Philipp
-- 

Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und
löschen Sie die E-Mail und alle Anhänge. Vielen Dank.

This e-mail is confidential. If you are not the right addressee please do
not forward it, please inform the sender, and please erase this e-mail
including any attachments. Thanks.
Index: tools/clang-format/clang-format.el
===
--- tools/clang-format/clang-format.el	(revision 280970)
+++ tools/clang-format/clang-format.el	(working copy)
@@ -122,7 +122,7 @@
 (let (status stderr operations)
   (setq status
 (call-process-region
- (point-min) (point-max) clang-format-executable
+ nil nil clang-format-executable
  nil `(,temp-buffer ,temp-file) nil
 
  "-output-replacements-xml"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Fixing some byte compilation warnings in utils/clang-completion-mode.el

2016-09-08 Thread Philipp Stephani via cfe-commits
Hi,

the following patch fixes a couple of byte compilation warnings in the
Emacs library utils/clang-completion-mode.el.

Thanks,
Philipp
-- 

Google Germany GmbH
Erika-Mann-Straße 33
80636 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den Absender und
löschen Sie die E-Mail und alle Anhänge. Vielen Dank.

This e-mail is confidential. If you are not the right addressee please do
not forward it, please inform the sender, and please erase this e-mail
including any attachments. Thanks.
Index: utils/clang-completion-mode.el
===
--- utils/clang-completion-mode.el	(revision 280970)
+++ utils/clang-completion-mode.el	(working copy)
@@ -64,15 +64,15 @@
   :group 'clang-completion-mode)
 
 ;;; The prefix header to use with Clang code completion. 
-(setq clang-completion-prefix-header "")
+(defvar clang-completion-prefix-header "")
 
 ;;; The substring we will use to filter completion results
-(setq clang-completion-substring "")
+(defvar clang-completion-substring "")
 
 ;;; The current completion buffer
-(setq clang-completion-buffer nil)
+(defvar clang-completion-buffer nil)
 
-(setq clang-result-string "")
+(defvar clang-result-string "")
 
 ;;; Compute the current line in the buffer	
 (defun current-line ()
@@ -199,7 +199,7 @@
 ;; for the currently-active code completion.
 (defun clang-backspace ()
   (interactive)
-  (delete-backward-char 1)
+  (delete-char -1)
   (clang-update-filter))
 
 ;; Invoked when the user types the delete key to update the filter
@@ -206,7 +206,7 @@
 ;; for the currently-active code completion.
 (defun clang-delete ()
   (interactive)
-  (delete-backward-char 1)
+  (delete-char -1)
   (clang-update-filter))
 
 ;; Set up the keymap for the Clang minor mode.
@@ -246,4 +246,3 @@
   nil
   " Clang"
   clang-completion-mode-map)
-
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r292234 - Make sure that clang-format input is in the right encoding

2017-01-17 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Tue Jan 17 11:30:55 2017
New Revision: 292234

URL: http://llvm.org/viewvc/llvm-project?rev=292234&view=rev
Log:
Make sure that clang-format input is in the right encoding

Summary: Add unit tests.

Reviewers: klimek, massberg

Reviewed By: massberg

Differential Revision: https://reviews.llvm.org/D28800

Added:
cfe/trunk/tools/clang-format/clang-format-test.el
Modified:
cfe/trunk/tools/clang-format/clang-format.el

Added: cfe/trunk/tools/clang-format/clang-format-test.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-test.el?rev=292234&view=auto
==
--- cfe/trunk/tools/clang-format/clang-format-test.el (added)
+++ cfe/trunk/tools/clang-format/clang-format-test.el Tue Jan 17 11:30:55 2017
@@ -0,0 +1,110 @@
+;;; clang-format-test.el --- unit tests for clang-format.el  -*- 
lexical-binding: t; -*-
+
+;; Copyright (C) 2017  Google Inc.
+
+;; Author: Philipp Stephani 
+
+;; This file is distributed under the University of Illinois Open Source
+;; License.  See LICENSE.TXT for details.
+
+;;; Commentary:
+
+;; Unit tests for clang-format.el.
+
+;;; Code:
+
+(require 'clang-format)
+
+(require 'cl-lib)
+(require 'ert)
+(require 'pcase)
+
+(ert-deftest clang-format-buffer--buffer-encoding ()
+  "Tests that encoded text is handled properly."
+  (cl-letf* ((call-process-args nil)
+ ((symbol-function 'call-process-region)
+  (lambda (&rest args)
+(push args call-process-args)
+(pcase-exhaustive args
+  (`(,_start ,_end ,_program ,_delete (,stdout ,_stderr)
+ ,_display . ,_args)
+   (with-current-buffer stdout
+ (insert "
+
+ 
+ 
+
+"))
+   0)
+(with-temp-buffer
+  (let ((buffer-file-name "foo.cpp")
+(buffer-file-coding-system 'utf-8-with-signature-dos)
+(default-process-coding-system 'latin-1-unix))
+(insert "ä =ö;\nü= ß;\n")
+(goto-char (point-min))
+(end-of-line)
+(clang-format-buffer))
+  (should (equal (buffer-string) "ä = ö;\nü = ß;\n"))
+  (should (eolp))
+  (should (equal (buffer-substring (point) (point-max))
+ "\nü = ß;\n")))
+(should-not (cdr call-process-args))
+(pcase-exhaustive call-process-args
+  (`((,start ,end ,_program ,delete (,_stdout ,_stderr) ,display . ,args))
+   (should-not start)
+   (should-not end)
+   (should-not delete)
+   (should-not display)
+   (should (equal args
+  '("-output-replacements-xml" "-assume-filename" "foo.cpp"
+"-style" "file"
+;; Length of the UTF-8 byte-order mark.
+"-offset" "3"
+;; We have two lines with 2×2 bytes for the umlauts,
+;; 2 bytes for the line ending, and 3 bytes for the
+;; other ASCII characters each.
+"-length" "18"
+;; Length of a single line (without line ending) plus
+;; BOM.
+"-cursor" "10")))
+
+(ert-deftest clang-format-buffer--process-encoding ()
+  "Tests that text is sent to the clang-format process in the
+right encoding."
+  (cl-letf* ((hexdump (executable-find "hexdump"))
+ (original-call-process-region
+  (symbol-function 'call-process-region))
+ (call-process-inputs nil)
+ ;; We redirect the input to hexdump so that we have guaranteed
+ ;; ASCII output.
+ ((symbol-function 'call-process-region)
+  (lambda (&rest args)
+(pcase-exhaustive args
+  (`(,start ,end ,_program ,_delete (,stdout ,_stderr)
+,_display . ,_args)
+   (with-current-buffer stdout
+ (insert "
+
+
+"))
+   (let ((stdin (current-buffer)))
+ (with-temp-buffer
+   (prog1
+   (let ((stdout (current-buffer)))
+ (with-current-buffer stdin
+   (funcall original-call-process-region
+start end hexdump nil stdout nil
+"-v" "-e" "/1 \"%02x \"")))
+ (push (buffer-string) call-process-inputs)
+(skip-unless hexdump)
+(with-temp-buffer
+  (let ((buffer-file-name "foo.cpp")
+(buffer-file-coding-system 'utf-8-with-signature-dos)
+(default-process-coding-system 'latin-1-unix))
+(insert "ä\n")
+(clang-format-buffer))
+  (should (equal (buffer-string) "ä\n"))
+  (should (eobp)))
+(should (equal call-process-inputs '("

r292593 - Use UTF-8 for all communication with clang-format

2017-01-20 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Fri Jan 20 03:37:50 2017
New Revision: 292593

URL: http://llvm.org/viewvc/llvm-project?rev=292593&view=rev
Log:
Use UTF-8 for all communication with clang-format

Summary: Instead of picking the buffer file coding system, always use 
utf-8-unix for communicating with clang-format.  This is fine because 
clang-format never actually reads the file to be formatted, only standard 
input.  This is a bit simpler (process coding system is now a constant) and 
potentially faster, as utf-8-unix is Emacs's internal coding system.  Also add 
an end-to-end test that actually invokes clang-format.

Reviewers: klimek

Reviewed By: klimek

Differential Revision: https://reviews.llvm.org/D28904

Modified:
cfe/trunk/tools/clang-format/clang-format-test.el
cfe/trunk/tools/clang-format/clang-format.el

Modified: cfe/trunk/tools/clang-format/clang-format-test.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-test.el?rev=292593&r1=292592&r2=292593&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format-test.el (original)
+++ cfe/trunk/tools/clang-format/clang-format-test.el Fri Jan 20 03:37:50 2017
@@ -31,8 +31,8 @@
(with-current-buffer stdout
  (insert "
 
- 
- 
+ 
+ 
 
 "))
0)
@@ -58,15 +58,14 @@
(should (equal args
   '("-output-replacements-xml" "-assume-filename" "foo.cpp"
 "-style" "file"
-;; Length of the UTF-8 byte-order mark.
-"-offset" "3"
+;; Beginning of buffer, no byte-order mark.
+"-offset" "0"
 ;; We have two lines with 2×2 bytes for the umlauts,
-;; 2 bytes for the line ending, and 3 bytes for the
+;; 1 byte for the line ending, and 3 bytes for the
 ;; other ASCII characters each.
-"-length" "18"
-;; Length of a single line (without line ending) plus
-;; BOM.
-"-cursor" "10")))
+"-length" "16"
+;; Length of a single line (without line ending).
+"-cursor" "7")))
 
 (ert-deftest clang-format-buffer--process-encoding ()
   "Tests that text is sent to the clang-format process in the
@@ -105,6 +104,23 @@ right encoding."
 (clang-format-buffer))
   (should (equal (buffer-string) "ä\n"))
   (should (eobp)))
-(should (equal call-process-inputs '("ef bb bf c3 a4 0d 0a ")
+(should (equal call-process-inputs '("c3 a4 0a ")
+
+(ert-deftest clang-format-buffer--end-to-end ()
+  "End-to-end test for ‘clang-format-buffer’.
+Actually calls the clang-format binary."
+  (skip-unless (file-executable-p clang-format-executable))
+  (with-temp-buffer
+(let ((buffer-file-name "foo.cpp")
+  (buffer-file-coding-system 'utf-8-with-signature-dos)
+  (default-process-coding-system 'latin-1-unix))
+  (insert "ä =ö;\nü= ß;\n")
+  (goto-char (point-min))
+  (end-of-line)
+  (clang-format-buffer))
+(should (equal (buffer-string) "ä = ö;\nü = ß;\n"))
+(should (eolp))
+(should (equal (buffer-substring (point) (point-max))
+   "\nü = ß;\n"
 
 ;;; clang-format-test.el ends here

Modified: cfe/trunk/tools/clang-format/clang-format.el
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.el?rev=292593&r1=292592&r2=292593&view=diff
==
--- cfe/trunk/tools/clang-format/clang-format.el (original)
+++ cfe/trunk/tools/clang-format/clang-format.el Fri Jan 20 03:37:50 2017
@@ -95,9 +95,10 @@ of the buffer."
 (defun clang-format--replace (offset length &optional text)
   "Replace the region defined by OFFSET and LENGTH with TEXT.
 OFFSET and LENGTH are measured in bytes, not characters.  OFFSET
-is a zero-based file offset."
-  (let ((start (clang-format--filepos-to-bufferpos offset 'exact))
-(end (clang-format--filepos-to-bufferpos (+ offset length) 'exact)))
+is a zero-based file offset, assuming ‘utf-8-unix’ coding."
+  (let ((start (clang-format--filepos-to-bufferpos offset 'exact 'utf-8-unix))
+(end (clang-format--filepos-to-bufferpos (+ offset length) 'exact
+ 'utf-8-unix)))
 (goto-char start)
 (delete-region start end)
 (when text
@@ -130,15 +131,18 @@ is no active region.  If no style is giv
   (unless style
 (setq style clang-format-style))
 
-  (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate))
-(file-end (clang-format--bufferpos-to-filepos end 'approximate))
-(cursor (clang-format--buf

[clang-tools-extra] r307535 - Improve error message when run from a buffer that doesn't visit a file

2017-07-10 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Mon Jul 10 06:49:18 2017
New Revision: 307535

URL: http://llvm.org/viewvc/llvm-project?rev=307535&view=rev
Log:
Improve error message when run from a buffer that doesn't visit a file

Summary: In this case, users currently get a confusing type error.  Make the 
error message more obvious.

Reviewers: klimek

Reviewed By: klimek

Differential Revision: https://reviews.llvm.org/D35197

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

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=307535&r1=307534&r2=307535&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Mon Jul 
10 06:49:18 2017
@@ -88,6 +88,8 @@ The current file name is passed after AR
 the call was successful the returned result is stored in a
 temporary buffer, and CALLBACK is called with the temporary
 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
  ;; ‘start-process’ doesn’t allow us to separate the


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


[clang-tools-extra] r307635 - Use new command replace-buffer-contents if available

2017-07-11 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Tue Jul 11 02:01:58 2017
New Revision: 307635

URL: http://llvm.org/viewvc/llvm-project?rev=307635&view=rev
Log:
Use new command replace-buffer-contents if available

Reviewers: klimek

Reviewed By: klimek

Differential Revision: https://reviews.llvm.org/D35211

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

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=307635&r1=307634&r2=307635&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Tue Jul 
11 02:01:58 2017
@@ -187,9 +187,9 @@ failure, a buffer containing the error o
   "Replace current buffer by content of STDOUT."
   (cl-check-type stdout buffer-live)
   (barf-if-buffer-read-only)
-  (unless (clang-include-fixer--insert-line stdout (current-buffer))
-(erase-buffer)
-(insert-buffer-substring stdout))
+  (cond ((fboundp 'replace-buffer-contents) (replace-buffer-contents stdout))
+((clang-include-fixer--insert-line stdout (current-buffer)))
+(t (erase-buffer) (insert-buffer-substring stdout)))
   (message "Fix applied")
   nil)
 


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


[clang-tools-extra] r286381 - Fix grammar

2016-11-09 Thread Philipp Stephani via cfe-commits
Author: phst
Date: Wed Nov  9 11:47:56 2016
New Revision: 286381

URL: http://llvm.org/viewvc/llvm-project?rev=286381&view=rev
Log:
Fix grammar

"allow" requires a direct object in this case.

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

Modified: clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el?rev=286381&r1=286380&r2=286381&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el (original)
+++ clang-tools-extra/trunk/include-fixer/tool/clang-include-fixer.el Wed Nov  
9 11:47:56 2016
@@ -5,8 +5,8 @@
 
 ;;; Commentary:
 
-;; This package allows to invoke the 'clang-include-fixer' within Emacs.
-;; 'clang-include-fixer' provides an automated way of adding #include
+;; This package allows Emacs users to invoke the 'clang-include-fixer' within
+;; Emacs.  'clang-include-fixer' provides an automated way of adding #include
 ;; directives for missing symbols in one translation unit, see
 ;; .
 


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