switch project fix
This commit is contained in:
@@ -105,7 +105,11 @@ Falls back to the global value of VAR if no dir-local value is set."
|
||||
|
||||
(defun org-roam-project--context (&optional dir)
|
||||
"Return the org-roam context for the project containing DIR.
|
||||
DIR defaults to `default-directory'.
|
||||
When DIR is nil, the project is detected via `project-current', which
|
||||
respects `project-current-directory-override' (set by
|
||||
`project-switch-project' on Emacs 29+) before falling back to
|
||||
`default-directory'. Pass an explicit DIR only when the caller already
|
||||
has a concrete filesystem path (e.g. the autosync advice).
|
||||
|
||||
Returns a cons cell (NOTES-DIR . DB-PATH) where NOTES-DIR is the
|
||||
absolute path to the project's org-roam notes directory and DB-PATH
|
||||
@@ -115,8 +119,9 @@ Returns nil if:
|
||||
- DIR is not inside a project.el project.
|
||||
- The notes directory does not exist and `org-roam-project-auto-create'
|
||||
is nil."
|
||||
(let* ((dir (expand-file-name (or dir default-directory)))
|
||||
(project (project-current nil dir)))
|
||||
(let* ((project (if dir
|
||||
(project-current nil (expand-file-name dir))
|
||||
(project-current nil))))
|
||||
(when project
|
||||
(let* ((root (project-root project))
|
||||
(notes-subdir (org-roam-project--value-in-dir
|
||||
@@ -150,10 +155,12 @@ Otherwise BODY executes with the global org-roam settings."
|
||||
|
||||
(defun org-roam-project--require-context ()
|
||||
"Return the project context or signal a helpful error.
|
||||
Respects `project-current-directory-override' (set by
|
||||
`project-switch-project' on Emacs 29+) before falling back to
|
||||
`default-directory'.
|
||||
Signals `user-error' if there is no current project or the project's
|
||||
notes directory has not been initialized."
|
||||
(let* ((dir default-directory)
|
||||
(project (project-current nil dir)))
|
||||
(let* ((project (project-current nil)))
|
||||
(unless project
|
||||
(user-error "Not inside a project.el project"))
|
||||
(let* ((root (project-root project))
|
||||
|
||||
Reference in New Issue
Block a user