[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 7f3ae90 19/40: Add option company-clang-use-compile-flags-
From: |
Dmitry Gutov |
Subject: |
[elpa] master 7f3ae90 19/40: Add option company-clang-use-compile-flags-txt |
Date: |
Thu, 2 Jan 2020 18:57:02 -0500 (EST) |
branch: master
commit 7f3ae9011c658c1d5d03559e291688ca1deb60f7
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Add option company-clang-use-compile-flags-txt
Closes #933
---
NEWS.md | 2 ++
company-clang.el | 27 ++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/NEWS.md b/NEWS.md
index 9ffc8a3..7c01c1f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
## Next
+* New user option `company-clang-use-compile-flags-txt`
+ ([#933](https://github.com/company-mode/company-mode/issues/933)).
* Support for completion style specific sorting (Emacs 27 feature).
* Snippet/template field interaction is inhibited while completion is active
(where by default `TAB` calls `company-complete-common`, clashing with
snippet
diff --git a/company-clang.el b/company-clang.el
index d764905..55d9d9b 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -48,6 +48,13 @@ and `c-electric-colon', for automatic completion right after
\">\" and
\":\"."
:type 'boolean)
+(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'."
+ :type 'boolean
+ :safe 'booleanp)
+
(defcustom company-clang-arguments nil
"Additional arguments to pass to clang when completing.
Prefix files (-include ...) can be selected with `company-clang-set-prefix'
@@ -249,13 +256,31 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(append '("-fsyntax-only" "-Xclang" "-code-completion-macros")
(unless (company-clang--auto-save-p)
(list "-x" (company-clang--lang-option)))
- company-clang-arguments
+ (company-clang--arguments)
(when (stringp company-clang--prefix)
(list "-include" (expand-file-name company-clang--prefix)))
(list "-Xclang" (format "-code-completion-at=%s"
(company-clang--build-location pos)))
(list (if (company-clang--auto-save-p) buffer-file-name "-"))))
+(defun company-clang--arguments ()
+ (let ((fname "compile_flags.txt")
+ (args company-clang-arguments))
+ (when company-clang-use-compile-flags-txt
+ (let ((dir (locate-dominating-file default-directory fname)))
+ (when dir
+ (with-temp-buffer
+ (insert-file-contents (expand-file-name fname dir))
+ (setq args
+ (append
+ args
+ (split-string (buffer-substring-no-properties
+ (point-min) (point-max))
+ "[\n\r]+"
+ t
+ "[ \t]+")))))))
+ args))
+
(defun company-clang--candidates (prefix callback)
(and (company-clang--auto-save-p)
(buffer-modified-p)
- [elpa] master f3e0290 14/40: Merge branch 'master' of github.com:company-mode/company-mode, (continued)
- [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, 2020/01/02
- [elpa] master 7f3ae90 19/40: Add option company-clang-use-compile-flags-txt,
Dmitry Gutov <=
- [elpa] master da4da70 36/40: Edit NEWS, Dmitry Gutov, 2020/01/02