ob: :file and :file-ext no longer imply :results file
* lisp/ob-core.el (org-babel-execute-src-block): ":results file" must be specified in order to return a file. (org-babel-merge-params): :file and :file-ext no longer imply :results file. * testing/lisp/test-ob.el (test-ob/indented-cached-org-bracket-link): (test-ob/result-file-link-type-header-argument): (test-ob/result-graphics-link-type-header-argument): Update tests. Deducing the results from some other arguments is not obvious. Moreover, it prevents users from setting, e.g., :file-ext, in a node property, as every block would then create a file. Reported-by: Alex Fenton <alex@pressure.to> <http://lists.gnu.org/r/emacs-orgmode/2018-05/msg00469.html>
This commit is contained in:
parent
ed9bdfd220
commit
26ed66b233
|
@ -14,6 +14,12 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
|
||||||
|
|
||||||
** Incompatible change
|
** Incompatible change
|
||||||
|
|
||||||
|
*** ~:file~ header argument no longer assume "file" ~:results~
|
||||||
|
|
||||||
|
The "file" ~:results~ value is now mandatory for a code block
|
||||||
|
returning a link to a file. The ~:file~ or ~:file-ext~ header
|
||||||
|
arguments no longer imply a "file" result is expected.
|
||||||
|
|
||||||
*** Plain numbers are hours in Column View mode
|
*** Plain numbers are hours in Column View mode
|
||||||
|
|
||||||
See [[git:3367ac9457]] for details.
|
See [[git:3367ac9457]] for details.
|
||||||
|
|
|
@ -694,7 +694,8 @@ block."
|
||||||
(not (listp r)))
|
(not (listp r)))
|
||||||
(list (list r))
|
(list (list r))
|
||||||
r)))
|
r)))
|
||||||
(let ((file (cdr (assq :file params))))
|
(let ((file (and (member "file" result-params)
|
||||||
|
(cdr (assq :file params)))))
|
||||||
;; If non-empty result and :file then write to :file.
|
;; If non-empty result and :file then write to :file.
|
||||||
(when file
|
(when file
|
||||||
;; If `:results' are special types like `link' or
|
;; If `:results' are special types like `link' or
|
||||||
|
@ -2624,19 +2625,6 @@ parameters when merging lists."
|
||||||
results
|
results
|
||||||
(split-string
|
(split-string
|
||||||
(if (stringp value) value (eval value t))))))
|
(if (stringp value) value (eval value t))))))
|
||||||
(`(,(or :file :file-ext) . ,value)
|
|
||||||
;; `:file' and `:file-ext' are regular keywords but they
|
|
||||||
;; imply a "file" `:results' and a "results" `:exports'.
|
|
||||||
(when value
|
|
||||||
(setq results
|
|
||||||
(funcall merge results-exclusive-groups results '("file")))
|
|
||||||
(unless (or (member "both" exports)
|
|
||||||
(member "none" exports)
|
|
||||||
(member "code" exports))
|
|
||||||
(setq exports
|
|
||||||
(funcall merge
|
|
||||||
exports-exclusive-groups exports '("results"))))
|
|
||||||
(push pair params)))
|
|
||||||
(`(:exports . ,value)
|
(`(:exports . ,value)
|
||||||
(setq exports (funcall merge
|
(setq exports (funcall merge
|
||||||
exports-exclusive-groups
|
exports-exclusive-groups
|
||||||
|
|
|
@ -30,7 +30,7 @@ should still return the link."
|
||||||
(org-test-with-temp-text
|
(org-test-with-temp-text
|
||||||
"
|
"
|
||||||
* Test
|
* Test
|
||||||
#+<point>BEGIN_SRC emacs-lisp :file test.txt :cache yes
|
#+<point>BEGIN_SRC emacs-lisp :results file :file test.txt :cache yes
|
||||||
(message \"test\")
|
(message \"test\")
|
||||||
#+END_SRC"
|
#+END_SRC"
|
||||||
;; Execute twice as the first time creates the cache.
|
;; Execute twice as the first time creates the cache.
|
||||||
|
@ -1003,22 +1003,31 @@ trying to find the :END: marker."
|
||||||
The file is just a link to `:file' value. Inhibit non-empty
|
The file is just a link to `:file' value. Inhibit non-empty
|
||||||
result write to `:file' value."
|
result write to `:file' value."
|
||||||
(org-test-with-temp-text "
|
(org-test-with-temp-text "
|
||||||
|
<point>#+begin_src shell :results value file link :file \"/tmp/test.txt\"
|
||||||
|
echo \"hello\" > /tmp/test.txt
|
||||||
|
echo \"test\"
|
||||||
|
#+end_src"
|
||||||
|
(org-babel-execute-src-block)
|
||||||
|
(should (search-forward "[[file:/tmp/test.txt]]" nil t))
|
||||||
|
(should (with-temp-buffer
|
||||||
|
(insert-file-contents "/tmp/test.txt")
|
||||||
|
(string= "hello\n" (buffer-string)))))
|
||||||
|
;; Without "link" output type, the result is not a file.
|
||||||
|
(should-not
|
||||||
|
(org-test-with-temp-text "
|
||||||
<point>#+begin_src shell :results value link :file \"/tmp/test.txt\"
|
<point>#+begin_src shell :results value link :file \"/tmp/test.txt\"
|
||||||
echo \"hello\" > /tmp/test.txt
|
echo \"hello\" > /tmp/test.txt
|
||||||
echo \"test\"
|
echo \"test\"
|
||||||
#+end_src"
|
#+end_src"
|
||||||
(org-babel-execute-src-block)
|
(org-babel-execute-src-block)
|
||||||
(should (search-forward "[[file:/tmp/test.txt]]" nil nil))
|
(search-forward "[[file:/tmp/test.txt]]" nil t))))
|
||||||
(should (with-temp-buffer
|
|
||||||
(insert-file-contents "/tmp/test.txt")
|
|
||||||
(string= "hello\n" (buffer-string))))))
|
|
||||||
|
|
||||||
(ert-deftest test-ob/result-graphics-link-type-header-argument ()
|
(ert-deftest test-ob/result-graphics-link-type-header-argument ()
|
||||||
"Ensure that the result is a link to a file.
|
"Ensure that the result is a link to a file.
|
||||||
The file is just a link to `:file' value. Inhibit non-empty
|
The file is just a link to `:file' value. Inhibit non-empty
|
||||||
result write to `:file' value."
|
result write to `:file' value."
|
||||||
(org-test-with-temp-text "
|
(org-test-with-temp-text "
|
||||||
<point>#+begin_src shell :results value graphics :file \"/tmp/test.txt\"
|
<point>#+begin_src shell :results value file graphics :file \"/tmp/test.txt\"
|
||||||
echo \"hello\" > /tmp/test.txt
|
echo \"hello\" > /tmp/test.txt
|
||||||
echo \"test\"
|
echo \"test\"
|
||||||
#+end_src"
|
#+end_src"
|
||||||
|
@ -1026,7 +1035,16 @@ echo \"test\"
|
||||||
(should (search-forward "[[file:/tmp/test.txt]]" nil nil))
|
(should (search-forward "[[file:/tmp/test.txt]]" nil nil))
|
||||||
(should (with-temp-buffer
|
(should (with-temp-buffer
|
||||||
(insert-file-contents "/tmp/test.txt")
|
(insert-file-contents "/tmp/test.txt")
|
||||||
(string= "hello\n" (buffer-string))))))
|
(string= "hello\n" (buffer-string)))))
|
||||||
|
;; Without "link" output type, the result is not a file.
|
||||||
|
(should-not
|
||||||
|
(org-test-with-temp-text "
|
||||||
|
<point>#+begin_src shell :results value graphics :file \"/tmp/test.txt\"
|
||||||
|
echo \"hello\" > /tmp/test.txt
|
||||||
|
echo \"test\"
|
||||||
|
#+end_src"
|
||||||
|
(org-babel-execute-src-block)
|
||||||
|
(search-forward "[[file:/tmp/test.txt]]" nil t))))
|
||||||
|
|
||||||
(ert-deftest test-ob/inline-src_blk-preceded-punct-preceded-by-point ()
|
(ert-deftest test-ob/inline-src_blk-preceded-punct-preceded-by-point ()
|
||||||
(let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")
|
(let ((test-line ".src_emacs-lisp[ :results verbatim ]{ \"x\" }")
|
||||||
|
|
Loading…
Reference in New Issue