Get current projectile root path in elisp
Asked Answered
P

2

9

Is there any way to get the current projectile root path in elisp.

Something similar to the command eproject-root in eproject.

Thanks

Pinebrook answered 26/3, 2017 at 0:53 Comment(0)
I
15

There is! The function is called projectile-project-root. You can see an example use here in my virtualenvwrapper.el project.

Illuminate answered 26/3, 2017 at 1:50 Comment(1)
I have a variable named this, which is nilCilo
R
2

There is no single way to do this, as the definition of a project root is not built into emacs.

You can call:

Without depending on 3rd party packages you can use vc directly (assuming projects use version control).

(defun my-vc-root-path-or-default (filepath &optional default)
  "Return the version control directory from FILEPATH or DEFAULT."
  (let ((vc-base-path default))
    (condition-case err
      (let ((vc-backend (ignore-errors (vc-responsible-backend filepath))))
        (when vc-backend
          (setq vc-base-path (vc-call-backend vc-backend 'root filepath))))
      (error (message "Error creating vc-backend root name: %s" err)))
    vc-base-path))
Repose answered 23/12, 2021 at 1:26 Comment(1)
I have no M-x projectile-project-rootCilo

© 2022 - 2024 — McMap. All rights reserved.