From 6fdc2361c93d2f77bcc81b479b6d68d57bd268a2 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Wed, 21 Aug 2013 12:24:17 +0200 Subject: [PATCH] ob-core: Fix wrong indentation of results * lisp/ob-core.el (org-babel-get-src-block-info): Look for indentation value at the correct location. * testing/lisp/test-ob.el: Add test. --- lisp/ob-core.el | 2 +- testing/lisp/test-ob.el | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 578a52daa..8fa0c1345 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -258,7 +258,7 @@ Returns a list (save-excursion (goto-char head) (setq info (org-babel-parse-src-block-match)) - (setq indent (nth 5 info)) + (setq indent (car (last info))) (setq info (butlast info)) (while (and (forward-line -1) (looking-at org-babel-multi-line-header-regexp)) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 11925899e..93c026b9a 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -1167,6 +1167,20 @@ echo \"$data\" (goto-char (match-beginning 0)) (org-babel-execute-src-block)))))) +(ert-deftest test-ob/preserve-results-indentation () + "Preserve indentation when executing a src block." + (should + (equal '(2 2) + (org-test-with-temp-text + " #+begin_src emacs-lisp\n (+ 1 1)\n #+end_src" + (org-babel-execute-src-block) + (buffer-string) + (let ((case-fold-search t)) (search-forward "#+results:")) + ;; Check if both #+RESULTS: keyword and actual results are + ;; indented by 2 columns. + (list (org-get-indentation) + (progn (forward-line) (org-get-indentation))))))) + (provide 'test-ob) ;;; test-ob ends here -- 2.11.4.GIT