在elisp中获取当前弹丸根路径
Get current projectile root path in elisp
有没有办法在elisp中获取当前弹丸根路径
类似于eproject.
中的命令eproject-root
谢谢
有!该函数称为 projectile-project-root
。您可以在我的 virtualenvwrapper.el 项目中看到使用 here 的示例。
没有单一的方法可以做到这一点,因为项目根的定义没有内置到 emacs 中。
您可以拨打:
ffip-project-root
对于 find-file-in-project. 的用户
projectile-project-root
对于 projectile. 的用户
无需依赖第 3 方包,您可以直接使用 vc
(假设项目使用版本控制)。
(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))
有没有办法在elisp中获取当前弹丸根路径
类似于eproject.
eproject-root
谢谢
有!该函数称为 projectile-project-root
。您可以在我的 virtualenvwrapper.el 项目中看到使用 here 的示例。
没有单一的方法可以做到这一点,因为项目根的定义没有内置到 emacs 中。
您可以拨打:
ffip-project-root
对于 find-file-in-project. 的用户
projectile-project-root
对于 projectile. 的用户
无需依赖第 3 方包,您可以直接使用 vc
(假设项目使用版本控制)。
(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))