(feat): reintroduce org-roam-link-current face (#516)

This commit is contained in:
Leo Vivier
2020-04-30 14:20:33 +02:00
committed by GitHub
parent e05ee1240d
commit 08aa5c630d

View File

@@ -603,20 +603,46 @@ INFO is an alist containing additional information."
;;;; org-roam-link-face ;;;; org-roam-link-face
(defface org-roam-link (defface org-roam-link
'((t :inherit org-link)) '((t :inherit org-link))
"Face for org-roam link." "Face for Org-roam links."
:group 'org-roam-faces) :group 'org-roam-faces)
(defface org-roam-backlink (defface org-roam-link-current
'((t :inherit org-block)) '((t :inherit org-block))
"Face for org-roam backlinks in backlinks buffer" "Face for Org-roam links pointing to the current buffer."
:group 'org-roam-faces) :group 'org-roam-faces)
(defun org-roam--in-buffer-p ()
"Return t if in the Org-roam buffer."
(and (boundp org-roam-backlinks-mode)
org-roam-backlinks-mode))
(defun org-roam--retrieve-link-path (&optional pom)
"Retrieve the path of the link at POM.
The point-or-marker POM can either be a position in the current
buffer or a marker."
(let ((pom (or pom (point))))
(org-with-point-at pom
(plist-get (cadr (org-element-context)) :path))))
(defun org-roam--backlink-to-current-p ()
"Return t if backlink is to the current Org-roam file."
(let ((current (buffer-file-name org-roam-buffer--current))
(backlink-dest (org-roam--retrieve-link-path)))
(string= current backlink-dest)))
(defun org-roam--roam-link-face (path) (defun org-roam--roam-link-face (path)
"Conditional face for org file links. "Conditional face for org file links.
Applies `org-roam-link-face' if PATH corresponds to a Roam file." Applies `org-roam-link-current' if PATH corresponds to the
(if (org-roam--org-roam-file-p path) currently opened Org-roam file in the backlink buffer, or
'org-roam-link `org-roam-link-face' if PATH corresponds to any other Org-roam
'org-link)) file."
(cond ((and (org-roam--in-buffer-p)
(org-roam--backlink-to-current-p))
'org-roam-link-current)
((org-roam--org-roam-file-p path)
'org-roam-link)
(t
'org-link)))
;;;; org-roam-backlinks-mode ;;;; org-roam-backlinks-mode
(defvar org-roam-backlinks-mode-map (defvar org-roam-backlinks-mode-map