(fix): fall back to org-id search ID face computation (#1195)

* (fix): fall back to org-id search ID face computation

Fixes the scenario where the face is reported as invalid although it is
part of Org's ID files (e.g. in the agenda).

Fixes #1191.

This can however slow face computation a lot (when there are many org
id/agenda files). Here, we choose to focus on correctness.

* Document faces, default to only applying to Org-roam notes
This commit is contained in:
Jethro Kuan
2020-10-19 13:47:07 +08:00
committed by GitHub
parent 09fd41ce24
commit 5d483f2d4d
4 changed files with 52 additions and 6 deletions

View File

@ -1190,7 +1190,7 @@ This is active when `org-roam-completion-everywhere' is non-nil."
;;;; Function Faces
;; These faces are used by `org-link-set-parameters', which take one argument,
;; which is the path.
(defcustom org-roam-link-use-custom-faces 'everywhere
(defcustom org-roam-link-use-custom-faces t
"Define where to apply custom faces to Org-roam links.
Valide values are:
@ -1202,9 +1202,9 @@ everywhere Apply custom faces everywhere.
Otherwise, do not apply custom faces to Org-roam links."
:type '(choice
(const :tag "Use custom faces inside Org-roam notes" t)
(const :tag "Apply custom faces everywhere" everywhere)
(const :tag "Do not apply custom faces" nil))
(const :tag "Use custom faces inside Org-roam notes" t)
(const :tag "Apply custom faces everywhere" everywhere)
(const :tag "Do not apply custom faces" nil))
:group 'org-roam)
(defun org-roam--file-link-face (path)
@ -1243,7 +1243,9 @@ file."
(custom (or (and in-note org-roam-link-use-custom-faces)
(eq org-roam-link-use-custom-faces 'everywhere))))
(cond ((and custom
(not (org-roam-id-get-file id)))
(not (org-roam-id-get-file id))
(not (and (eq org-roam-link-use-custom-faces 'everywhere)
(org-id-find id))))
'org-roam-link-invalid)
((and (org-roam--in-buffer-p)
(org-roam--backlink-to-current-p))