summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-06-10 10:02:07 -0700
committerEric Schulte <schulte.eric@gmail.com>2010-06-10 10:02:07 -0700
commit0e9e01c3fd50fdb458c05fae4fde1cdf52b5e125 (patch)
tree9bea93900f98ee3c08eb2936f8cb42c12ccb2479
parent9a3e9ad8658409027060cbd0a83c77742e70b676 (diff)
downloadorg-mode-0e9e01c3fd50fdb458c05fae4fde1cdf52b5e125.tar.gz
babel: results now indented to the level of the #+results: line
Thanks to Sébastien Vauban for pointing this out -- as well as the previous babel commit :) * contrib/babel/lisp/org-babel.el (org-babel-insert-result): results are now indented to the level of any existing #+results line.
-rw-r--r--contrib/babel/lisp/org-babel.el16
1 files changed, 12 insertions, 4 deletions
diff --git a/contrib/babel/lisp/org-babel.el b/contrib/babel/lisp/org-babel.el
index c147ced..bdd3286 100644
--- a/contrib/babel/lisp/org-babel.el
+++ b/contrib/babel/lisp/org-babel.el
@@ -221,7 +221,7 @@ block."
(params (setf (third info)
(sort (org-babel-merge-params (third info) params)
(lambda (el1 el2) (string< (symbol-name (car el1))
- (symbol-name (car el2)))))))
+ (symbol-name (car el2)))))))
(new-hash
(if (and (cdr (assoc :cache params))
(string= "yes" (cdr (assoc :cache params))))
@@ -484,7 +484,7 @@ added as the last element of the kill ring. This can be called
with C-c C-c."
(interactive)
(let ((hash (car (delq nil (mapcar
- (lambda (ol) (overlay-get ol 'babel-hash))
+ (lambda (ol) (overlay-get ol 'babel-hash))
(overlays-at (or point (point))))))))
(when hash (kill-new hash) (message hash))))
(add-hook 'org-ctrl-c-ctrl-c-hook 'org-babel-hash-at-point)
@@ -956,9 +956,14 @@ code ---- the results are extracted in the syntax of the source
(let ((existing-result (org-babel-where-is-src-block-result
t info hash))
(results-switches
- (cdr (assoc :results_switches (third info)))) beg)
+ (cdr (assoc :results_switches (third info))))
+ indent-level beg)
(when existing-result
(goto-char existing-result)
+ (save-excursion
+ (re-search-forward "#" nil t)
+ (setq indent-level (- (current-column) 1)))
+ (message "%d:%d" (point) indent-level)
(forward-line 1)
(cond
((member "replace" result-params)
@@ -995,7 +1000,10 @@ code ---- the results are extracted in the syntax of the source
(save-excursion (insert result)) (if (org-at-table-p) (org-cycle)))
(t
(org-babel-examplize-region
- (point) (progn (insert result) (point)) results-switches)))))
+ (point) (progn (insert result) (point)) results-switches)))
+ ;; possibly indent the results to match the #+results line
+ (when (and indent-level (> indent-level 0))
+ (indent-rigidly beg (org-babel-result-end) indent-level))))
(message "finished"))))
(defun org-babel-result-to-org-string (result)