Browse Source

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.
stardiviner 7 years ago
parent
commit
b088389c6b
3 changed files with 18 additions and 2 deletions
  1. 2 1
      doc/org-manual.org
  2. 1 1
      lisp/ob-core.el
  3. 15 0
      testing/lisp/test-ob.el

+ 2 - 1
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

+ 1 - 1
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)))

+ 15 - 0
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 "
+<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)
+   (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="))