emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Steven Allen <steven@stebalien.com>
To: Ihor Radchenko <yantar92@posteo.net>
Subject: Re: [PATCH] org.el: inline display of attached images in link descriptions
Date: Fri, 02 Jun 2023 08:33:21 -0700	[thread overview]
Message-ID: <875y85dgla.fsf@stebalien.com> (raw)
In-Reply-To: <87fs7a5mpx.fsf@localhost>

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


You're right.... and now I have no idea what I was testing. I'm
apologize for that.

The attached patch should actually work this time. It's not great (setq
in a let), but anything else would likely be a much larger change.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: inline-image-attachement.patch --]
[-- Type: text/x-patch, Size: 2118 bytes --]

From 6ca24ca705fc3856c68957cfa50dfce77c9148c9 Mon Sep 17 00:00:00 2001
From: Steven Allen <steven@stebalien.com>
Date: Thu, 1 Jun 2023 11:49:19 -0700
Subject: [PATCH] org.el: inline display of attached images in link
 descriptions

* lisp/org.el (org-display-inline-images): inline display of attached
images in link descriptions.

Previously, `org-display-inline-images' only inlined images in link
descriptions when they were explicit "file:" links. This change adds
support for "attachment:" links. E.g.:

    [[https://orgmode.org][attachment:emacs-screenshot.png]]
---
 lisp/org.el | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 0e5740412..405cae9a5 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16301,7 +16301,8 @@ defun org-create-formula-image
 
   2. Its description consists in a single link of the previous
      type.  In this case, that link must be a well-formed plain
-     or angle link, i.e., it must have an explicit \"file\" type.
+     or angle link, i.e., it must have an explicit \"file\" or
+     \"attachment\" type.
 
 Equip each image with the key-map `image-map'.
 
@@ -16332,7 +16333,7 @@ defun org-create-formula-image
 	       ;; "file:" links.  Also check link abbreviations since
 	       ;; some might expand to "file" links.
 	       (file-types-re
-		(format "\\[\\[\\(?:file%s:\\|attachment:\\|[./~]\\)\\|\\]\\[\\(<?file:\\)"
+		(format "\\[\\[\\(?:file%s:\\|attachment:\\|[./~]\\)\\|\\]\\[\\(<?\\(?:file\\|attachment\\):\\)"
 			(if (not link-abbrevs) ""
 			  (concat "\\|" (regexp-opt link-abbrevs))))))
 	  (while (re-search-forward file-types-re end t)
@@ -16371,7 +16372,9 @@ defun org-create-formula-image
 			     ;; description.
 			     (= (org-element-property :contents-end link)
 				(match-end 0))
-			     (match-string 2)))))))
+			     (progn
+                               (setq linktype (match-string 1))
+                               (match-string 2))))))))
 	      (when (and path (string-match-p file-extension-re path))
 		(let ((file (if (equal "attachment" linktype)
 				(progn
-- 
2.40.1


      reply	other threads:[~2023-06-02 15:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 19:13 [PATCH] org.el: inline display of attached images in link descriptions Steven Allen
2023-06-02  7:48 ` Ihor Radchenko
2023-06-02 15:33   ` Steven Allen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875y85dgla.fsf@stebalien.com \
    --to=steven@stebalien.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).