diff options
author | Dan Davison <davison@stats.ox.ac.uk> | 2010-09-01 10:47:22 -0700 |
---|---|---|
committer | Dan Davison <davison@stats.ox.ac.uk> | 2010-09-01 10:57:53 -0700 |
commit | 13891fce6e29310ea8e5d49e2bbc815377128789 (patch) | |
tree | 046f6facfb53edf1168e1c7815de2d09736ea7c8 | |
parent | 0a46f202cac6530e7bd82bf621bb66c763b170a5 (diff) | |
download | org-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.el | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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) |