Function: org-babel-lob--src-info

org-babel-lob--src-info is a byte-compiled function defined in ob-lob.el.gz.

Signature

(org-babel-lob--src-info REF)

Documentation

Return internal representation for Babel data referenced as REF.

REF is a string. This function looks into the current document for a Babel call or source block. If none is found, it looks after REF in the Library of Babel.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-lob.el.gz
(defun org-babel-lob--src-info (ref)
  "Return internal representation for Babel data referenced as REF.
REF is a string.  This function looks into the current document
for a Babel call or source block.  If none is found, it looks
after REF in the Library of Babel."
  (let ((name ref)
	(file nil))
    ;; Extract the remote file, if specified in the reference.
    (when (string-match "\\`\\(.+\\):\\(.+\\)\\'" ref)
      (setq file (match-string 1 ref))
      (setq name (match-string 2 ref)))
    ;; During export, look into the pristine copy of the document
    ;; being exported instead of the current one, which could miss
    ;; some data.
    (with-current-buffer (cond (file (find-file-noselect file t))
			       (org-babel-exp-reference-buffer)
			       (t (current-buffer)))
      (org-with-point-at 1
	(catch :found
	  (let ((case-fold-search t)
		(regexp (org-babel-named-data-regexp-for-name name)))
	    (while (re-search-forward regexp nil t)
	      (let ((element (org-element-at-point)))
		(when (equal name (org-element-property :name element))
		  (throw :found
			 (pcase (org-element-type element)
			   (`src-block (org-babel-get-src-block-info t element))
			   (`babel-call (org-babel-lob-get-info element))
			   ;; Non-executable data found.  Since names
			   ;; are supposed to be unique throughout
			   ;; a document, bail out.
			   (_ nil))))))
	    (cdr (assoc-string ref org-babel-library-of-babel))))))))