emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [PATCH] add "link" :results type for Babel


From: stardiviner
Subject: Re: [O] [PATCH] add "link" :results type for Babel
Date: Thu, 12 Apr 2018 10:04:05 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0


On 04/12/2018 04:55 AM, Nicolas Goaziou wrote:
Hello,

stardiviner <address@hidden> writes:

This patch try to support following way:

#+begin_src sh :results link :file "/tmp/test.txt"
echo "hello" > /tmp/test.txt
echo "test"
#+end_src

#+RESULTS:
[[file:/tmp/test.txt]]

Because:

- ~org-babel-execute-src-block~
   - ~(org-babel-get-src-block-info)~
     - (let* ((info .. (apply #'org-babel-merge-params ...))))
       - ~org-babel-merge-params~
         - [ ] *because* code ~(`(,(or :file :file-ext) . ,value) ...)~
           lines logic in function ~org-babel-get-src-block-info~, it
           merge "file" ~:results~, so override params plist :results
           value ~link~.
         - [ ] So I put ~link~ and ~graphics~ "~:results~" type into a
           separate group in constant
           ~org-babel-common-header-args-w-values~.

If anybody has better way, please improve my code.
IIRC, there is no technical difference between ":results graphics" and
":results link". So, what about simply stating that `link' and
`graphics' are equivalent, like, e.g., `table' and `vector' or `scalar'
and `verbatim'?

Note that `graphics' results are not properly documented in the current
manual. They should probably go in "Working with Source Code/Results of
Evaluation/Format" section.
updated.

-    (results   . ((file list vector table scalar verbatim)
+    (results   . (
+                  ;; separate group to avoid been override by "file"
+                  ;; :results in `org-babel-merge-params'.
+                  (link)
`link' is not an output type. `graphics' is not defined here either.
Updated. I put "link" and "graphics" into result format group now.
This is really good. I have not come up with this.

+(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 shell :results value link :file 
\"/tmp/test.txt\"
+echo \"hello\" > /tmp/test.txt
+echo \"test\"
+#+end_src"
+   (org-babel-execute-src-block)
+   (goto-char (point-min))
+   (should (search-forward "[[file:/tmp/test.txt]]" nil nil))
+   (should (with-temp-buffer
+            (insert-file-contents "/tmp/test.txt")
+            (string=
+             "hello\n"
+             (buffer-substring-no-properties (point-min) (point-max)))))))
Note that this test already passes when "link" is substituted with "graphics".

Regards,

I think keep "graphics" result format test is necessary. Even though is is almost same way "link" result format test. Because I have some ideas on graphics result format. Might add in the future. Also it provide straight mean for result format. People can understand it clearly. What do you think?

I attached new generated patches.

Attachment: 0001-ob-core.el-add-link-results-format-for-babel.patch
Description: Text Data

Attachment: 0002-ob-core.el-add-document-and-test-for-graphics-result.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]