1
0
Fork 0

[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.
This commit is contained in:
Tom Willemse 2023-05-26 23:45:57 -07:00
parent ec54fa9d04
commit dd2bbeb47b

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org> ;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local ;; 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) ;; 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 ;; 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")) (insert "\n"))
(goto-char (point-min)))) (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) (provide 'oni-org)
;;; oni-org.el ends here ;;; oni-org.el ends here