emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: inline images for filenames with spaces
@ 2011-06-29  9:31 Huy
  2011-06-29 11:34 ` Manuel Giraud
  2011-06-30 15:41 ` Bastien
  0 siblings, 2 replies; 11+ messages in thread
From: Huy @ 2011-06-29  9:31 UTC (permalink / raw)
  To: emacs-orgmode

Hi,
inline image display doesn't seem to work for image links with spaces in
them.  However, clicking on the image links does work: a window shows
the image.

Example:
[[file:img/test.png]] will display inline
[[file:img/test copy.png]] won't

I'm using the latest org-mode sources in git as of a few minutes ago on:
GNU Emacs 23.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.35) of
2011-03-10 on black.porkrind.org

Thanks,
Huy

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

* Re: Bug: inline images for filenames with spaces
  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 15:42   ` Bastien
  2011-06-30 15:41 ` Bastien
  1 sibling, 2 replies; 11+ messages in thread
From: Manuel Giraud @ 2011-06-29 11:34 UTC (permalink / raw)
  To: Huy; +Cc: emacs-orgmode

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

> Example:
> [[file:img/test.png]] will display inline
> [[file:img/test copy.png]] won't

Just tested on the same emacs version and few minutes old org-mode and
both works for me. How do you export? Do you have some special settings?

-- 
Manuel Giraud

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

* Re: Bug: inline images for filenames with spaces
  2011-06-29 11:34 ` Manuel Giraud
@ 2011-06-30  6:06   ` Huy
  2011-06-30  8:28     ` Bastien
  2011-06-30 15:42   ` Bastien
  1 sibling, 1 reply; 11+ messages in thread
From: Huy @ 2011-06-30  6:06 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: emacs-orgmode


I'm not exporting.
I'm just doing C-c C-x C-v to display the inline images within emacs.

On Wed, Jun 29, 2011 at 01:34:36PM +0200, Manuel Giraud wrote:
> Huy <list-orgmode@reml.org> writes:
> 
> > Example:
> > [[file:img/test.png]] will display inline
> > [[file:img/test copy.png]] won't
> 
> Just tested on the same emacs version and few minutes old org-mode and
> both works for me. How do you export? Do you have some special settings?
> 
> -- 
> Manuel Giraud
> 

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

* Re: Bug: inline images for filenames with spaces
  2011-06-30  6:06   ` Huy
@ 2011-06-30  8:28     ` Bastien
  2011-07-01  8:58       ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2011-06-30  8:28 UTC (permalink / raw)
  To: Huy; +Cc: emacs-orgmode, Manuel Giraud

Hi Huy,

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

> I'm not exporting.
> I'm just doing C-c C-x C-v to display the inline images within emacs.

I confirm there is a bug here, I'm on it.

-- 
 Bastien

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

* Re: Bug: inline images for filenames with spaces
  2011-06-29  9:31 Bug: inline images for filenames with spaces Huy
  2011-06-29 11:34 ` Manuel Giraud
@ 2011-06-30 15:41 ` Bastien
  2011-07-04 11:23   ` Huy
  1 sibling, 1 reply; 11+ messages in thread
From: Bastien @ 2011-06-30 15:41 UTC (permalink / raw)
  To: Huy; +Cc: emacs-orgmode

[-- 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 "]") "")
 	  "]"))
-- 
1.7.5.2


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


-- 
 Bastien

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

* Re: Bug: inline images for filenames with spaces
  2011-06-29 11:34 ` Manuel Giraud
  2011-06-30  6:06   ` Huy
@ 2011-06-30 15:42   ` Bastien
  1 sibling, 0 replies; 11+ messages in thread
From: Bastien @ 2011-06-30 15:42 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Huy, emacs-orgmode

Hi Manuel,

Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:

> Huy <list-orgmode@reml.org> writes:
>
>> Example:
>> [[file:img/test.png]] will display inline
>> [[file:img/test copy.png]] won't
>
> Just tested on the same emacs version and few minutes old org-mode and
> both works for me. How do you export? Do you have some special
> settings?

That's because you need to actually test this:


[[file:img/test.png][file:img/test.png]]
[[file:img/test%20copy.png][file:img/test copy.png]]

... where you can reproduce the error.

HTH,

-- 
 Bastien

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

* Re: Bug: inline images for filenames with spaces
  2011-06-30  8:28     ` Bastien
@ 2011-07-01  8:58       ` Bastien
  2011-07-01 10:52         ` Manuel Giraud
  0 siblings, 1 reply; 11+ messages in thread
From: Bastien @ 2011-07-01  8:58 UTC (permalink / raw)
  To: Huy; +Cc: emacs-orgmode, Manuel Giraud

Hi Huy,

Bastien <bzg@altern.org> writes:

>> I'm not exporting.
>> I'm just doing C-c C-x C-v to display the inline images within emacs.
>
> I confirm there is a bug here, I'm on it.

I've pushed the fix now, please test it!

Thanks,

-- 
 Bastien

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

* Re: Bug: inline images for filenames with spaces
  2011-07-01  8:58       ` Bastien
@ 2011-07-01 10:52         ` Manuel Giraud
  2011-07-01 16:05           ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Manuel Giraud @ 2011-07-01 10:52 UTC (permalink / raw)
  To: Bastien; +Cc: Huy, emacs-orgmode

Bastien <bzg@altern.org> writes:

> Hi Huy,
>
> Bastien <bzg@altern.org> writes:
>
>>> I'm not exporting.
>>> I'm just doing C-c C-x C-v to display the inline images within emacs.
>>
>> I confirm there is a bug here, I'm on it.
>
> I've pushed the fix now, please test it!

I've tested your patch. It works with org-toggle-inline-image, export to
HTML and to LaTeX.

AFAIU, now a link to an inline image inserted with org-insert-link will
expand into [[file name.jpg]] instead of [[file%20name.jpg][file
name.jpg]].  But the later form still doesn't work so it have to be
fixed into older org files.

Best,
-- 
Manuel Giraud

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

* Re: Bug: inline images for filenames with spaces
  2011-07-01 10:52         ` Manuel Giraud
@ 2011-07-01 16:05           ` Bastien
  0 siblings, 0 replies; 11+ messages in thread
From: Bastien @ 2011-07-01 16:05 UTC (permalink / raw)
  To: Manuel Giraud; +Cc: Huy, emacs-orgmode

Hi Manuel,

Manuel Giraud <manuel.giraud@univ-nantes.fr> writes:

> AFAIU, now a link to an inline image inserted with org-insert-link will
> expand into [[file name.jpg]] instead of [[file%20name.jpg][file
> name.jpg]].  But the later form still doesn't work so it have to be
> fixed into older org files.

Yes, exactly.

-- 
 Bastien

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

* Re: Bug: inline images for filenames with spaces
  2011-06-30 15:41 ` Bastien
@ 2011-07-04 11:23   ` Huy
  2011-07-04 12:20     ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Huy @ 2011-07-04 11:23 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

On Thu, Jun 30, 2011 at 05:41:55PM +0200, Bastien wrote:
> Hi Huy,
> 
> Huy <list-orgmode@reml.org> writes:
> 
> > inline image display doesn't seem to work for image links with spaces in
> > them.  
> 
> The attached patch fixes this. 
> 
> Please confirm and also take the time to check that there is no
> side-effects -- especially wrt the exporter.

Sorry, it took me long to get back.

I confirm that the current repo fixed it, bt I can't confirm exporting.
I don't know how to do any exporting yet.

Thanks for the fix!
Huy

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

* Re: Bug: inline images for filenames with spaces
  2011-07-04 11:23   ` Huy
@ 2011-07-04 12:20     ` Bastien
  0 siblings, 0 replies; 11+ messages in thread
From: Bastien @ 2011-07-04 12:20 UTC (permalink / raw)
  To: Huy; +Cc: emacs-orgmode

Hi Huy,

Thanks for confirming the fix is okay!

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

> I don't know how to do any exporting yet.

Try the magic keystroke in any Org file: C-c C-e 

HTH,

-- 
 Bastien

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

end of thread, other threads:[~2011-07-04 12:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2011-07-04 11:23   ` Huy
2011-07-04 12:20     ` Bastien

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