From b088389c6b4eead4d41528b18a273b8a2cd47eb3 Mon Sep 17 00:00:00 2001 From: stardiviner Date: Thu, 12 Apr 2018 15:13:02 +0200 Subject: [PATCH] ob-core: Add document and test for "graphics" format * doc/org-manual.org: Document value. * lisp/ob-core.el (org-babel-common-header-args-w-values): Handle symbol "graphics". * testing/lisp/test-ob.el (test-ob/result-graphics-link-type-header-argument): New test. --- doc/org-manual.org | 3 ++- lisp/ob-core.el | 2 +- testing/lisp/test-ob.el | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index c9742a497..3e7ce4c4e 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -17186,6 +17186,7 @@ Format pertains to the type of the result returned by the code block. Choose one of the options; they are mutually exclusive. The default follows from the type specified above. +#+attr_texinfo: :sep , - =raw= :: Interpreted as raw Org mode. Inserted directly into the buffer. @@ -17224,7 +17225,7 @@ follows from the type specified above. =raw= or =org= results for later scripting and automated processing. Usage example: =:results value drawer=. -- =link= :: +- =link=, =graphics= :: Result is a link to the file specified in =:file= header argument. However, unlike plain =:file=, nothing is written to diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 75311e03b..aa4c3715c 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -414,7 +414,7 @@ then run `org-babel-switch-to-session'." (post . :any) (prologue . :any) (results . ((file list vector table scalar verbatim) - (raw html latex org code pp drawer link) + (raw html latex org code pp drawer link graphics) (replace silent none append prepend) (output value))) (rownames . ((no yes))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index add76da84..ff86d5eeb 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1011,6 +1011,21 @@ echo \"test\" (insert-file-contents "/tmp/test.txt") (string= "hello\n" (buffer-string)))))) +(ert-deftest test-ob/result-graphics-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' value." + (org-test-with-temp-text " +#+begin_src shell :results value graphics :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 nil)) + (should (with-temp-buffer + (insert-file-contents "/tmp/test.txt") + (string= "hello\n" (buffer-string)))))) + (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="))