Skip to content

Commit 8927963

Browse files
committed
Give the related-project commands a prefix of their own
s-p n is now the prefix for everything that works across related projects, with each key mirroring the project-wide one a level down the way c m does for subprojects: n p switches, n f finds a file, n s searches. That costs the s-p n binding from 3.4.0, but three commands scattered across n, N and s n were never going to read as one family, and better to pay it now with three than later with more. Switching to a sibling project and to a worktree were missing from the menu entirely, which was easy to miss while they were the only commands in the family.
1 parent aa26537 commit 8927963

5 files changed

Lines changed: 27 additions & 20 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88

99
### New features
1010

11-
- [#2160](https://github.com/bbatsov/projectile/pull/2160): Add `projectile-find-file-in-sibling-projects` (`s-p N`) and `projectile-search-in-sibling-projects` (`s-p s n`), which work across the family of related projects rather than just the one you're in.
11+
- [#2160](https://github.com/bbatsov/projectile/pull/2160): Add `projectile-find-file-in-sibling-projects` (`s-p n f`) and `projectile-search-in-sibling-projects` (`s-p n s`), which work across the family of related projects rather than just the one you're in.
1212
- Both are built on `projectile-find-file-in-projects` and `projectile-search-in-projects`, which take any list of projects, so a command for a group of your own is a two-line wrapper.
1313
- A group search puts every match in one `*projectile-search*` buffer, named relative to the directory containing the group, so each one is labelled with the project it came from.
1414

15+
### Changes
16+
17+
- [#2160](https://github.com/bbatsov/projectile/pull/2160): `projectile-switch-sibling-project` moved from `s-p n` to `s-p n p`. `s-p n` is now the prefix for every command that works across related projects, with each key mirroring the project-wide one a level down, the way `c m` does for subprojects.
18+
1519
### Bugs fixed
1620

1721
- [#2157](https://github.com/bbatsov/projectile/pull/2157): `projectile-use-comint-mode` now covers the named tasks run by `projectile-run-task`, which were always given a read-only compilation buffer however it was set - so a task that needs to ask for a sudo password had nowhere to type one ([#2156](https://github.com/bbatsov/projectile/issues/2156)). Name `task` in the list, or set the option to `t`.

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ else" that come up constantly, and Projectile has a command for each:
1010
* *Different projects that belong together* - a library and the app using
1111
it, a tool and its documentation site.
1212
<<siblings,`projectile-switch-sibling-project`>>
13-
(kbd:[s-p n]).
13+
(kbd:[s-p n p]).
1414
1515
Both are narrowed versions of `projectile-switch-project` (kbd:[s-p p]).
1616
That command offers every project you've ever visited; these two offer
@@ -23,9 +23,9 @@ directories is the right one.
2323
| Keybinding | Command
2424

2525
| kbd:[s-p W] | `projectile-switch-worktree`
26-
| kbd:[s-p n] | `projectile-switch-sibling-project`
27-
| kbd:[s-p N] | `projectile-find-file-in-sibling-projects`
28-
| kbd:[s-p s n] | `projectile-search-in-sibling-projects`
26+
| kbd:[s-p n p] | `projectile-switch-sibling-project`
27+
| kbd:[s-p n f] | `projectile-find-file-in-sibling-projects`
28+
| kbd:[s-p n s] | `projectile-search-in-sibling-projects`
2929
|===
3030

3131
The two switch commands honour `projectile-switch-project-action`, and both
@@ -101,7 +101,7 @@ option's docstring for the details.
101101
[#siblings]
102102
== Related projects
103103

104-
kbd:[s-p n] offers the projects related to the one you're in. Three
104+
kbd:[s-p n p] offers the projects related to the one you're in. Three
105105
signals decide what "related" means, consulted in the order listed by
106106
`projectile-sibling-project-functions` - from the one you can trust
107107
completely to the one that's a guess.
@@ -213,12 +213,12 @@ function that accidentally matches everything will offer you everything.
213213
Switching isn't the only thing you want a family of projects for. Two
214214
commands work on the whole group at once, the current project included:
215215

216-
* kbd:[s-p N] (`projectile-find-file-in-sibling-projects`) completes over
216+
* kbd:[s-p n f] (`projectile-find-file-in-sibling-projects`) completes over
217217
the files of every related project. It's kbd:[s-p F] narrowed from "every
218218
project I have ever visited" to "the handful this one belongs with",
219219
which is the difference between a useful completion list and a hopeless
220220
one.
221-
* kbd:[s-p s n] (`projectile-search-in-sibling-projects`) searches them all
221+
* kbd:[s-p n s] (`projectile-search-in-sibling-projects`) searches them all
222222
and collects the matches in one `*projectile-search*` buffer. A prefix
223223
argument makes the term an Emacs regexp.
224224

@@ -329,7 +329,7 @@ Worth knowing before you file a bug:
329329
When kbd:[s-p W] has nothing to offer it distinguishes the two reasons:
330330
having looked and found no other checkout, and not being able to look at
331331
all because the project isn't the top level of a git, Mercurial or
332-
Jujutsu repository. Only the first means "there aren't any". kbd:[s-p n]
332+
Jujutsu repository. Only the first means "there aren't any". kbd:[s-p n p]
333333
needs none of this, so it's the one to reach for when Projectile can't
334334
identify the repository.
335335

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Here's a list of the interactive Emacs Lisp functions, provided by Projectile:
1616
| kbd:[s-p F]
1717
| Display a list of all files in all known projects.
1818

19-
| kbd:[s-p N]
19+
| kbd:[s-p n f]
2020
| Display a list of all files in the projects related to this one - kbd:[s-p F] narrowed to the family the current project belongs to (see xref:across_repositories.adoc[Working across repositories]).
2121

2222
| kbd:[s-p g]
@@ -85,7 +85,7 @@ Here's a list of the interactive Emacs Lisp functions, provided by Projectile:
8585
| kbd:[s-p s t]
8686
| Collect the project's `TODO`/`FIXME`-style annotations into the reviewable search buffer. With a prefix argument it prompts for which keywords to search for.
8787

88-
| kbd:[s-p s n]
88+
| kbd:[s-p n s]
8989
| Search the current project and the ones related to it, collecting every match in one reviewable buffer. With a prefix argument the term is an Emacs regexp (see xref:across_repositories.adoc[Working across repositories]).
9090

9191
| kbd:[s-p v]
@@ -244,7 +244,7 @@ Here's a list of the interactive Emacs Lisp functions, provided by Projectile:
244244
| kbd:[s-p W]
245245
| Switch to another checkout of the current project's repository - a git worktree, a Jujutsu workspace, or another clone of the same upstream - showing what tells each apart (see xref:across_repositories.adoc[Working across repositories]).
246246

247-
| kbd:[s-p n]
247+
| kbd:[s-p n p]
248248
| Switch to a project related to the current one, rather than to any known project (see xref:across_repositories.adoc[Working across repositories]).
249249

250250
| kbd:[s-p S]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ where you're headed. Two commands narrow it down:
630630
current project's repository - its git worktrees, its Jujutsu workspaces, or
631631
another clone of the same upstream - each labelled with whatever tells it
632632
apart: the branch, or the workspace name.
633-
* `projectile-switch-sibling-project` (kbd:[s-p n]) offers the projects related
633+
* `projectile-switch-sibling-project` (kbd:[s-p n p]) offers the projects related
634634
to this one: grouped with it in your configuration, sharing the owner of its
635635
remote, or named after the same thing.
636636

‎projectile.el‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16480,9 +16480,11 @@ Magit that don't trigger `find-file-hook'."
1648016480
(define-key map (kbd "k") #'projectile-kill-buffers)
1648116481
(define-key map (kbd "l") #'projectile-find-file-in-directory)
1648216482
(define-key map (kbd "m") #'projectile-dispatch)
16483-
;; projects related to this one, in other repositories
16484-
(define-key map (kbd "n") #'projectile-switch-sibling-project)
16485-
(define-key map (kbd "N") #'projectile-find-file-in-sibling-projects)
16483+
;; projects related to this one, in other repositories - the keys
16484+
;; mirror the project-wide ones a level down, as `c m' does
16485+
(define-key map (kbd "n p") #'projectile-switch-sibling-project)
16486+
(define-key map (kbd "n f") #'projectile-find-file-in-sibling-projects)
16487+
(define-key map (kbd "n s") #'projectile-search-in-sibling-projects)
1648616488
(define-key map (kbd "o") #'projectile-multi-occur)
1648716489
(define-key map (kbd "p") #'projectile-switch-project)
1648816490
(define-key map (kbd "q") #'projectile-switch-open-project)
@@ -16496,7 +16498,6 @@ Magit that don't trigger `find-file-hook'."
1649616498
(define-key map (kbd "s x") #'projectile-find-references)
1649716499
(define-key map (kbd "s R") #'projectile-search-review)
1649816500
(define-key map (kbd "s X") #'projectile-search-regexp-review)
16499-
(define-key map (kbd "s n") #'projectile-search-in-sibling-projects)
1650016501
(define-key map (kbd "s t") #'projectile-todos)
1650116502
(define-key map (kbd "S") #'projectile-save-project-buffers)
1650216503
(define-key map (kbd "t") #'projectile-toggle-between-implementation-and-test)
@@ -16817,7 +16818,7 @@ search/replace case-sensitive, `--word' makes it match whole words,
1681716818
("l" "file in dir" projectile-find-file-in-directory)
1681816819
("C" "changed file" projectile-find-changed-file)
1681916820
("F" "file in known projects" projectile-find-file-in-known-projects)
16820-
("N" "file in sibling projects" projectile-find-file-in-sibling-projects)
16821+
("nf" "file in sibling projects" projectile-find-file-in-sibling-projects)
1682116822
("d" "dir" projectile-dispatch-find-dir)
1682216823
("D" "dired" projectile-dispatch-dired)
1682316824
("e" "recentf" projectile-recentf)
@@ -16843,7 +16844,7 @@ search/replace case-sensitive, `--word' makes it match whole words,
1684316844
("sa" "ag" projectile-dispatch-ag)
1684416845
("sx" "references" projectile-find-references)
1684516846
("sR" "search (review)" projectile-dispatch-search-review)
16846-
("sn" "search siblings" projectile-dispatch-search-siblings)
16847+
("ns" "search siblings" projectile-dispatch-search-siblings)
1684716848
("st" "todos" projectile-todos)
1684816849
("o" "multi-occur" projectile-multi-occur)
1684916850
("r" "replace" projectile-replace)
@@ -16853,7 +16854,7 @@ search/replace case-sensitive, `--word' makes it match whole words,
1685316854
("p" "switch project" projectile-dispatch-switch-project)
1685416855
("q" "switch open project" projectile-switch-open-project)
1685516856
("W" "switch worktree" projectile-switch-worktree)
16856-
("n" "switch sibling project" projectile-switch-sibling-project)
16857+
("np" "switch sibling project" projectile-switch-sibling-project)
1685716858
("A" "add known project" projectile-add-known-project)
1685816859
("v" "vc" projectile-vc)
1685916860
("P" "dashboard" projectile-dashboard)
@@ -16960,6 +16961,8 @@ search/replace case-sensitive, `--word' makes it match whole words,
1696016961
"--"
1696116962
["Switch to project" projectile-switch-project]
1696216963
["Switch to open project" projectile-switch-open-project]
16964+
["Switch to sibling project" projectile-switch-sibling-project]
16965+
["Switch to worktree" projectile-switch-worktree]
1696316966
"--"
1696416967
["Discover projects in directory" projectile-discover-projects-in-directory]
1696516968
["Discover projects in search path" projectile-discover-projects-in-search-path]

0 commit comments

Comments
 (0)