From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabrice Popineau Subject: Display inline images for shortcuts links Date: Thu, 17 Aug 2017 14:20:45 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="089e08225dacf3c3c80556f20b35" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diJnR-0005Dq-Qx for emacs-orgmode@gnu.org; Thu, 17 Aug 2017 08:21:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diJnQ-000564-Ig for emacs-orgmode@gnu.org; Thu, 17 Aug 2017 08:21:09 -0400 Received: from mail-qt0-x234.google.com ([2607:f8b0:400d:c0d::234]:33336) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1diJnQ-00055E-BZ for emacs-orgmode@gnu.org; Thu, 17 Aug 2017 08:21:08 -0400 Received: by mail-qt0-x234.google.com with SMTP id a18so36423706qta.0 for ; Thu, 17 Aug 2017 05:21:06 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "emacs-orgmode@gnu.org" --089e08225dacf3c3c80556f20b35 Content-Type: text/plain; charset="UTF-8" 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 --089e08225dacf3c3c80556f20b35 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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 ca= se of :


#+LINK: temp file:c:/t= emp/%h

[[file:cover.jpg]]

[[temp:cover.jpg]]

The first link will be m= atched, 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 i= s 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 +1= 9398,12 @@ boundaries."
=C2=A0 =C2=A0 =C2=A0(org-with-wide-b= uffer
=C2=A0 =C2=A0 =C2=A0 (goto-char (or beg (point-min)))
=
=C2=A0 =C2=A0 =C2=A0 (let ((case-fold-search t)
- =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(file-extension-re (image-file-name-regexp)))
=
- =C2=A0 =C2=A0 =C2=A0 (while (re-search-forward "[][]\\[\\(?:fil= e\\|[./~]\\)" end t)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((lin= k (save-match-data (org-element-context))))
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(file-extension-re (image-file-name-regexp))
+ = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (parse-tree (org-element-parse-buffer)))=
+ =C2=A0 =C2=A0 =C2=A0 (org-element-map parse-tree 'link
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda (link)
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 ;; (while (re-search-forward "[][]\\[\\(?:fil= e\\|[./~]\\)" end t)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;;= =C2=A0(let ((link (save-match-data (org-element-context))))))
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Check if we're at an inlin= e image.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (when (and (eq= ual (org-element-property :type link) "file")
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(or include-linked

--089e08225dacf3c3c80556f20b35--