From mboxrd@z Thu Jan 1 00:00:00 1970 From: Baoqiu Cui Subject: Re: Wow -- adding images to an org file Date: Wed, 12 May 2010 00:55:00 -0700 Message-ID: References: <3950.1273620034@iinet.net.au> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=55606 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OC6n2-0005ho-2V for emacs-orgmode@gnu.org; Wed, 12 May 2010 03:55:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OC6mr-00064y-K3 for emacs-orgmode@gnu.org; Wed, 12 May 2010 03:55:30 -0400 Received: from lo.gmane.org ([80.91.229.12]:54389) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OC6ml-00063l-SH for emacs-orgmode@gnu.org; Wed, 12 May 2010 03:55:20 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OC6mg-0005i6-5F for emacs-orgmode@gnu.org; Wed, 12 May 2010 09:55:14 +0200 Received: from nat-dip6.cfw-a-gci.corp.yahoo.com ([209.131.62.115]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 May 2010 09:55:14 +0200 Received: from cbaoqiu by nat-dip6.cfw-a-gci.corp.yahoo.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 12 May 2010 09:55:14 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Hi Carsten, Carsten Dominik writes: > On May 12, 2010, at 7:39 AM, Baoqiu Cui wrote: > > ... > >> I like the idea of inline image display too, but hit the similar >> problems. After reading the code in org.el, I found that the inline >> image file link has to start with either "file:" or "./". >> >> For example, the following two links are OK: >> >> [[file:~/images/myImage.png]] >> [[./figures/org-mode-unicorn.svg]] >> >> but the following two are not: >> >> [[Screenshot.png]] > > This one I do not want to support, because it limits what other things > we > can do with links. > >> [[~/images/myImage.png]] > > This one on the other hand should be supported, I like that. Can you > please modify the patch accordingly? I believe this will also require > corresponding changes in the exporter(s) somewhere... OK, I modified the patch a little bit and came up with a version (see below) that can handle the following 7 cases. Please check if it looks good to you. I don't see any needed exporter changes so far... ------------------------------------------------------------------------ * Test Inline Images 1. [[file:~/Org/GNU.png]] 2. [[file:GNU.png]] 3. [[./figures/GNU.png]] 4. [[../tmp/figures/GNU.png]] 5. [[~/Org/GNU.png]] 6. [[~bcui/Org/GNU.png]] 7. [[/tmp/GNU.png]] ------------------------------------------------------------------------ --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=inline-images-2.diff diff --git a/lisp/org.el b/lisp/org.el index 0381a26..51230b3 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -15502,12 +15502,14 @@ with a description part will be inlined." (interactive "P") (org-remove-inline-images) (goto-char (point-min)) - (let ((re (concat "\\[\\[\\(file:\\|\\./\\)\\(~?" "[-+./_0-9a-zA-Z]+" + (let ((re (concat "\\[\\[\\(\\(file:\\)\\|\\([./~]\\)\\)\\([-+~./_0-9a-zA-Z]+" (substring (org-image-file-name-regexp) 0 -2) "\\)\\]" (if include-linked "" "\\]"))) file ov) (while (re-search-forward re nil t) - (setq file (expand-file-name (match-string 2))) + (setq file (expand-file-name + (concat (or (match-string 3) "") + (match-string 4)))) (when (file-exists-p file) (setq ov (make-overlay (match-beginning 0) (match-end 0))) (overlay-put ov 'display (create-image file)) --=-=-= Thanks, -- Baoqiu --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--