(fix): fix org-agenda hangs on face computation (#1101)

Org expects face functions to save-match-data, or it would lead to
infinite recursions with use of some Org functionality such as
org-agenda (h.t. @myshevchuk for figuring this out)

Fixes #1096 and fixes #1045.
This commit is contained in:
Jethro Kuan
2020-09-13 20:42:28 +08:00
committed by GitHub
parent da507a5bee
commit efb592907e

View File

@ -1440,22 +1440,23 @@ Applies `org-roam-link-current' if PATH corresponds to the
currently opened Org-roam file in the backlink buffer, or currently opened Org-roam file in the backlink buffer, or
`org-roam-link-face' if PATH corresponds to any other Org-roam `org-roam-link-face' if PATH corresponds to any other Org-roam
file." file."
(let* ((in-note (-> (buffer-file-name (buffer-base-buffer)) (save-match-data
(org-roam--org-roam-file-p))) (let* ((in-note (-> (buffer-file-name (buffer-base-buffer))
(custom (or (and in-note org-roam-link-use-custom-faces) (org-roam--org-roam-file-p)))
(eq org-roam-link-use-custom-faces 'everywhere)))) (custom (or (and in-note org-roam-link-use-custom-faces)
(cond ((and custom (eq org-roam-link-use-custom-faces 'everywhere))))
(not (file-remote-p path)) ;; Prevent lockups opening Tramp links (cond ((and custom
(not (file-exists-p path))) (not (file-remote-p path)) ;; Prevent lockups opening Tramp links
'org-roam-link-invalid) (not (file-exists-p path)))
((and (org-roam--in-buffer-p) 'org-roam-link-invalid)
(org-roam--backlink-to-current-p)) ((and (org-roam--in-buffer-p)
'org-roam-link-current) (org-roam--backlink-to-current-p))
((and custom 'org-roam-link-current)
(org-roam--org-roam-file-p path)) ((and custom
'org-roam-link) (org-roam--org-roam-file-p path))
(t 'org-roam-link)
'org-link)))) (t
'org-link)))))
(defun org-roam--id-link-face (id) (defun org-roam--id-link-face (id)
"Conditional face for id links. "Conditional face for id links.
@ -1463,21 +1464,22 @@ Applies `org-roam-link-current' if ID corresponds to the
currently opened Org-roam file in the backlink buffer, or currently opened Org-roam file in the backlink buffer, or
`org-roam-link-face' if ID corresponds to any other Org-roam `org-roam-link-face' if ID corresponds to any other Org-roam
file." file."
(let* ((in-note (-> (buffer-file-name (buffer-base-buffer)) (save-match-data
(org-roam--org-roam-file-p))) (let* ((in-note (-> (buffer-file-name (buffer-base-buffer))
(custom (or (and in-note org-roam-link-use-custom-faces) (org-roam--org-roam-file-p)))
(eq org-roam-link-use-custom-faces 'everywhere)))) (custom (or (and in-note org-roam-link-use-custom-faces)
(cond ((and custom (eq org-roam-link-use-custom-faces 'everywhere))))
(not (org-roam-id-find id))) (cond ((and custom
'org-roam-link-invalid) (not (org-roam-id-find id)))
((and (org-roam--in-buffer-p) 'org-roam-link-invalid)
(org-roam--backlink-to-current-p)) ((and (org-roam--in-buffer-p)
'org-roam-link-current) (org-roam--backlink-to-current-p))
((and custom 'org-roam-link-current)
(org-roam-id-find id)) ((and custom
'org-roam-link) (org-roam-id-find id))
(t 'org-roam-link)
'org-link)))) (t
'org-link)))))
(defun org-roam--queue-file-for-update (&optional file-path) (defun org-roam--queue-file-for-update (&optional file-path)
"Queue FILE-PATH for `org-roam' database update. "Queue FILE-PATH for `org-roam' database update.