aboutsummaryrefslogtreecommitdiffstats
path: root/oni-org
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-05-26 23:45:57 -0700
committerGravatar Tom Willemse2023-05-26 23:45:57 -0700
commitdd2bbeb47b1c59b1f3aed80832446872cd01b30c (patch)
tree9a322a9948d48917e31a716e66071490f707160c /oni-org
parentec54fa9d049c349701039a4b3ee9150505a1a1cb (diff)
downloademacs-config-dd2bbeb47b1c59b1f3aed80832446872cd01b30c.tar.gz
emacs-config-dd2bbeb47b1c59b1f3aed80832446872cd01b30c.zip
[oni-org] Change the way file links are displayed in org-mode
If a file link points to a file that doesn't exist, display it similarly to an error.
Diffstat (limited to 'oni-org')
-rw-r--r--oni-org/oni-org.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el
index 6dd9c66..400a569 100644
--- a/oni-org/oni-org.el
+++ b/oni-org/oni-org.el
@@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
-;; Version: 2023.0517.001154
+;; Version: 2023.0526.234458
;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-bullets org-edna diminish all-the-icons olivetti form-feed org-pretty-table)
;; This program is free software; you can redistribute it and/or modify
@@ -1192,5 +1192,21 @@ placed above TARGET. Otherwise it will be placed below it."
(insert "\n"))
(goto-char (point-min))))
+;;; Add face to file links that show file doesn't exist.
+
+(defface oni-org-link-nonexitent-file
+ '((t :inherit error :underline t :weight regular))
+ "Face to display links that point to nonexistent files in.")
+
+(defun oni-org-file-face-selector (path)
+ "Return a different face based on whether PATH exists or not.
+When PATH exists just return the face ‘org-link’ as usual,
+otherwise return ‘oni-org-link-nonexistent-file’."
+ (if (file-exists-p path)
+ 'org-link
+ 'oni-org-link-nonexistent-file))
+
+(org-link-set-parameters "file" :face #'oni-org-file-face-selector)
+
(provide 'oni-org)
;;; oni-org.el ends here