(feat): allow ignoring files matching a regular expression (#1046)

Adds a new user option, `org-roam-file-exclude-regexp`, to exclude files from Org-roam.
This commit is contained in:
Kisaragi Hiu
2020-08-18 17:16:56 +09:00
committed by GitHub
parent 30b2e97426
commit c33867e6bc
4 changed files with 19 additions and 0 deletions

View File

@ -10,6 +10,7 @@ In this release we support fuzzy links of the form `[[Title]]`, `[[*Headline]]`
### Features ### Features
- [#1046](https://github.com/org-roam/org-roam/pull/1046) New user option to exclude files from Org-roam
- [#1032](https://github.com/org-roam/org-roam/pull/1032) File changes are now propagated to the database on idle timer. This prevents large wait times during file saves. - [#1032](https://github.com/org-roam/org-roam/pull/1032) File changes are now propagated to the database on idle timer. This prevents large wait times during file saves.
- [#974](https://github.com/org-roam/org-roam/pull/974) Protect region targeted by `org-roam-insert` - [#974](https://github.com/org-roam/org-roam/pull/974) Protect region targeted by `org-roam-insert`
- [#994](https://github.com/org-roam/org-roam/pull/994) Simplify org-roam-store-link - [#994](https://github.com/org-roam/org-roam/pull/994) Simplify org-roam-store-link

View File

@ -513,6 +513,10 @@ This section concerns the placement and creation of files.
It is the users responsibility to set this correctly, especially when used It is the users responsibility to set this correctly, especially when used
with multiple Org-roam instances. with multiple Org-roam instances.
- Variable: org-roam-file-exclude-regexp
Files matching this regular expression are excluded from the Org-roam.
** The Org-roam Buffer ** The Org-roam Buffer
The Org-roam buffer displays backlinks for the currently active Org-roam note. The Org-roam buffer displays backlinks for the currently active Org-roam note.

View File

@ -731,6 +731,11 @@ database is saved here.
It is the users responsibility to set this correctly, especially when used It is the users responsibility to set this correctly, especially when used
with multiple Org-roam instances. with multiple Org-roam instances.
@item
Variable: org-roam-file-exclude-regexp
Files matching this regular expression are excluded from the Org-roam.
@end itemize @end itemize
@node The Org-roam Buffer @node The Org-roam Buffer

View File

@ -100,6 +100,13 @@ ensure that."
:type '(repeat string) :type '(repeat string)
:group 'org-roam) :group 'org-roam)
(defcustom org-roam-file-exclude-regexp nil
"Files matching this regular expression are excluded from the Org-roam."
:type '(choice
(string :tag "Regular expression matching files to ignore")
(const :tag "Include everything" nil))
:group 'org-roam)
(defcustom org-roam-find-file-function nil (defcustom org-roam-find-file-function nil
"Function called when visiting files in Org-roam commands. "Function called when visiting files in Org-roam commands.
If nil, `find-file' is used." If nil, `find-file' is used."
@ -342,6 +349,8 @@ If FILE is not specified, use the current buffer's file-path."
(save-match-data (save-match-data
(and (and
(org-roam--org-file-p path) (org-roam--org-file-p path)
(not (and org-roam-file-exclude-regexp
(string-match-p org-roam-file-exclude-regexp path)))
(f-descendant-of-p (file-truename path) (f-descendant-of-p (file-truename path)
(file-truename org-roam-directory)))))) (file-truename org-roam-directory))))))