Skip to content

Commit 6234d07

Browse files
committed
Make cquery-project-roots a root matcher
1 parent 12ce064 commit 6234d07

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

cquery-common.el

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@
5151
(defsubst cquery--root-from-func (func)
5252
(and (fboundp func) (ignore-errors (funcall func))))
5353

54-
(cl-defun cquery--get-root ()
55-
"Return the root directory of a cquery project."
54+
(cl-defun cquery-project-roots-matcher ()
5655
(cl-loop for root in cquery-project-roots do
5756
(when (string-prefix-p (expand-file-name root) buffer-file-name)
58-
(cl-return-from cquery--get-root root)))
57+
(cl-return-from cquery--get-root root))))
58+
59+
(cl-defun cquery--get-root ()
60+
"Return the root directory of a cquery project."
5961
(cl-loop for matcher in cquery-project-root-matchers do
6062
(-when-let (root (cl-typecase matcher
6163
(string (cquery--root-from-file matcher))

cquery.el

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ Relative to the project root directory."
8686
(defcustom cquery-project-roots
8787
nil
8888
"A list of project roots that will be matched against the source filename first
89-
to get the project root before consulting `cquery-project-root-matchers'.
89+
to get the project root.
9090
91-
This is useful when your project has subprojects. Otherwise `projectile' and
92-
`project' may think the file resides in a subproject and thus the file
93-
does not belong to the current workspace.
91+
This is used by `cquery-project-roots-matcher', useful when your project has
92+
subprojects. Otherwise `projectile' and `project' may think the file resides
93+
in a subproject and thus does not belong to the current workspace.
9494
"
9595
:type '(repeat directory)
9696
:group 'cquery)
9797

9898
(defcustom cquery-project-root-matchers
99-
'(projectile-project-root "compile_commands.json" ".cquery")
99+
'(cquery-project-roots-matcher projectile-project-root "compile_commands.json" ".cquery")
100100
"List of matchers that are used to locate the cquery project roots.
101101
Each matcher is run in order, and the first successful (non-nil) matcher
102102
determines the project root.
@@ -107,7 +107,7 @@ upwards through the project directory structure and return the first
107107
matching file.
108108
109109
A `function' entry define a callable function that either returns workspace's
110-
root location or `nil' if another matcher should be used instead.
110+
root location or `nil' if subsequent matchers should be used instead.
111111
"
112112
:type '(repeat (choice (file) (function)))
113113
:group 'cquery)

0 commit comments

Comments
 (0)