From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: How to let ob-shell to download file and get result as a link to file? Date: Mon, 26 Mar 2018 23:35:17 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------69E742EE18D901EE3D064523" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0U9g-0003dy-4N for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 11:35:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0U9b-0000W7-7v for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 11:35:28 -0400 Received: from mail-pl0-x235.google.com ([2607:f8b0:400e:c01::235]:46080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0U9b-0000Vk-09 for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 11:35:23 -0400 Received: by mail-pl0-x235.google.com with SMTP id f5-v6so12147448plj.13 for ; Mon, 26 Mar 2018 08:35:22 -0700 (PDT) Received: from [0.0.0.0] ([119.28.89.243]) by smtp.gmail.com with ESMTPSA id z65sm9361587pgz.24.2018.03.26.08.35.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 08:35:20 -0700 (PDT) Content-Language: en-US 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: org-mode This is a multi-part message in MIME format. --------------69E742EE18D901EE3D064523 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I tried the following example: ``` #+begin_src shell :mkdir yes :dir "data/tmp" :results file :file "crackzor_1.0.c.gz" wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" #+end_src #+RESULTS: [[file:data/tmp/crackzor_1.0.c.gz]] ``` But the files is empty, I check out Org-mode document about `:file` header argument, seems org-babel will write result to `:file` specified file. I wander how I can handle upper case correctly? (don't write result to file, just insert a link to downloaded file as a result) --------------69E742EE18D901EE3D064523 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

I tried the following example:

```

#+begin_src shell :mkdir yes :dir "data/tmp" :results file :file "crackzor_1.0.c.gz"
wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz"
#+end_src

#+RESULTS:
[[file:data/tmp/crackzor_1.0.c.gz]]
```

But the files is empty, I check out Org-mode document about `:file` header argument, seems org-babel will write result to `:file` specified file. I wander how I can handle upper case correctly? (don't write result to file, just insert a link to downloaded file as a result)

--------------69E742EE18D901EE3D064523-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Welle Subject: Re: How to let ob-shell to download file and get result as a link to file? Date: Mon, 26 Mar 2018 20:06:21 +0200 Message-ID: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0WVq-0006Gw-0w for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 14:06:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0WVm-00025T-SX for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 14:06:30 -0400 Received: from mout.gmx.net ([212.227.17.20]:34929) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0WVm-000258-Im for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 14:06:26 -0400 Received: from stella.c0t0d0s0.de ([89.204.153.12]) by mail.gmx.com (mrgmx101 [212.227.17.168]) with ESMTPSA (Nemesis) id 0LsgvV-1eXpbl2CNt-012L5v for ; Mon, 26 Mar 2018 20:06:24 +0200 Received: from Stella (stella.c0t0d0s0.de [192.168.42.1]) by stella.c0t0d0s0.de (Postfix) with ESMTP id 2180CC4080 for ; Mon, 26 Mar 2018 20:06:21 +0200 (CEST) In-Reply-To: (stardiviner's message of "Mon, 26 Mar 2018 23:35:17 +0800") 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: emacs-orgmode@gnu.org Hello, stardiviner writes: > I tried the following example: > > ``` > > #+begin_src shell :mkdir yes :dir "data/tmp" :results file :file > "crackzor_1.0.c.gz" > wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" > #+end_src > > #+RESULTS: > [[file:data/tmp/crackzor_1.0.c.gz]] > ``` > > But the files is empty, I check out Org-mode document about `:file` > header argument, seems org-babel will write result to `:file` specified > file. I wander how I can handle upper case correctly? (don't write > result to file, just insert a link to downloaded file as a result) well, your above example would work, at least to a certain point, if you let wget write its output to stdout: #+begin_src sh :mkdir yes :dir "/tmp" :results file :file "crackzor_1.0.c.gz" wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" -O- #+end_src But I don't now know how to get the encoding right (I think that's the problem). The zip file contains rubbish. What I would do instead is something like this: #+begin_src sh :mkdir yes :dir "/tmp" :results raw :var fn="crackzor_1.0.c.gz" /usr/bin/wget -c "http://ben.akrin.com/crackzor/${fn}" echo "[[file:/tmp/${fn}]]" #+end_src Regards hmw From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: [PATCH] support insert link without write result to :file link Date: Tue, 27 Mar 2018 10:56:59 +0800 Message-ID: <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> References: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3DC0203D59B90DC595E97A4A" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0enN-00044i-BX for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 22:57:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0enK-0000pd-1z for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 22:57:09 -0400 Received: from mail-pl0-x231.google.com ([2607:f8b0:400e:c01::231]:46778) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0enJ-0000op-NF for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 22:57:05 -0400 Received: by mail-pl0-x231.google.com with SMTP id f5-v6so13224705plj.13 for ; Mon, 26 Mar 2018 19:57:05 -0700 (PDT) Received: from [0.0.0.0] ([119.28.89.243]) by smtp.gmail.com with ESMTPSA id 89sm292137pfs.156.2018.03.26.19.57.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 19:57:02 -0700 (PDT) In-Reply-To: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> Content-Language: en-US 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: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------3DC0203D59B90DC595E97A4A Content-Type: multipart/alternative; boundary="------------DC6E837906BD1E11C38D8433" --------------DC6E837906BD1E11C38D8433 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I added this patch to handle posted question case. This will improve Org-mode links with org-babel resulta lot. Make Org-mode can insert link as user want at many places. Hope can be merged. On 03/27/2018 02:06 AM, Michael Welle wrote: > Hello, > > stardiviner writes: > >> I tried the following example: >> >> ``` >> >> #+begin_src shell :mkdir yes :dir "data/tmp" :results file :file >> "crackzor_1.0.c.gz" >> wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" >> #+end_src >> >> #+RESULTS: >> [[file:data/tmp/crackzor_1.0.c.gz]] >> ``` >> >> But the files is empty, I check out Org-mode document about `:file` >> header argument, seems org-babel will write result to `:file` specified >> file. I wander how I can handle upper case correctly? (don't write >> result to file, just insert a link to downloaded file as a result) > well, your above example would work, at least to a certain point, if you > let wget write its output to stdout: > > #+begin_src sh :mkdir yes :dir "/tmp" :results file :file "crackzor_1.0.c.gz" > wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" -O- > #+end_src > > But I don't now know how to get the encoding right (I think that's the > problem). The zip file contains rubbish. What I would do instead is > something like this: > > #+begin_src sh :mkdir yes :dir "/tmp" :results raw :var fn="crackzor_1.0.c.gz" > /usr/bin/wget -c "http://ben.akrin.com/crackzor/${fn}" > echo "[[file:/tmp/${fn}]]" > #+end_src > > Regards > hmw > --------------DC6E837906BD1E11C38D8433 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

I added this patch to handle posted question case.

This will improve Org-mode links with org-babel result a lot. Make Org-mode can insert link as user want at many places.

Hope can be merged.


On 03/27/2018 02:06 AM, Michael Welle wrote:
Hello,

stardiviner <numbchild@gmail.com> writes:

I tried the following example:

```

#+begin_src shell :mkdir yes :dir "data/tmp" :results file :file 
"crackzor_1.0.c.gz"
wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz"
#+end_src

#+RESULTS:
[[file:data/tmp/crackzor_1.0.c.gz]]
```

But the files is empty, I check out Org-mode document about `:file` 
header argument, seems org-babel will write result to `:file` specified 
file. I wander how I can handle upper case correctly? (don't write 
result to file, just insert a link to downloaded file as a result)
well, your above example would work, at least to a certain point, if you
let wget write its output to stdout:

#+begin_src sh :mkdir yes :dir "/tmp" :results file :file "crackzor_1.0.c.gz"
wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" -O-
#+end_src

But I don't now know how to get the encoding right (I think that's the
problem). The zip file contains rubbish. What I would do instead is
something like this: 

#+begin_src sh :mkdir yes :dir "/tmp" :results raw :var fn="crackzor_1.0.c.gz"
/usr/bin/wget -c "http://ben.akrin.com/crackzor/${fn}"
echo "[[file:/tmp/${fn}]]"
#+end_src

Regards
hmw


--------------DC6E837906BD1E11C38D8433-- --------------3DC0203D59B90DC595E97A4A Content-Type: text/x-patch; name="0001-ob-core.el-org-babel-execute-src-block-support-resul.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0001-ob-core.el-org-babel-execute-src-block-support-resul.pa"; filename*1="tch" >From 6e6f04016525ece12610833d731e8a92d4473ee2 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Tue, 27 Mar 2018 10:50:03 +0800 Subject: [PATCH] * ob-core.el (org-babel-execute-src-block) support :results link. --- etc/ORG-NEWS | 9 +++++++++ lisp/ob-core.el | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index d479b982c..e2a02d0a2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -113,6 +113,15 @@ now sort according to the locale’s collation rules instead of by code-point. ** New features +*** add ~:results link~ support for org-babel +This will support only insert file link without writing result to file. +Like this case: +#+begin_src shell :dir "data/tmp" :results link :file "crackzor_1.0.c.gz" +wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" +#+end_src + +#+RESULTS: +[[file:data/tmp/crackzor_1.0.c.gz]] *** Add ~:session~ support of ob-js for js-comint #+begin_src js :session "*Javascript REPL*" console.log("stardiviner") diff --git a/lisp/ob-core.el b/lisp/ob-core.el index e33168278..a0e5663ec 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -707,10 +707,13 @@ block." ;; If non-empty result and :file then write to :file. (when file (let ((graphics? - (member "graphics" (cdr (assq :result-params params))))) - ;; Handle :results graphics :file case. Don't - ;; write result to file if result is graphics. - (when (and result (not graphics?)) + (member "graphics" (cdr (assq :result-params params)))) + (file-link? + (member "link" (cdr (assq :result-params params))))) + ;; If :results are special types like `link', `graphics' etc. + ;; don't write result to :file. literately only + ;; insert link to :file. + (when (and result (not graphics?) (not file-link?)) (with-temp-file file (insert (org-babel-format-result result (cdr (assq :sep params))))))) -- 2.16.3 --------------3DC0203D59B90DC595E97A4A-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] support insert link without write result to :file link Date: Tue, 27 Mar 2018 08:26:02 +0200 Message-ID: <87o9jarq4l.fsf@nicolasgoaziou.fr> References: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0i3c-0004yD-MD for emacs-orgmode@gnu.org; Tue, 27 Mar 2018 02:26:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0i3Y-0008OQ-S3 for emacs-orgmode@gnu.org; Tue, 27 Mar 2018 02:26:08 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:33603) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0i3Y-0008Ns-M8 for emacs-orgmode@gnu.org; Tue, 27 Mar 2018 02:26:04 -0400 In-Reply-To: <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> (stardiviner's message of "Tue, 27 Mar 2018 10:56:59 +0800") 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: stardiviner Cc: emacs-orgmode@gnu.org Hello, stardiviner writes: > I added this patch to handle posted question case. > > This will improve Org-mode links with org-babel resulta lot. Make > Org-mode can insert link as user want at many places. > > Hope can be merged. Thank you. However, before thinking about merging it, it requires documentation and tests. You also need to update `org-babel-common-header-args-w-values'. Also, there are still failing tests from the last change to :results behaviour in master, if you ever have time to look into it. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [PATCH] support insert link without write result to :file link Date: Thu, 29 Mar 2018 00:11:00 +0800 Message-ID: <55a201ba-d990-ede1-cf12-a6a3814d1979@gmail.com> References: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> <87o9jarq4l.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2FEC5537D2DEB2F7A609ADB3" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1DfM-0006xF-Hq for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 12:11:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1DfH-0001va-F1 for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 12:11:12 -0400 Received: from mail-pl0-x236.google.com ([2607:f8b0:400e:c01::236]:39301) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1DfH-0001tm-1W for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 12:11:07 -0400 Received: by mail-pl0-x236.google.com with SMTP id s24-v6so1867621plq.6 for ; Wed, 28 Mar 2018 09:11:07 -0700 (PDT) In-Reply-To: <87o9jarq4l.fsf@nicolasgoaziou.fr> Content-Language: en-US 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: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------2FEC5537D2DEB2F7A609ADB3 Content-Type: multipart/alternative; boundary="------------7D42C71FE4AAD94D83C33932" --------------7D42C71FE4AAD94D83C33932 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Nicolas, I have problem in my code. Even after many times and 5 hourse Edebug on ob-core.el code. Still can't find out where is wrong. After Edebug, just know somewhere is wrong. here is my info: - [ ] probelm is on ~org-babel-merge-params~, ~info~ is generated from it, but it removed ~link~ in ~:results~. - [ ] org-babel-execute-src-block   - [ ] (org-babel-get-src-block-info)     - [ ] (let* ((info .. (apply #'org-babel-merge-params ...))))  -> info -> :results file replace (been removed here)       - because ~:results link file replace~ are merged into ~:results file replace~?         - where does the ~file~ comes from?           - from ~:file~ header argument?             - which function get this?       - [ ] org-babel-process-params info I added my latest patches in attachment (include test, and added your suggested modification). Can you help me on my code? On 03/27/2018 02:26 PM, Nicolas Goaziou wrote: > Hello, > > stardiviner writes: > >> I added this patch to handle posted question case. >> >> This will improve Org-mode links with org-babel resulta lot. Make >> Org-mode can insert link as user want at many places. >> >> Hope can be merged. > Thank you. > > However, before thinking about merging it, it requires documentation and > tests. You also need to update `org-babel-common-header-args-w-values'. > > Also, there are still failing tests from the last change to :results > behaviour in master, if you ever have time to look into it. > > Regards, > --------------7D42C71FE4AAD94D83C33932 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi, Nicolas, I have problem in my code. Even after many times and 5 hourse Edebug on ob-core.el code. Still can't find out where is wrong. After Edebug, just know somewhere is wrong. here is my info:

- [ ] probelm is on ~org-babel-merge-params~, ~info~ is generated from it, but it removed ~link~ in ~:results~.
- [ ] org-babel-execute-src-block
  - [ ] (org-babel-get-src-block-info)
    - [ ] (let* ((info .. (apply #'org-babel-merge-params ...))))  -> info -> :results file replace (been removed here)
      - because ~:results link file replace~ are merged into ~:results file replace~?
        - where does the ~file~ comes from?
          - from ~:file~ header argument?
            - which function get this?
      - [ ] org-babel-process-params info


I added my latest patches in attachment (include test, and added your suggested modification). Can you help me on my code?


On 03/27/2018 02:26 PM, Nicolas Goaziou wrote:
Hello,

stardiviner <numbchild@gmail.com> writes:

I added this patch to handle posted question case.

This will improve Org-mode links with org-babel resulta lot. Make
Org-mode can insert link as user want at many places.

Hope can be merged.
Thank you.

However, before thinking about merging it, it requires documentation and
tests. You also need to update `org-babel-common-header-args-w-values'.

Also, there are still failing tests from the last change to :results
behaviour in master, if you ever have time to look into it.

Regards,


--------------7D42C71FE4AAD94D83C33932-- --------------2FEC5537D2DEB2F7A609ADB3 Content-Type: text/x-patch; name="0001-ob-core.el-org-babel-execute-src-block-support-resul.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename*0="0001-ob-core.el-org-babel-execute-src-block-support-resul.pa"; filename*1="tch" >From a4da247355dd0f347843b06d9e64d26d210a4b0a Mon Sep 17 00:00:00 2001 From: stardiviner Date: Tue, 27 Mar 2018 10:50:03 +0800 Subject: [PATCH 1/2] * ob-core.el (org-babel-execute-src-block) support :results link. - doc/org.texi (:results): support :results link type. Don't write non-empty result to :file when result type is link. Use it like this: wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" [[file:data/tmp/crackzor_1.0.c.gz]] - testing/lisp/test-ob.el (test-ob/result-file-link-type-header-argument) add test. --- doc/org.texi | 3 +++ etc/ORG-NEWS | 9 +++++++++ lisp/ob-core.el | 13 ++++++++----- testing/lisp/test-ob.el | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/doc/org.texi b/doc/org.texi index aaa180401..903f52143 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -16204,6 +16204,9 @@ example: @code{:results value verbatim}. @item @code{file} Interpret as path to a file. Inserts a link to the file. Usage example: @code{:results value file}. +@item @code{link} +Interpret as path to a file. Inserts a link to the file. Usage example: +@code{:results value link}. @end itemize @subsubheading Format diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index d479b982c..e2a02d0a2 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -113,6 +113,15 @@ now sort according to the locale’s collation rules instead of by code-point. ** New features +*** add ~:results link~ support for org-babel +This will support only insert file link without writing result to file. +Like this case: +#+begin_src shell :dir "data/tmp" :results link :file "crackzor_1.0.c.gz" +wget -c "http://ben.akrin.com/crackzor/crackzor_1.0.c.gz" +#+end_src + +#+RESULTS: +[[file:data/tmp/crackzor_1.0.c.gz]] *** Add ~:session~ support of ob-js for js-comint #+begin_src js :session "*Javascript REPL*" console.log("stardiviner") diff --git a/lisp/ob-core.el b/lisp/ob-core.el index e33168278..d2c1b70f3 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -413,7 +413,7 @@ then run `org-babel-switch-to-session'." (padline . ((yes no))) (post . :any) (prologue . :any) - (results . ((file list vector table scalar verbatim) + (results . ((file link list vector table scalar verbatim) (raw html latex org code pp drawer) (replace silent none append prepend) (output value))) @@ -707,10 +707,13 @@ block." ;; If non-empty result and :file then write to :file. (when file (let ((graphics? - (member "graphics" (cdr (assq :result-params params))))) - ;; Handle :results graphics :file case. Don't - ;; write result to file if result is graphics. - (when (and result (not graphics?)) + (member "graphics" (cdr (assq :result-params params)))) + (file-link? + (member "link" (cdr (assq :result-params params))))) + ;; If :results are special types like `link', `graphics' etc. + ;; don't write result to :file. literately only + ;; insert link to :file. + (when (and result (not graphics?) (not file-link?)) (with-temp-file file (insert (org-babel-format-result result (cdr (assq :sep params))))))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index a4a590d6a..93eb7736a 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -996,6 +996,23 @@ trying to find the :END: marker." (should (search-forward "[[file:foo][bar]]" nil t)) (should (search-forward "[[file:foo][foo]]" nil t)))) +(ert-deftest test-ob/result-file-link-type-header-argument () + "Ensure that the result is a link to a file. +The file is just a link to :file value. Inhibit non-empty result write to :file." + (org-test-with-temp-text + "#+begin_src sh :results link :file \"test.txt\" + echo \"hello\" > test.txt + echo \"test\" + #+end_src" + (org-babel-execute-src-block) + (goto-char (point-min)) + (should (search-forward "[[file:test.txt]]" nil t)) + (should (with-temp-buffer + (insert-file-contents "test.txt") + (string-match + "hello.*" + (buffer-substring-no-properties (point-min) (point-max))))))) + (ert-deftest test-ob/inline-src_blk-preceded-punct-preceded-by-point () (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }") (org-babel-inline-result-wrap "=%s=")) -- 2.16.3 --------------2FEC5537D2DEB2F7A609ADB3 Content-Type: text/x-patch; name="0002-ob-core.el-add-graphics-to-result-type.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-ob-core.el-add-graphics-to-result-type.patch" >From cacac1895c4871e122c16965edf6aad938c783dd Mon Sep 17 00:00:00 2001 From: stardiviner Date: Tue, 27 Mar 2018 20:03:48 +0800 Subject: [PATCH 2/2] * ob-core.el: add graphics to result type. enhance for commit 39bd69b08. - ob-core.el (org-babel-common-header-args-w-values): add keyword graphics. - doc/org.texi (:results): add document for :results value graphics. - testing/lisp/test-ob.el (test-ob/result-graphics-file-link-type-header-argument) add test. --- doc/org.texi | 3 +++ lisp/ob-core.el | 2 +- testing/lisp/test-ob.el | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/org.texi b/doc/org.texi index 903f52143..be5d6ba2b 100644 --- a/doc/org.texi +++ b/doc/org.texi @@ -16207,6 +16207,9 @@ Interpret as path to a file. Inserts a link to the file. Usage example: @item @code{link} Interpret as path to a file. Inserts a link to the file. Usage example: @code{:results value link}. +@item @code{graphics} +Interpret as path to a graphic image file. Inserts a link to the file. Usage +example: @code{:results value graphics}. @end itemize @subsubheading Format diff --git a/lisp/ob-core.el b/lisp/ob-core.el index d2c1b70f3..ef67bc8a7 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -413,7 +413,7 @@ then run `org-babel-switch-to-session'." (padline . ((yes no))) (post . :any) (prologue . :any) - (results . ((file link list vector table scalar verbatim) + (results . ((file graphics link list vector table scalar verbatim) (raw html latex org code pp drawer) (replace silent none append prepend) (output value))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 93eb7736a..11b88275b 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1013,6 +1013,23 @@ The file is just a link to :file value. Inhibit non-empty result write to :file. "hello.*" (buffer-substring-no-properties (point-min) (point-max))))))) +(ert-deftest test-ob/result-graphics-file-link-type-header-argument () + "Ensure that the result is a link to a graphic image file. +The file is just a link to :file value. Inhibit non-empty result write to :file." + (org-test-with-temp-text + "#+begin_src sh :results value graphics :file \"test.png\" + echo \"hello\" > test.png + echo \"test\" + #+end_src" + (org-babel-execute-src-block) + (goto-char (point-min)) + (should (search-forward "[[file:test.png]]" nil t)) + (should (with-temp-buffer + (insert-file-contents "test.png") + (string-match + "hello.*" + (buffer-substring-no-properties (point-min) (point-max))))))) + (ert-deftest test-ob/inline-src_blk-preceded-punct-preceded-by-point () (let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }") (org-babel-inline-result-wrap "=%s=")) -- 2.16.3 --------------2FEC5537D2DEB2F7A609ADB3-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] support insert link without write result to :file link Date: Wed, 28 Mar 2018 18:23:00 +0200 Message-ID: <874ll0qie3.fsf@nicolasgoaziou.fr> References: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> <87o9jarq4l.fsf@nicolasgoaziou.fr> <55a201ba-d990-ede1-cf12-a6a3814d1979@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40249) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1Dqt-0001vj-3T for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 12:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1Dqp-000094-5L for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 12:23:07 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:52181) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f1Dqo-000077-UQ for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 12:23:03 -0400 In-Reply-To: <55a201ba-d990-ede1-cf12-a6a3814d1979@gmail.com> (stardiviner's message of "Thu, 29 Mar 2018 00:11:00 +0800") 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: stardiviner Cc: emacs-orgmode@gnu.org Hello, stardiviner writes: > Hi, Nicolas, I have problem in my code. Even after many times and > 5 hourse Edebug on ob-core.el code. Still can't find out where is > wrong. After Edebug, just know somewhere is wrong. here is my info: > > - [ ] probelm is on ~org-babel-merge-params~, ~info~ is generated from > it, but it removed ~link~ in ~:results~. > - [ ] org-babel-execute-src-block > =C2=A0 - [ ] (org-babel-get-src-block-info) > =C2=A0=C2=A0=C2=A0 - [ ] (let* ((info .. (apply #'org-babel-merge-params = ...))))=C2=A0 ->=20 > info -> :results file replace (been removed here) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - because ~:results link file replace~ are= merged into ~:results > file replace~? > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - where does the ~file~ comes = from? > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - from ~:file~ hea= der argument? > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - whic= h function get this? > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 - [ ] org-babel-process-params info > > > I added my latest patches in attachment (include test, and added your > suggested modification). Can you help me on my code? What are the differences between ":results file" and ":results link"? Regards, --=20 Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: Re: [PATCH] support insert link without write result to :file link Date: Thu, 29 Mar 2018 11:39:21 +0800 Message-ID: <11213e2f-ed9e-71bb-5732-bbf99bbb2999@gmail.com> References: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> <87o9jarq4l.fsf@nicolasgoaziou.fr> <55a201ba-d990-ede1-cf12-a6a3814d1979@gmail.com> <874ll0qie3.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------F9F5C36590FC7826697EACA3" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1OPS-0005HY-W4 for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 23:39:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1OPP-0007So-2f for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 23:39:31 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:36142) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1OPO-0007ST-PP for emacs-orgmode@gnu.org; Wed, 28 Mar 2018 23:39:27 -0400 Received: by mail-pg0-x22c.google.com with SMTP id 201so2227457pgg.3 for ; Wed, 28 Mar 2018 20:39:26 -0700 (PDT) In-Reply-To: <874ll0qie3.fsf@nicolasgoaziou.fr> Content-Language: en-US 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: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------F9F5C36590FC7826697EACA3 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit `:results file` will write non-empty result to `:file`. But `:results link` don't, it just insert a link of `:file` at result. And that is what I want to solve in the first post of this thread. On 03/29/2018 12:23 AM, Nicolas Goaziou wrote: > Hello, > > stardiviner writes: > >> Hi, Nicolas, I have problem in my code. Even after many times and >> 5 hourse Edebug on ob-core.el code. Still can't find out where is >> wrong. After Edebug, just know somewhere is wrong. here is my info: >> >> - [ ] probelm is on ~org-babel-merge-params~, ~info~ is generated from >> it, but it removed ~link~ in ~:results~. >> - [ ] org-babel-execute-src-block >>   - [ ] (org-babel-get-src-block-info) >>     - [ ] (let* ((info .. (apply #'org-babel-merge-params ...))))  -> >> info -> :results file replace (been removed here) >>       - because ~:results link file replace~ are merged into ~:results >> file replace~? >>         - where does the ~file~ comes from? >>           - from ~:file~ header argument? >>             - which function get this? >>       - [ ] org-babel-process-params info >> >> >> I added my latest patches in attachment (include test, and added your >> suggested modification). Can you help me on my code? > What are the differences between ":results file" and ":results link"? > > Regards, > --------------F9F5C36590FC7826697EACA3 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

`:results file` will write non-empty result to `:file`. But `:results link` don't, it just insert a link of `:file` at result. And that is what I want to solve in the first post of this thread.


On 03/29/2018 12:23 AM, Nicolas Goaziou wrote:
Hello,

stardiviner <numbchild@gmail.com> writes:

Hi, Nicolas, I have problem in my code. Even after many times and
5 hourse Edebug on ob-core.el code. Still can't find out where is
wrong. After Edebug, just know somewhere is wrong. here is my info:

- [ ] probelm is on ~org-babel-merge-params~, ~info~ is generated from
it, but it removed ~link~ in ~:results~.
- [ ] org-babel-execute-src-block
  - [ ] (org-babel-get-src-block-info)
    - [ ] (let* ((info .. (apply #'org-babel-merge-params ...))))  -> 
info -> :results file replace (been removed here)
      - because ~:results link file replace~ are merged into ~:results
file replace~?
        - where does the ~file~ comes from?
          - from ~:file~ header argument?
            - which function get this?
      - [ ] org-babel-process-params info


I added my latest patches in attachment (include test, and added your
suggested modification). Can you help me on my code?
What are the differences between ":results file" and ":results link"?

Regards,


--------------F9F5C36590FC7826697EACA3-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Berry, Charles" Subject: Re: [PATCH] support insert link without write result to :file link Date: Thu, 29 Mar 2018 16:30:04 +0000 Message-ID: References: <87zi2u90f6.fsf@luisa.c0t0d0s0.de> <11516348-a184-6f9e-6a10-15fe4b06d0fb@gmail.com> <87o9jarq4l.fsf@nicolasgoaziou.fr> <55a201ba-d990-ede1-cf12-a6a3814d1979@gmail.com> <874ll0qie3.fsf@nicolasgoaziou.fr> <11213e2f-ed9e-71bb-5732-bbf99bbb2999@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1aRP-00085J-Oj for emacs-orgmode@gnu.org; Thu, 29 Mar 2018 12:30:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1aRK-00028a-QN for emacs-orgmode@gnu.org; Thu, 29 Mar 2018 12:30:19 -0400 Received: from iport-bcv3-out.ucsd.edu ([132.239.0.89]:50204) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1aRK-00025i-AV for emacs-orgmode@gnu.org; Thu, 29 Mar 2018 12:30:14 -0400 In-Reply-To: <11213e2f-ed9e-71bb-5732-bbf99bbb2999@gmail.com> Content-Language: en-US Content-ID: 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: stardiviner Cc: "emacs-orgmode@gnu.org" , Nicolas Goaziou > On Mar 28, 2018, at 8:39 PM, stardiviner wrote: >=20 > `:results file` will write non-empty result to `:file`. But `:results lin= k` don't, it just insert a link of `:file` at result. And that is what I wa= nt to solve in the first post of this thread. The :post header arg will allow this.=20 In the examples below the first code line in the src block writes a file th= at is not subsequently overwritten. #+name: file-output #+begin_src emacs-lisp =20 (org-babel-result-to-file *this*)=20 #+end_src #+begin_src R :results raw :post file-output() cat("this is a test",file=3D"testit.out") "testit.out" #+end_src #+RESULTS: [[file:testit.out]] #+name: file-output2 #+begin_src emacs-lisp :var fname=3D"xxx"=20 (org-babel-result-to-file fname)=20 #+end_src #+begin_src R :results raw :post file-output2("testit2.out") cat("this is a test",file=3D"testit2.out") #+end_src #+RESULTS: [[file:testit2.out]] HTH, Chuck=