From mboxrd@z Thu Jan 1 00:00:00 1970 From: "numbchild@gmail.com" Subject: Re: Let Org-mode babel file result support relative link type by using org-link-file-path-type Date: Mon, 13 Mar 2017 09:49:00 +0800 Message-ID: References: <87efy2ljrm.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114fd5b2202def054a92ec01 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:39012) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnF77-0004h8-Kf for emacs-orgmode@gnu.org; Sun, 12 Mar 2017 21:49:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnF75-0002DW-Q7 for emacs-orgmode@gnu.org; Sun, 12 Mar 2017 21:49:33 -0400 Received: from mail-io0-x229.google.com ([2607:f8b0:4001:c06::229]:36505) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cnF75-0002DG-H2 for emacs-orgmode@gnu.org; Sun, 12 Mar 2017 21:49:31 -0400 Received: by mail-io0-x229.google.com with SMTP id l7so76020089ioe.3 for ; Sun, 12 Mar 2017 18:49:31 -0700 (PDT) In-Reply-To: <87efy2ljrm.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: Org-mode --001a114fd5b2202def054a92ec01 Content-Type: text/plain; charset=UTF-8 * Does Org-mode `:output-dir` header-argument? Or is `:dir`? * An example I can make it (`:results file :file "FILENAME"`) work in `ob-python` like this: ```org #+BEGIN_SRC python :var fname="QR_I_Love_YOU.png" :dir "data/images" :results file import qrcode img = qrcode.make("I Love YOU") img.save(fname) return fname #+END_SRC #+RESULTS: [[file:/home/stardiviner/Org/Wiki/Computer Technology/Programming/Programming Languages/Python/Data/Packages/data/images/QR_I_Love_YOU.png]] ``` * More specific suggestion: Make use of org-mode variable `org-link-file-path-type`. When user generate a result with link (like: ```org #+RESULTS: [[file:/home/stardiviner/Org/Wiki/Computer Technology/Programming/Programming Languages/Python/Data/Packages/data/images/QR_I_Love_YOU.png]] ``` Org-mode babel always use relative file path for link, instead of absolute file path like upper example. For example, if current path is `/home/stardiviner/Org/Wiki/Computer Technology/Programming/Programming Languages/Python/Data/Packages/`, then the relative file path link should be: ```org #+RESULTS: [[file:data/images/QR_I_Love_YOU.png]] ``` * About what one preceduce over the other problem The header argument `:dir "data/images"` is used to specify my generated image's destination directory. My suggestion is want a the result link use `org-link-file-path-type`. So the header argument `:dir` is not about the result link. Just it will be used. Like upper example. [stardiviner] GPG key ID: 47C32433 IRC(freeenode): stardiviner Twitter: @numbchild Key fingerprint = 9BAA 92BC CDDD B9EF 3B36 CB99 B8C4 B8E5 47C3 2433 Blog: http://stardiviner.github.io/ On Sun, Mar 12, 2017 at 9:14 PM, Nicolas Goaziou wrote: > Hello, > > "numbchild@gmail.com" writes: > > > Let Org-mode babel file result support relative (adaptive) link type by > > using `org-link-file-path-type`. > > > > This also can solve static site generator extensions (like `ob-blog.el` > > etc) image link path issue. > > > > Also better if user changed parent directory name, those links will have > to > > updated too. But if `adaptive` `org-link-file-path-type` will solve this > > problem. > > > > So please let Org-mode babel header arguments `:results file :file > > "filename.png"` use `org-link-file-path-type` variable. > > It sounds interesting. Could you be more specific about the > specifications of your suggestion. > > For example, what happens when :output-dir is set, or when :file already > provides some directory part? What part takes precedence over the other? > > Better, could you show some examples, or some tests? > > Regards, > > -- > Nicolas Goaziou > --001a114fd5b2202def054a92ec01 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
* Does Org-mode `:output-dir` header-argument?= Or is `:dir`?

* An example

I can make it (`:results file :file "FI= LENAME"`) work in `ob-python` like this:

```org
#+BEGIN_SRC python :var fname= =3D"QR_I_Love_YOU.png" :dir "data/images" :results file=
import qrcode

img =3D qrcode.make("I Love YOU&= quot;)
img.save(fname)
return fname
#+END_SRC

<= /font>
#+RESULTS:
[[file:/home/stardiviner/Org/Wiki/Computer Technolog= y/Programming/Programming Languages/Python/Data/Packages/data/images/QR_I_L= ove_YOU.png]]
```

* More specific suggestion:

Make use of org-mode variable `org-link-file-pa= th-type`.
When user generate a result with link (like:=C2=A0

```org
#+RESULTS:
[[file:/home/stardiviner/Org/Wiki/Computer Technol= ogy/Programming/Programming Languages/Python/Data/Packages/data/images/QR_I= _Love_YOU.png]]
```

Org-mode babel always u= se relative file path for link, instead of absolute file path like upper ex= ample.
For example= , if current path is `/home/stardiviner/Org/Wiki/Computer Technology/Progra= mming/Programming Languages/Python/Data/Packages/`, then the relative file = path link should be:

```org
#+RESULTS:
=
[[file:data/images/QR_I_Love_YOU.png]]
```

<= div style=3D"font-family:"trebuchet ms",sans-serif">* About what = one preceduce over the other problem

The header argument `:dir "data/images&quo= t;` is used to specify my generated image's destination directory.
My suggesti= on is want a the result link use `org-link-file-path-type`. So the header a= rgument `:dir` is not about the result link. Just it will be used. Like upp= er example.


[stardiviner]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 <Hack this world!>=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 GPG key ID: 47C32433
IRC(freeenode): stardiviner =C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Twitter:=C2=A0 @numbchild
Key fingerprint= =3D 9BAA 92BC CDDD B9EF 3B36=C2=A0 CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.g= ithub.io/

On Sun, Mar 12, 2017 at 9:14 PM, Nicolas Goa= ziou <mail@nicolasgoaziou.fr> wrote:
Hello,

"numbchild@gmail.com" = <numbchild@gmail.com> writ= es:

> Let Org-mode babel file result support relative (adaptive) link type b= y
> using `org-link-file-path-type`.
>
> This also can solve static site generator extensions (like `ob-blog.el= `
> etc) image link path issue.
>
> Also better if user changed parent directory name, those links will ha= ve to
> updated too. But if `adaptive` `org-link-file-path-type` will solve th= is
> problem.
>
> So please let Org-mode babel header arguments `:results file :file
> "filename.png"` use `org-link-file-path-type` variable.

It sounds interesting. Could you be more specific about the
specifications of your suggestion.

For example, what happens when :output-dir is set, or when :file already provides some directory part? What part takes precedence over the other?
Better, could you show some examples, or some tests?

Regards,

--
Nicolas Goaziou

--001a114fd5b2202def054a92ec01--