[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 74bb693 21/40: Call Clang from the directory containing co
From: |
Dmitry Gutov |
Subject: |
[elpa] master 74bb693 21/40: Call Clang from the directory containing compile_flags.txt |
Date: |
Thu, 2 Jan 2020 18:57:03 -0500 (EST) |
branch: master
commit 74bb6934eaae7affb5ec57599c3080736d5ad10c
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Call Clang from the directory containing compile_flags.txt
#933
---
company-clang.el | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/company-clang.el b/company-clang.el
index 55d9d9b..272dd8f 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -51,7 +51,10 @@ and `c-electric-colon', for automatic completion right after
\">\" and
(defcustom company-clang-use-compile-flags-txt nil
"When non-nil, use flags from compile_flags.txt if present.
-The lines from that files will be appended to `company-clang-arguments'."
+The lines from that files will be appended to `company-clang-arguments'.
+
+And if such file is found, Clang is called from the directory containing
+it. That allows the flags use relative file names within the project."
:type 'boolean
:safe 'booleanp)
@@ -265,12 +268,15 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(defun company-clang--arguments ()
(let ((fname "compile_flags.txt")
- (args company-clang-arguments))
+ (args company-clang-arguments)
+ current-dir-rel)
(when company-clang-use-compile-flags-txt
(let ((dir (locate-dominating-file default-directory fname)))
(when dir
+ (setq current-dir-rel (file-relative-name default-directory dir))
+ (setq default-directory dir)
(with-temp-buffer
- (insert-file-contents (expand-file-name fname dir))
+ (insert-file-contents fname)
(setq args
(append
args
@@ -278,7 +284,9 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(point-min) (point-max))
"[\n\r]+"
t
- "[ \t]+")))))))
+ "[ \t]+"))))
+ (unless (equal current-dir-rel "./")
+ (push (format "-I%s" current-dir-rel) args)))))
args))
(defun company-clang--candidates (prefix callback)
@@ -288,13 +296,14 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(when (null company-clang--prefix)
(company-clang-set-prefix (or (funcall company-clang-prefix-guesser)
'none)))
- (apply 'company-clang--start-process
- prefix
- callback
- (company-clang--build-complete-args
- (if (company-clang--check-version 4.0 9.0)
- (point)
- (- (point) (length prefix))))))
+ (let ((default-directory default-directory))
+ (apply 'company-clang--start-process
+ prefix
+ callback
+ (company-clang--build-complete-args
+ (if (company-clang--check-version 4.0 9.0)
+ (point)
+ (- (point) (length prefix)))))))
(defun company-clang--prefix ()
(if company-clang-begin-after-member-access
- [elpa] master c046847 33/40: Add a NEWS entry, (continued)
- [elpa] master c046847 33/40: Add a NEWS entry, Dmitry Gutov, 2020/01/02
- [elpa] master f3e0290 14/40: Merge branch 'master' of github.com:company-mode/company-mode, Dmitry Gutov, 2020/01/02
- [elpa] master b800fbd 23/40: company-enable-overriding-keymap: Make a defun, Dmitry Gutov, 2020/01/02
- [elpa] master 7fc6ad9 34/40: Merge pull request #941 from amosbird/master, Dmitry Gutov, 2020/01/02
- [elpa] master 0760e48 37/40: Move the entry to the proper position, Dmitry Gutov, 2020/01/02
- [elpa] master dbb4c74 35/40: Merge branch 'master' of github.com:company-mode/company-mode, Dmitry Gutov, 2020/01/02
- [elpa] master 1b00f8c 38/40: Update copyright notice, Dmitry Gutov, 2020/01/02
- [elpa] master ed14c67 40/40: Merge commit '3c11c30c9ab41d8a9c88560071c48fbcdcbcba5d' from company, Dmitry Gutov, 2020/01/02
- [elpa] master 3c11c30 39/40: Bump the version, Dmitry Gutov, 2020/01/02
- [elpa] master bb737d8 20/40: Determine exit-function's status using completion-boundaries, Dmitry Gutov, 2020/01/02
- [elpa] master 74bb693 21/40: Call Clang from the directory containing compile_flags.txt,
Dmitry Gutov <=
- [elpa] master 7f3ae90 19/40: Add option company-clang-use-compile-flags-txt, Dmitry Gutov, 2020/01/02
- [elpa] master da4da70 36/40: Edit NEWS, Dmitry Gutov, 2020/01/02