0

In this function definition snippet, a call to switch-project-action is done without any arguments. How does it switch to the correct project?

(defun projectile-switch-project-by-name (project-to-switch &optional arg)
  "Switch to project by project name PROJECT-TO-SWITCH.
Invokes the command referenced by `projectile-switch-project-action' on switch.
With a prefix ARG invokes `projectile-commander' instead of
`projectile-switch-project-action.'"
  (let* ((default-directory project-to-switch)
         (switch-project-action (if arg
                                    'projectile-commander
                                  projectile-switch-project-action)))
    (run-hooks 'projectile-before-switch-project-hook)
    (funcall switch-project-action)
    (run-hooks 'projectile-after-switch-project-hook)))
2

The current project is determined by the value of default-directory, which is let-bound to "switch" projects before calling the action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.