From d2efb01d29ee6d03954e158799b51127d07b2a64 Mon Sep 17 00:00:00 2001 From: 45mg <45mg@no.mail> Date: Fri, 28 Jun 2024 06:18:23 +0000 Subject: [PATCH] fix(org): attachment image inline preview Fix originally proposed by Khoulaiz here: https://github.com/doomemacs/doomemacs/issues/7222#issuecomment-1535932540 Fix: #7222 #3185 Co-authored-by: Andreas Sahlbach --- modules/lang/org/autoload/org-link.el | 18 ++++++++---------- modules/lang/org/config.el | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/lang/org/autoload/org-link.el b/modules/lang/org/autoload/org-link.el index aea9d0084..ff29cac19 100644 --- a/modules/lang/org/autoload/org-link.el +++ b/modules/lang/org/autoload/org-link.el @@ -316,16 +316,14 @@ exist, and `org-link' otherwise." (defun +org-image-file-data-fn (protocol link _description) "Intepret LINK as an image file path and return its data." (setq - link (expand-file-name - link (pcase protocol - ("download" - (or (if (require 'org-download nil t) org-download-image-dir) - (if (require 'org-attach) org-attach-id-dir) - default-directory)) - ("attachment" - (require 'org-attach) - org-attach-id-dir) - (_ default-directory)))) + link (pcase protocol + ("download" + (expand-file-name link (or (if (require 'org-download nil t) org-download-image-dir) + default-directory))) + ("attachment" + (require 'org-attach) + (org-attach-expand link)) + (_ (expand-file-name link default-directory)))) (when (and (file-exists-p link) (image-type-from-file-name link)) (with-temp-buffer diff --git a/modules/lang/org/config.el b/modules/lang/org/config.el index 0d34604da..fb297e1c4 100644 --- a/modules/lang/org/config.el +++ b/modules/lang/org/config.el @@ -494,7 +494,7 @@ relative to `org-directory', unless it is an absolute path." (add-to-list 'projectile-globally-ignored-directories org-attach-id-dir))) ;; Add inline image previews for attachment links - (org-link-set-parameters "attachment" :image-data-fun #'+org-inline-image-data-fn)) + (org-link-set-parameters "attachment" :image-data-fun #'+org-image-file-data-fn)) (defun +org-init-custom-links-h ()