(fix)org-roam-file-p: don't exclude org-roam-directory (#2178)

* (fix)org-roam-file-p: don't exclude org-roam-directory

Don't exlude the org-roam-directory even if it matches
org-roam-file-exclude-regexp.

Should fix [#2165].

* Refactor PR #2178

Refactor PR #2178 to avoid recalculating (file-relative-name path
org-roam-directory) multiple timess.
This commit is contained in:
Tor Egil Hoftun Kvæstad
2022-05-02 18:12:28 +02:00
committed by GitHub
parent b63ff2a7bb
commit 5483e65d5a
2 changed files with 4 additions and 2 deletions

View File

@ -193,6 +193,7 @@ FILE is an Org-roam file if:
- It has a matching file extension (`org-roam-file-extensions')
- It doesn't match excluded regexp (`org-roam-file-exclude-regexp')"
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
(relative-path (file-relative-name path org-roam-directory))
(ext (when path (org-roam--file-name-extension path)))
(ext (if (string= ext "gpg")
(org-roam--file-name-extension (file-name-sans-extension path))
@ -203,11 +204,11 @@ FILE is an Org-roam file if:
(cond
((not org-roam-file-exclude-regexp) nil)
((stringp org-roam-file-exclude-regexp)
(string-match-p org-roam-file-exclude-regexp path))
(string-match-p org-roam-file-exclude-regexp relative-path))
((listp org-roam-file-exclude-regexp)
(let (is-match)
(dolist (exclude-re org-roam-file-exclude-regexp)
(setq is-match (or is-match (string-match-p exclude-re path))))
(setq is-match (or is-match (string-match-p exclude-re relative-path))))
is-match)))))
(save-match-data
(and