(fix): fix additional buffers opening from ID face (#1130)

`org-roam-id-find` opens the file containing the ID to get the marker.
We don't need to get the exact point for face computation.

Fixes #1129
This commit is contained in:
Jethro Kuan
2020-09-23 13:09:16 +08:00
committed by GitHub
parent cd87cfdd58
commit da6af3a468

View File

@ -1088,15 +1088,21 @@ citation key, for Org-ref cite links."
(unless id (unless id
(org-roam-db--update-headlines)))))) (org-roam-db--update-headlines))))))
(defun org-roam-id-get-file (id)
"Return the file if ID exists in the Org-roam database.
Return nil otherwise."
(caar (org-roam-db-query [:select [file]
:from headlines
:where (= id $s1)
:limit 1]
id)))
(defun org-roam-id-find (id &optional markerp strict) (defun org-roam-id-find (id &optional markerp strict)
"Return the location of the entry with the id ID. "Return the location of the entry with the id ID.
When MARKERP is non-nil, return a marker pointing to theheadline. When MARKERP is non-nil, return a marker pointing to theheadline.
Otherwise, return a cons formatted as \(file . pos). Otherwise, return a cons formatted as \(file . pos).
When STRICT is non-nil, only consider Org-roams database." When STRICT is non-nil, only consider Org-roams database."
(let ((file (or (caar (org-roam-db-query [:select [file] (let ((file (or (org-roam-id-get-file id)
:from headlines
:where (= id $s1)]
id))
(unless strict (unless strict
(org-id-find-id-file id))))) (org-id-find-id-file id)))))
(when file (when file
@ -1478,13 +1484,13 @@ file."
(custom (or (and in-note org-roam-link-use-custom-faces) (custom (or (and in-note org-roam-link-use-custom-faces)
(eq org-roam-link-use-custom-faces 'everywhere)))) (eq org-roam-link-use-custom-faces 'everywhere))))
(cond ((and custom (cond ((and custom
(not (org-roam-id-find id))) (not (org-roam-id-get-file id)))
'org-roam-link-invalid) 'org-roam-link-invalid)
((and (org-roam--in-buffer-p) ((and (org-roam--in-buffer-p)
(org-roam--backlink-to-current-p)) (org-roam--backlink-to-current-p))
'org-roam-link-current) 'org-roam-link-current)
((and custom ((and custom
(org-roam-id-find id)) (org-roam-id-get-file id))
'org-roam-link) 'org-roam-link)
(t (t
'org-link))))) 'org-link)))))