ob: ob-exec-buf and ob-exec-tree now eval inline code blocks as well
* lisp/ob.el (org-babel-map-inline-src-blocks): Macro for executing code in each inline code block. (org-babel-execute-buffer): Executes inline code blocks as well as regular code blocks.
This commit is contained in:
parent
db0e815a4c
commit
39c982eb49
1 changed files with 24 additions and 0 deletions
24
lisp/ob.el
24
lisp/ob.el
|
@ -653,6 +653,28 @@ end-body --------- point at the end of the body"
|
|||
(unless visited-p (kill-buffer to-be-removed))
|
||||
(goto-char point))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro org-babel-map-inline-src-blocks (file &rest body)
|
||||
"Evaluate BODY forms on each inline source-block 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-inline-src-block-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))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-execute-buffer (&optional arg)
|
||||
"Execute source code blocks in a buffer.
|
||||
|
@ -662,6 +684,8 @@ the current buffer."
|
|||
(org-babel-eval-wipe-error-buffer)
|
||||
(org-save-outline-visibility t
|
||||
(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))))
|
||||
|
||||
;;;###autoload
|
||||
|
|
Loading…
Reference in a new issue