summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eric.schulte@gmx.com>2012-01-23 12:52:57 -0700
committerEric Schulte <eric.schulte@gmx.com>2012-01-23 12:53:15 -0700
commit527e6844cc1b67f2ef93c2304265ffe4b9cf3e69 (patch)
treeb80ae9a21bba712e10c902d083a344c52c02b880
parent1d99fd7010b1528dd98f592a58b3a98f0b479221 (diff)
downloadorg-mode-527e6844cc1b67f2ef93c2304265ffe4b9cf3e69.tar.gz
optionally export additional information with call lines
* lisp/ob-exp.el (org-babel-exp-call-line-template): Control export of additional call line information. (org-babel-exp-non-block-elements): Fancier call line export. * testing/examples/babel.org (an): Example data to test new call line export. * testing/lisp/test-ob-exp.el (ob-exp/export-call-line-information): Test new call line export.
-rw-r--r--lisp/ob-exp.el51
-rw-r--r--testing/examples/babel.org6
-rw-r--r--testing/lisp/test-ob-exp.el9
3 files changed, 50 insertions, 16 deletions
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index c22740f..c5cc0cb 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -115,6 +115,23 @@ none ----- do not display either code or results upon export"
(nth 1 info)))
(org-babel-exp-do-export info 'block hash)))))
+(defcustom org-babel-exp-call-line-template
+ ""
+ "Template used to export call lines.
+This template may be customized to include the call line name
+with any export markup. The template is filled out using
+`org-fill-template', and the following %keys may be used.
+
+ line --- call line
+
+An example value would be \"\\n: call: %line\" to export the call line
+wrapped in a verbatim environment.
+
+Note: the results are inserted separately after the contents of
+this template."
+ :group 'org-babel
+ :type 'string)
+
(defvar org-babel-default-lob-header-args)
(defun org-babel-exp-non-block-elements (start end)
"Process inline source and call lines between START and END for export."
@@ -160,22 +177,24 @@ none ----- do not display either code or results upon export"
(inlinep (match-string 11))
(inline-start (match-end 11))
(inline-end (match-end 0))
- (rep (let ((lob-info (org-babel-lob-get-info)))
- (save-match-data
- (org-babel-exp-do-export
- (list "emacs-lisp" "results"
- (org-babel-merge-params
- org-babel-default-header-args
- org-babel-default-lob-header-args
- (org-babel-params-from-properties)
- (org-babel-parse-header-arguments
- (org-babel-clean-text-properties
- (concat ":var results="
- (mapconcat #'identity
- (butlast lob-info)
- " ")))))
- "" nil (car (last lob-info)))
- 'lob)))))
+ (results (save-match-data
+ (org-babel-exp-do-export
+ (list "emacs-lisp" "results"
+ (org-babel-merge-params
+ org-babel-default-header-args
+ org-babel-default-lob-header-args
+ (org-babel-params-from-properties)
+ (org-babel-parse-header-arguments
+ (org-babel-clean-text-properties
+ (concat ":var results="
+ (mapconcat #'identity
+ (butlast lob-info)
+ " ")))))
+ "" nil (car (last lob-info)))
+ 'lob)))
+ (rep (org-fill-template
+ org-babel-exp-call-line-template
+ `(("line" . ,(nth 0 lob-info))))))
(if inlinep
(save-excursion
(goto-char inline-start)
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index bc334f4..bfa366f 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -334,3 +334,9 @@ Fifth
#+begin_src emacs-lisp
(push 5 *evaluation-collector*)
#+end_src
+* exporting more than just results from a call line
+ :PROPERTIES:
+ :ID: bec63a04-491e-4caa-97f5-108f3020365c
+ :END:
+Here is a call line with more than just the results exported.
+#+call: double(8)
diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el
index 7ff7c4b..8cdfba4 100644
--- a/testing/lisp/test-ob-exp.el
+++ b/testing/lisp/test-ob-exp.el
@@ -231,6 +231,15 @@ elements in the final html."
(org-export-as-ascii nil nil nil 'string)
(should (equal '(5 4 3 2 1) *evaluation-collector*)))))
+(ert-deftest ob-exp/export-call-line-information ()
+ (org-test-at-id "bec63a04-491e-4caa-97f5-108f3020365c"
+ (org-narrow-to-subtree)
+ (let* ((org-babel-exp-call-line-template "\n: call: %line special-token")
+ (html (org-export-as-html nil nil nil 'string t)))
+ (should (string-match "double" html))
+ (should (string-match "16" html))
+ (should (string-match "special-token" html)))))
+
(provide 'test-ob-exp)
;;; test-ob-exp.el ends here