-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
I don't know elisp well enough to know if there's a better way to do this (hence an issue and not a pull request). This code returns the directory of the current buffer if there isn't a project root. That way, I can write tests in a single file where I'm just testing out some code.
Untouched; only changed the name.
(defun pytest-find-project-root-recursive (&optional dirname)
(let ((dn
(if dirname
dirname
(file-name-directory buffer-file-name))))
(cond ((funcall pytest-project-root-test dn) (expand-file-name dn))
((equal (expand-file-name dn) "/") nil)
(t (pytest-find-project-root-recursive
(file-name-directory (directory-file-name dn)))))))
Try to find a project root and fall back to the current directory.
(defun pytest-find-project-root (&optional dirname)
(or (pytest-find-project-root-recursive dirname)
(file-name-directory buffer-file-name)))
Metadata
Metadata
Assignees
Labels
No labels