summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Davison <davison@stats.ox.ac.uk>2010-09-01 10:47:22 -0700
committerDan Davison <davison@stats.ox.ac.uk>2010-09-01 10:57:53 -0700
commit13891fce6e29310ea8e5d49e2bbc815377128789 (patch)
tree046f6facfb53edf1168e1c7815de2d09736ea7c8
parent0a46f202cac6530e7bd82bf621bb66c763b170a5 (diff)
downloadorg-mode-13891fce6e29310ea8e5d49e2bbc815377128789.tar.gz
babel: Allow `org-babel-map-src-blocks' to operate on current buffer
* ob.el (org-babel-map-src-blocks): If FILE is nil evaluate BODY forms on source blocks in current buffer; restore point in current buffer.
-rw-r--r--lisp/ob.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index 56005a6..753562b 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -724,12 +724,14 @@ portions of results lines."
'org-babel-show-result-all 'append 'local)))
(defmacro org-babel-map-src-blocks (file &rest body)
- "Evaluate BODY forms on each source-block in FILE."
+ "Evaluate BODY forms on each source-block in FILE. If FILE is
+nil evaluate BODY forms on source blocks in current buffer."
(declare (indent 1))
- `(let ((visited-p (get-file-buffer (expand-file-name ,file)))
- to-be-removed)
+ `(let ((visited-p (or (null ,file)
+ (get-file-buffer (expand-file-name ,file))))
+ (point (point)) to-be-removed)
(save-window-excursion
- (find-file ,file)
+ (if ,file (find-file ,file))
(setq to-be-removed (current-buffer))
(goto-char (point-min))
(while (re-search-forward org-babel-src-block-regexp nil t)
@@ -737,7 +739,8 @@ portions of results lines."
(save-match-data ,@body)
(goto-char (match-end 0))))
(unless visited-p
- (kill-buffer to-be-removed))))
+ (kill-buffer to-be-removed))
+ (goto-char point)))
(defvar org-file-properties)
(defun org-babel-params-from-properties (&optional lang)