-1

My general workflow for going to another project is

  1. projectile-switch-project which pops up a helm interface for picking a project
  2. select a project
  3. select a file within the project to open the file
  4. then run magit-status

Is there a way to combine steps 2-4?

irregular
  • 1,437
  • 3
  • 20
  • 39

3 Answers3

1
  1. projectile-switch-project which pops up a helm interface for picking a project

If you want to use projectile with helm, you could give helm-projectile a try.

  1. helm-projectile-switch-project
  2. then choose your project with M-g or f3 instead of RET

enter image description here

ramsay
  • 3,197
  • 2
  • 14
  • 13
  • I've updated my shortcut to go with `helm-projectile-switch-project` instead of the non-helm version, thanks! Would you know if there's a way to see what the other possible shortcuts are when scrolling through those project candidates? – irregular Nov 01 '22 at 17:07
  • You can see more actions in the action menu with `TAB` (the default Helm binding) – ramsay Nov 02 '22 at 01:40
  • or `C-z` (if you swapped). – ramsay Nov 02 '22 at 01:50
0

If you don't use many projectile features, you can take a look at the built-in project, whose project-switch-project will let you select a command after selecting the project like: enter image description here

Or you may add actions to open magit status for the project to helm like https://occasionallycogent.com/emacs_custom_helm_actions/index.html (something similar embark in helm if I remember correctly)

Tianshu Wang
  • 630
  • 2
  • 9
0

If I understand your question correctly, you may be able to code a little function that does what you need and attach it to projectile-after-switch-project-hook. At least running magit-status on that hook (if it's a git project), should be pretty easy to do.

EDIT: Tried it out. It interferes with projectile-switch-project-action. Good news is that you can just use that instead.

Here's a draft:

(defun my-projectile-switch-project-action ()
  (interactive)
  ;; test for some typical files in my projects
  (ignore-errors
    (let ((files '("README" "README.md" "build.gradle")))
      (while files
        (message "Looking for: %s" (first files))
        (if (file-exists-p (first files))
            (progn
              (find-file-other-window (first files))
              (setq files nil))
          (setq files (rest files))))))
  ;; now run magit
  (if (vc-git-responsible-p default-directory)
      (magit-status)))


;; Use the function like this:
(setq projectile-switch-project-action
      #'my-projectile-switch-project-action)

I hereby put above code under the GPLv2 or later in addition to StackOverflow's standard license. You can chose under which license you want to receive this code.

Stefan Kamphausen
  • 1,615
  • 15
  • 20