Browse Source

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.
Nicolas Goaziou 11 years ago
parent
commit
6fdc2361c9
2 changed files with 15 additions and 1 deletions
  1. 1 1
      lisp/ob-core.el
  2. 14 0
      testing/lisp/test-ob.el

+ 1 - 1
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))

+ 14 - 0
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