>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}. address@hidden @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