emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Display inline images for shortcuts links
@ 2017-08-17 12:20 Fabrice Popineau
  2017-08-17 13:59 ` Nicolas Goaziou
  0 siblings, 1 reply; 5+ messages in thread
From: Fabrice Popineau @ 2017-08-17 12:20 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1494 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2152 bytes --]

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-18 10:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 12:20 Display inline images for shortcuts links Fabrice Popineau
2017-08-17 13:59 ` Nicolas Goaziou
2017-08-17 20:05   ` Fabrice Popineau
2017-08-18 10:06     ` Fabrice Popineau
2017-08-18 10:27       ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).