emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Display inline images for shortcuts links


From: Fabrice Popineau
Subject: [O] Display inline images for shortcuts links
Date: Thu, 17 Aug 2017 14:20:45 +0200


Would it be possible to enable inline images for shortcuts links ?
Currently, the function `org-display-inline-images' checks for a hard coded file: link.
In the case of :


#+LINK: temp file:c:/temp/%h

[[file:cover.jpg]]

[[temp:cover.jpg]]

The first link will be matched, but not the second one.
(Unless I missed something?)

A small patch like the one attached enables to display inline images for all links.
But maybe relying on the org-element API is not the smarter move here.

( I voluntarily kept the old lines commented in the patch. )

Regards,

Fabrice

diff --git a/lisp/org.el b/lisp/org.el
index b05eac57e..0b45ecec2 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -19398,9 +19398,12 @@ boundaries."
     (org-with-wide-buffer
      (goto-char (or beg (point-min)))
      (let ((case-fold-search t)
-          (file-extension-re (image-file-name-regexp)))
-       (while (re-search-forward "[][]\\[\\(?:file\\|[./~]\\)" end t)
-        (let ((link (save-match-data (org-element-context))))
+          (file-extension-re (image-file-name-regexp))
+           (parse-tree (org-element-parse-buffer)))
+       (org-element-map parse-tree 'link
+         (lambda (link)
+           ;; (while (re-search-forward "[][]\\[\\(?:file\\|[./~]\\)" end t)
+           ;;  (let ((link (save-match-data (org-element-context))))))
            ;; Check if we're at an inline image.
            (when (and (equal (org-element-property :type link) "file")
                       (or include-linked


reply via email to

[Prev in Thread] Current Thread [Next in Thread]