diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2011-11-09 14:35:04 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-11-09 14:35:04 -0700 |
commit | 67a26e0141c147c22d76482e96770a81432d2f7b (patch) | |
tree | e33194eeb34d66b2787dff2c39cd037937c34e0c | |
parent | 4cf9de5ea0c545c1143001de432f71052fa9c3f8 (diff) | |
download | org-mode-67a26e0141c147c22d76482e96770a81432d2f7b.tar.gz |
execute call lines when executing an entire buffer
* lisp/ob-lob.el (org-babel-map-call-lines): Allow mapping of code
over all call lines in a buffer.
* lisp/ob.el (org-babel-execute-buffer): Execute call lines when
executing an entire buffer.
-rw-r--r-- | lisp/ob-lob.el | 24 | ||||
-rw-r--r-- | lisp/ob.el | 5 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lisp/ob-lob.el b/lisp/ob-lob.el index 9a87b70..d5ee239 100644 --- a/lisp/ob-lob.el +++ b/lisp/ob-lob.el @@ -88,6 +88,30 @@ If you change the value of this variable then your files may "Regexp to match calls to predefined source block functions.") ;; functions for executing lob one-liners + +;;;###autoload +(defmacro org-babel-map-call-lines (file &rest body) + "Evaluate BODY forms on each call line in FILE. +If FILE is nil evaluate BODY forms on source blocks in current +buffer." + (declare (indent 1)) + (let ((tempvar (make-symbol "file"))) + `(let* ((,tempvar ,file) + (visited-p (or (null ,tempvar) + (get-file-buffer (expand-file-name ,tempvar)))) + (point (point)) to-be-removed) + (save-window-excursion + (when ,tempvar (find-file ,tempvar)) + (setq to-be-removed (current-buffer)) + (goto-char (point-min)) + (while (re-search-forward org-babel-lob-one-liner-regexp nil t) + (goto-char (match-beginning 1)) + (save-match-data ,@body) + (goto-char (match-end 0)))) + (unless visited-p (kill-buffer to-be-removed)) + (goto-char point)))) +(def-edebug-spec org-babel-map-call-lines (form body)) + ;;;###autoload (defun org-babel-lob-execute-maybe () "Execute a Library of Babel source block, if appropriate. @@ -71,6 +71,7 @@ (declare-function org-babel-ref-goto-headline-id "ob-ref" (id)) (declare-function org-babel-ref-headline-body "ob-ref" ()) (declare-function org-babel-lob-execute-maybe "ob-lob" ()) +(declare-function org-babel-map-call-lines "ob-lob" (file &rest body)) (declare-function org-number-sequence "org-compat" (from &optional to inc)) (declare-function org-at-item-p "org-list" ()) (declare-function org-list-parse-list "org-list" (&optional delete)) @@ -858,7 +859,9 @@ the current buffer." (org-babel-map-src-blocks nil (org-babel-execute-src-block arg)) (org-babel-map-inline-src-blocks nil - (org-babel-execute-src-block arg)))) + (org-babel-execute-src-block arg)) + (org-babel-map-call-lines nil + (org-babel-lob-execute-maybe)))) ;;;###autoload (defun org-babel-execute-subtree (&optional arg) |