Skip to content

Commit 63177af

Browse files
committed
Document the sibling signal list as an extension point
`projectile-sibling-project-functions' is a plain list of functions, and adding your own is the intended way to teach Projectile a grouping it can't infer. The manual mentioned the option once, in passing, as the thing that fixes the order of the three built-ins - never that the list is yours to extend, and never what a function has to return. The worktree equivalent four sections down documents exactly that, so the omission was just an inconsistency. Adds a section with the contract, a worked example, and where to put yours relative to the built-ins. Also states something that was true but written down nowhere: the share cap is applied inside the two inferred signals rather than to the list as a whole, so a function you add is never capped. Someone writing one would reasonably assume the cap protects them. That note goes in the docstring too, which is where they'd actually look.
1 parent 9357ffb commit 63177af

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

‎doc/modules/ROOT/pages/across_repositories.adoc‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,37 @@ signal goes quiet and you fall back to name matching. When a project you
171171
care about ends up with no siblings, that's what `projectile-project-groups`
172172
is for.
173173

174+
=== Signals of your own
175+
176+
The three above are only the default value of
177+
`projectile-sibling-project-functions`, which is a plain list of functions.
178+
Each is called with a project root and should return a list of project
179+
directories related to it; the results are concatenated in the order the
180+
list gives, and a project found by more than one function is offered once,
181+
in the position the first one to report it put it.
182+
183+
So you can add a signal of your own - reading a workspace manifest, asking
184+
a service, consulting whatever your organization uses to say which
185+
repositories belong together:
186+
187+
[source,elisp]
188+
----
189+
(defun my-siblings-from-manifest (root)
190+
"Return the projects listed beside ROOT in our workspace manifest."
191+
...)
192+
193+
;; ahead of the built-ins, so it wins where it has an opinion
194+
(add-to-list 'projectile-sibling-project-functions #'my-siblings-from-manifest)
195+
----
196+
197+
Put yours before the built-ins to have it take precedence, after them to
198+
act as a fallback, or replace the list outright to use nothing else.
199+
200+
NOTE: The share cap applies inside the two inferred signals, not to the
201+
list as a whole, so a function of your own is never capped - it behaves
202+
like a configured group. That's usually what you want, but it does mean a
203+
function that accidentally matches everything will offer you everything.
204+
174205
== What else checkouts share
175206

176207
Knowing that two roots are one repository is useful beyond switching between

‎projectile.el‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14428,7 +14428,13 @@ Each is called with a project root and should return a list of project
1442814428
directories related to it. They're consulted in order and their results
1442914429
concatenated, so the most trustworthy signal should come first; a project
1443014430
found by more than one is offered once, in the position the first
14431-
function to report it put it."
14431+
function to report it put it.
14432+
14433+
Adding your own is the intended way to teach Projectile a grouping it
14434+
can't infer - a workspace manifest, say. Note that
14435+
`projectile-sibling-max-group-share' is applied inside the two built-in
14436+
inferred signals rather than to this list, so a function you add is never
14437+
capped: it is trusted the way a configured group is."
1443214438
:group 'projectile
1443314439
:type '(repeat function)
1443414440
:package-version '(projectile . "3.4.0"))

0 commit comments

Comments
 (0)