diff options
author | Nicolas Goaziou <n.goaziou@gmail.com> | 2014-02-01 21:54:03 +0100 |
---|---|---|
committer | Nicolas Goaziou <n.goaziou@gmail.com> | 2014-02-01 21:54:03 +0100 |
commit | 8f91f657e16bf36fdbe071416618ad6316bf1681 (patch) | |
tree | eede9230b677b42a2d3ac861f10cc8bd421f0d79 | |
parent | 4df24f5fc8138901cd00fde0ae6bdc2a91ab298c (diff) | |
parent | ac2f516edf90e9631f069c08294fb11ecf42b231 (diff) | |
download | org-mode-8f91f657e16bf36fdbe071416618ad6316bf1681.tar.gz |
Merge branch 'maint'
-rw-r--r-- | lisp/ob-exp.el | 4 | ||||
-rw-r--r-- | testing/lisp/test-ob-exp.el | 33 |
2 files changed, 36 insertions, 1 deletions
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el index 38affaa..09ae827 100644 --- a/lisp/ob-exp.el +++ b/lisp/ob-exp.el @@ -271,7 +271,9 @@ this template." (save-excursion (goto-char end) (line-end-position))) (insert replacement) - (if (org-element-property :preserve-indent element) + (if (or org-src-preserve-indentation + (org-element-property :preserve-indent + element)) ;; Indent only the code block markers. (save-excursion (skip-chars-backward " \r\t\n") (indent-line-to ind) diff --git a/testing/lisp/test-ob-exp.el b/testing/lisp/test-ob-exp.el index d09e9eb..8345da7 100644 --- a/testing/lisp/test-ob-exp.el +++ b/testing/lisp/test-ob-exp.el @@ -323,6 +323,39 @@ Here is one at the end of a line. =2= (org-export-execute-babel-code) (buffer-string))))) +(ert-deftest ob-export/export-and-indentation () + "Test indentation of evaluated source blocks during export." + ;; No indentation. + (should + (string-match + "^t" + (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n t\n#+END_SRC" + (let ((indent-tabs-mode t) + (tab-width 1) + (org-src-preserve-indentation nil)) + (org-export-execute-babel-code) + (buffer-string))))) + ;; Preserve indentation with "-i" flag. + (should + (string-match + "^ t" + (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp -i\n t\n#+END_SRC" + (let ((indent-tabs-mode t) + (tab-width 1)) + (org-export-execute-babel-code) + (buffer-string))))) + ;; Preserve indentation with a non-nil + ;; `org-src-preserve-indentation'. + (should + (string-match + "^ t" + (org-test-with-temp-text "#+BEGIN_SRC emacs-lisp\n t\n#+END_SRC" + (let ((indent-tabs-mode t) + (tab-width 1) + (org-src-preserve-indentation t)) + (org-export-execute-babel-code) + (buffer-string)))))) + (provide 'test-ob-exp) ;;; test-ob-exp.el ends here |