-
-
Notifications
You must be signed in to change notification settings - Fork 587
Description
Motivation
The idea is to have commands that will switch to a project and then find a file
in the project displaying the file in other window or other frame. The natural
bindings for it seem to be C-c p 4 p
and C-c p 5 p
.
I've been using a custom implementation based on helm-projectile
for a last
few years and I think it may be generalised to projectile
. I have been
thinking how to do that and since I couldn't decide what would be the best way
to approach the implementation I decided to reach here. For brevity, I will
only consider the other window version, but the same applies for other frame.
Solution 1
Utilise existing functionality and simply
set projectile-switch-project-action
to projectile-find-file-other-window
and call projectile-switch-project-by-name
. Caveat is that a natural command
name (IMHO the best one), i.e., projectile-switch-project-other-window
would
have different semantics to projectile-switch-project
. If that's an issue
then perhaps come up with a distinct name the new command,
e.g. projectile-switch-project-and-find-file-other-window
. But I think such a
name is too mouthful and would vote for different semantics with a mention in
docstring.
FWIW I implemented a solution that bases on this idea in helm-projectile
.
Solution 2
To mimic projectile-switch-project
semantics (to a degree), try to find a
function named after the vale of projectile-switch-project-action
that
matches the intention. E.g. append -other-window
suffix to a current value of
the action variable and if such a function exists then call it. The bit that
doesn't have so clear answer is what to do when such a function doesn't
exist. Calling a hardcoded projectile-find-file-other-window
may be
surprising for someone who set the action to something completely different.
Solution 3
To preserve projectile-switch-project
semantics add a new
variable projectile-switch-project-other-window-action
with default vale
of projectile-find-file-other-window
and replicate semantics
of projectile-switch-project
. This may be a bit of overkill though.
Please let me know what you think. I am happy to cut a PR with whatever
solution you think is best.