From dd2bbeb47b1c59b1f3aed80832446872cd01b30c Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 26 May 2023 23:45:57 -0700 Subject: [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. --- oni-org/oni-org.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'oni-org') 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 ;; 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 -- cgit v1.2.3-54-g00ecf