(feat): Add toggle for custom-faces for Org-roam links (#997)
* org-roam.el (org-roam-link-use-custom-faces): New toggle (org-roam--file-link-face): Refactor for new toggle
This commit is contained in:
parent
76d2e3f6b4
commit
30fab7bcc4
1 changed files with 33 additions and 10 deletions
43
org-roam.el
43
org-roam.el
|
@ -1086,22 +1086,45 @@ This function hooks into `org-open-at-point' via
|
||||||
;;;; Function Faces
|
;;;; Function Faces
|
||||||
;; These faces are used by `org-link-set-parameters', which take one argument,
|
;; These faces are used by `org-link-set-parameters', which take one argument,
|
||||||
;; which is the path.
|
;; which is the path.
|
||||||
|
(defcustom org-roam-link-use-custom-faces 'everywhere
|
||||||
|
"Define where to apply custom faces to Org-roam links.
|
||||||
|
|
||||||
|
Valide values are:
|
||||||
|
|
||||||
|
t Use custom faces inside Org-roam notes (i.e. files in
|
||||||
|
`org-roam-directory'.)
|
||||||
|
|
||||||
|
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))
|
||||||
|
:group 'org-roam)
|
||||||
|
|
||||||
(defun org-roam--file-link-face (path)
|
(defun org-roam--file-link-face (path)
|
||||||
"Conditional face for file: links.
|
"Conditional face for file: links.
|
||||||
Applies `org-roam-link-current' if PATH corresponds to the
|
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."
|
||||||
(cond ((and (not (file-remote-p path)) ;; Prevent lockups opening Tramp links
|
(let* ((in-note (-> (buffer-file-name (buffer-base-buffer))
|
||||||
(not (file-exists-p path)))
|
(org-roam--org-roam-file-p)))
|
||||||
'org-roam-link-invalid)
|
(custom (or (and in-note org-roam-link-use-custom-faces)
|
||||||
((and (org-roam--in-buffer-p)
|
(eq org-roam-link-use-custom-faces 'everywhere))))
|
||||||
(org-roam--backlink-to-current-p))
|
(cond ((and custom
|
||||||
'org-roam-link-current)
|
(not (file-remote-p path)) ;; Prevent lockups opening Tramp links
|
||||||
((org-roam--org-roam-file-p path)
|
(not (file-exists-p path)))
|
||||||
'org-roam-link)
|
'org-roam-link-invalid)
|
||||||
(t
|
((and (org-roam--in-buffer-p)
|
||||||
'org-link)))
|
(org-roam--backlink-to-current-p))
|
||||||
|
'org-roam-link-current)
|
||||||
|
((and custom
|
||||||
|
(org-roam--org-roam-file-p path))
|
||||||
|
'org-roam-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.
|
||||||
|
|
Loading…
Reference in a new issue