Function: org-babel-map-call-lines

org-babel-map-call-lines is an autoloaded macro defined in ob-core.el.gz.

Signature

(org-babel-map-call-lines FILE &rest BODY)

Documentation

Evaluate BODY forms on each call line in FILE.

If FILE is nil evaluate BODY forms on source blocks in current buffer.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
;;;###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) (debug (form body)))
  (org-with-gensyms (datum end point tempvar to-be-removed visitedp)
    `(let* ((case-fold-search t)
	    (,tempvar ,file)
	    (,visitedp (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 "call_\\S-\\|^[ \t]*#\\+CALL:" nil t)
	   (let ((,datum (org-element-context)))
	     (when (org-element-type-p ,datum '(babel-call inline-babel-call))
	       (goto-char (or (org-element-post-affiliated datum)
                              (org-element-begin datum)))
	       (let ((,end (copy-marker (org-element-end ,datum))))
		 ,@body
		 (goto-char ,end)
		 (set-marker ,end nil))))))
       (unless ,visitedp (kill-buffer ,to-be-removed))
       (goto-char ,point))))