branch: externals/denote
commit 3d24ea54ebd5fff5d718ff924cec0199ec9fa85b
Author: Samuel W. Flint <[email protected]>
Commit: Samuel W. Flint <[email protected]>

    Enable preview of denote links
    
    Preview will only happen if there is one file with the denote ID/path,
    and will work with any format supported by `org-link-preview-file`.
---
 denote.el | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/denote.el b/denote.el
index 333713b6d3..94858f1ec6 100644
--- a/denote.el
+++ b/denote.el
@@ -6993,6 +6993,17 @@ backend."
 ;; The `eval-after-load' part with the quoted lambda is adapted from
 ;; Elfeed: <https://github.com/skeeto/elfeed/>.
 
+(declare-function org-link-preview-file "ol" (ov path link))
+
+;;;###autoload
+(defun denote-link-preview-file (ov path link)
+  "Use `org-link-preview-file' for OV, PATH, and LINK.
+
+  Resolve the PATH using `denote-directory-files'."
+  (when-let ((files (denote-directory-files (rx-to-string (list 'and 'bol 
path)))))
+    (when (length= files 1)
+      (org-link-preview-file ov (car files) link))))
+
 ;;;###autoload
 (eval-after-load 'org
   `(funcall
@@ -7003,6 +7014,7 @@ backend."
         (with-no-warnings
           (org-link-set-parameters
            "denote"
+           :preview #'denote-link-preview-file
            :follow #'denote-link-ol-follow
            :face #'denote-get-link-face
            :help-echo #'denote-link-ol-help-echo

Reply via email to