1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-29 07:58:21 +00:00

Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2014-01-29 09:05:44 +01:00
commit 98eed5baf9
2 changed files with 17 additions and 3 deletions

View File

@ -311,7 +311,7 @@ The function respects the value of the :exports header argument."
(org-babel-exp-code info)))))
(defcustom org-babel-exp-code-template
"#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC"
"#+BEGIN_SRC %lang%switches%flags\n%body\n#+END_SRC"
"Template used to export the body of code blocks.
This template may be customized to include additional information
such as the code block name, or the values of particular header
@ -321,6 +321,7 @@ and the following %keys may be used.
lang ------ the language of the code block
name ------ the name of the code block
body ------ the body of the code block
switches -- the switches associated to the code block
flags ----- the flags passed to the code block
In addition to the keys mentioned above, every header argument
@ -343,8 +344,10 @@ replaced with its value."
org-babel-exp-code-template
`(("lang" . ,(nth 0 info))
("body" . ,(org-escape-code-in-string (nth 1 info)))
("switches" . ,(let ((f (nth 3 info)))
(and (org-string-nw-p f) (concat " " f))))
("flags" . ,(let ((f (assq :flags (nth 2 info))))
(when f (concat " " (cdr f)))))
(and f (concat " " (cdr f)))))
,@(mapcar (lambda (pair)
(cons (substring (symbol-name (car pair)) 1)
(format "%S" (cdr pair))))

View File

@ -303,10 +303,21 @@ Here is one at the end of a line. =2=
(org-export-execute-babel-code)
(buffer-string)))))
(ert-deftest ob-export/export-src-block-with-switches ()
"Test exporting a source block with switches."
(should
(string-match
"\\`#\\+BEGIN_SRC emacs-lisp -n -r$"
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp -n -r\n\(+ 1 1)\n#+END_SRC"
(org-export-execute-babel-code)
(buffer-string)))))
(ert-deftest ob-export/export-src-block-with-flags ()
"Test exporting a source block with a flag."
(should
(string-match "\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
(string-match
"\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
(org-test-with-temp-text
"#+BEGIN_SRC emacs-lisp :flags -some-flag\n\(+ 1 1)\n#+END_SRC"
(org-export-execute-babel-code)