emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: Huy <list-orgmode@reml.org>
Cc: emacs-orgmode@gnu.org
Subject: Re: Bug: inline images for filenames with spaces
Date: Thu, 30 Jun 2011 17:41:55 +0200	[thread overview]
Message-ID: <8762nn1g3g.fsf@gnu.org> (raw)
In-Reply-To: <20110629093107.BC5E7C7C0C@fish.malachiarts.com> (Huy's message of "Wed, 29 Jun 2011 02:31:07 -0700")

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

Hi Huy,

Huy <list-orgmode@reml.org> writes:

> inline image display doesn't seem to work for image links with spaces in
> them.  

That's because those images will be inserted as

[[file:image%20with%20space.png][file:image with space.png]]

and such a string is not recognized by the inline displayer.

The attached patch fixes this. 

Please confirm and also take the time to check that there is no
side-effects -- especially wrt the exporter.

E.g. this LaTeX command:

  \includegraphics[width=10em]{image with space.png}

will result in a problem, with the string "with space.png" just
next to the picture.

In any case, it's better to avoid spaces in file names.

Thanks for reporting this,

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org.el-don-t-escape-image-links-with-no-description.patch --]
[-- Type: text/x-patch, Size: 1770 bytes --]

From 84e18e5fb8dbaee425caffb90bdab9f67dc268de Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
Date: Thu, 30 Jun 2011 17:35:23 +0200
Subject: [PATCH] org.el: don't escape image links with no description.

(org-make-link-string): Don't escape image links when no description
is provided by the user.  Otherwise those images won't be recognized
as images when trying to display inline pictures.
 lisp/org.el |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 574ac37..8d71117 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8686,16 +8686,19 @@ according to FMT (default from `org-email-link-description-format')."
       (setq description (replace-match "{" t t description)))
     (while (string-match "\\]" description)
       (setq description (replace-match "}" t t description))))
-  (when (equal (org-link-escape link) description)
+  (when (equal link description)
     ;; No description needed, it is identical
     (setq description nil))
   (when (and (not description)
+	     (not (string-match (org-image-file-name-regexp) link))
 	     (not (equal link (org-link-escape link))))
     (setq description (org-extract-attributes link)))
-  (setq link (if (string-match org-link-types-re link)
-		 (concat (match-string 1 link)
-			 (org-link-escape (substring link (match-end 1))))
-	       (org-link-escape link)))
+  (setq link
+	(cond ((string-match (org-image-file-name-regexp) link) link)
+	      ((string-match org-link-types-re link)
+	       (concat (match-string 1 link)
+		       (org-link-escape (substring link (match-end 1)))))
+	      (t (org-link-escape link))))
   (concat "[[" link "]"
 	  (if description (concat "[" description "]") "")

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


  parent reply	other threads:[~2011-06-30 15:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-29  9:31 Bug: inline images for filenames with spaces Huy
2011-06-29 11:34 ` Manuel Giraud
2011-06-30  6:06   ` Huy
2011-06-30  8:28     ` Bastien
2011-07-01  8:58       ` Bastien
2011-07-01 10:52         ` Manuel Giraud
2011-07-01 16:05           ` Bastien
2011-06-30 15:42   ` Bastien
2011-06-30 15:41 ` Bastien [this message]
2011-07-04 11:23   ` Huy
2011-07-04 12:20     ` Bastien

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:

  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=8762nn1g3g.fsf@gnu.org \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=list-orgmode@reml.org \


* 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


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).