Allow word boundary regex to be customized for unlinked reference #2359
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation for this change
The unlinked references are searched for by ripgrep using a simple regex pattern
(\b%s\b
). This works fine with English, but in a language for which the concept of regex word boundary doesn't apply (e.g., CJK), the pattern doesn't work. The issue #1290 for Chinese is an example.This PR introduces
org-roam-unlinked-references-word-boundary-re
custom variable so that users can modify the regex pattern used by ripgrep.For example, adding a pattern like this
(set-q org-roam-unlinked-references-word-boundary-re "|(\\b%1$s\\b|(?<=[^\x20-\x7e\xff61-\xff9f])%1$s(?=[^\x20-\x7e\xff61-\xff9f]))")
the regex would work sufficiently well in both English and Japanese.
This PR should fix #1290, though improving regex pattern is delegated to users.