mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
(fix) org-roam-file-p handle opening a buffer with no path (#2185)
reapply #2169
This commit is contained in:
10
org-roam.el
10
org-roam.el
@ -192,9 +192,9 @@ FILE is an Org-roam file if:
|
|||||||
- It's located somewhere under `org-roam-directory'
|
- It's located somewhere under `org-roam-directory'
|
||||||
- It has a matching file extension (`org-roam-file-extensions')
|
- It has a matching file extension (`org-roam-file-extensions')
|
||||||
- It doesn't match excluded regexp (`org-roam-file-exclude-regexp')"
|
- It doesn't match excluded regexp (`org-roam-file-exclude-regexp')"
|
||||||
|
(when (or file (buffer-file-name (buffer-base-buffer)))
|
||||||
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
|
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
|
||||||
(relative-path (file-relative-name path org-roam-directory))
|
(ext (org-roam--file-name-extension path))
|
||||||
(ext (when path (org-roam--file-name-extension path)))
|
|
||||||
(ext (if (string= ext "gpg")
|
(ext (if (string= ext "gpg")
|
||||||
(org-roam--file-name-extension (file-name-sans-extension path))
|
(org-roam--file-name-extension (file-name-sans-extension path))
|
||||||
ext))
|
ext))
|
||||||
@ -204,18 +204,18 @@ FILE is an Org-roam file if:
|
|||||||
(cond
|
(cond
|
||||||
((not org-roam-file-exclude-regexp) nil)
|
((not org-roam-file-exclude-regexp) nil)
|
||||||
((stringp org-roam-file-exclude-regexp)
|
((stringp org-roam-file-exclude-regexp)
|
||||||
(string-match-p org-roam-file-exclude-regexp relative-path))
|
(string-match-p org-roam-file-exclude-regexp path))
|
||||||
((listp org-roam-file-exclude-regexp)
|
((listp org-roam-file-exclude-regexp)
|
||||||
(let (is-match)
|
(let (is-match)
|
||||||
(dolist (exclude-re org-roam-file-exclude-regexp)
|
(dolist (exclude-re org-roam-file-exclude-regexp)
|
||||||
(setq is-match (or is-match (string-match-p exclude-re relative-path))))
|
(setq is-match (or is-match (string-match-p exclude-re path))))
|
||||||
is-match)))))
|
is-match)))))
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(and
|
(and
|
||||||
path
|
path
|
||||||
org-roam-dir-p
|
org-roam-dir-p
|
||||||
valid-file-ext-p
|
valid-file-ext-p
|
||||||
(not match-exclude-regexp-p)))))
|
(not match-exclude-regexp-p))))))
|
||||||
|
|
||||||
(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'.
|
||||||
|
Reference in New Issue
Block a user