mirror of
https://github.com/org-roam/org-roam
synced 2025-08-11 13:07:24 -05:00
(fix): fix org-roam-file-p crashing (#1651)
org-roam-file-p throws `wrong-type-argument stringp nil` on buffers that do not have a corresponding file. This fix changes org-roam-file-p to return nil instead of crashing in this scenario. Addresses #1645
This commit is contained in:
@ -167,12 +167,13 @@ Like `file-name-extension', but does not strip version number."
|
|||||||
"Return t if FILE is part of Org-roam system, nil otherwise.
|
"Return t if FILE is part of Org-roam system, nil otherwise.
|
||||||
If FILE is not specified, use the current buffer's file-path."
|
If FILE is not specified, use the current buffer's file-path."
|
||||||
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
|
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
|
||||||
(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)))
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(and
|
(and
|
||||||
|
path
|
||||||
(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)))
|
||||||
|
Reference in New Issue
Block a user