(fix): org-roam-descendant-of-p bug on Windows (#2089)

On Windows, `file-truename` and `directory-file-name` downcase driver
label: "C:/" => "c:/", while `expand-file-name` keep the case
unchanged. If `org-roam-directory` use upper case driver label, `org-roam-descendant-of-p` will alway return `nil`. Fix by only using `file-truename` in the function.
This commit is contained in:
bing
2022-02-21 02:05:12 +08:00
committed by GitHub
parent d20480bb8d
commit 97a342fd3f
3 changed files with 2 additions and 9 deletions

View File

@ -289,7 +289,7 @@ If FILE is not specified, use the current buffer's file-path."
(save-match-data (save-match-data
(and (and
(org-roam-file-p path) (org-roam-file-p path)
(org-roam-descendant-of-p path directory))))) (file-in-directory-p path directory)))))
;;;###autoload ;;;###autoload
(defun org-roam-dailies-find-directory () (defun org-roam-dailies-find-directory ()

View File

@ -108,13 +108,6 @@ SPEC is a list, as per `dolist'."
`(dolist-with-progress-reporter ,spec ,msg ,@body) `(dolist-with-progress-reporter ,spec ,msg ,@body)
`(dolist ,spec ,@body))) `(dolist ,spec ,@body)))
;;; File utilities
(defun org-roam-descendant-of-p (a b)
"Return t if A is descendant of B."
(unless (equal (file-truename a) (file-truename b))
(string-prefix-p (expand-file-name b)
(expand-file-name a))))
(defmacro org-roam-with-file (file keep-buf-p &rest body) (defmacro org-roam-with-file (file keep-buf-p &rest body)
"Execute BODY within FILE. "Execute BODY within FILE.
If FILE is nil, execute BODY in the current buffer. If FILE is nil, execute BODY in the current buffer.

View File

@ -194,7 +194,7 @@ FILE is an Org-roam file if:
(member ext org-roam-file-extensions) (member ext org-roam-file-extensions)
(not (and org-roam-file-exclude-regexp (not (and org-roam-file-exclude-regexp
(string-match-p org-roam-file-exclude-regexp path))) (string-match-p org-roam-file-exclude-regexp path)))
(org-roam-descendant-of-p path (expand-file-name org-roam-directory)))))) (file-in-directory-p path (expand-file-name org-roam-directory))))))
(defun org-roam-list-files () (defun org-roam-list-files ()
"Return a list of all Org-roam files under `org-roam-directory'. "Return a list of all Org-roam files under `org-roam-directory'.