Function: org-babel-ref-parse

org-babel-ref-parse is a byte-compiled function defined in ob-ref.el.gz.

Signature

(org-babel-ref-parse ASSIGNMENT)

Documentation

Parse a variable ASSIGNMENT in a header argument.

If the right hand side of the assignment has a literal value return that value, otherwise interpret it as a reference to an external resource and find its value using org-babel-ref-resolve.

Return a list with two elements: the name of the variable, and an Emacs Lisp representation of the value of the variable.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-ref.el.gz
(defun org-babel-ref-parse (assignment)
  "Parse a variable ASSIGNMENT in a header argument.

If the right hand side of the assignment has a literal value
return that value, otherwise interpret it as a reference to an
external resource and find its value using `org-babel-ref-resolve'.

Return a list with two elements: the name of the variable, and an
Emacs Lisp representation of the value of the variable."
  (when (string-match "\\(.+?\\)=" assignment)
    (let ((var (org-trim (match-string 1 assignment)))
	  (ref (org-trim (substring assignment (match-end 0)))))
      (cons (intern var)
	    (let ((out (save-excursion
			 (when org-babel-current-src-block-location
			   (goto-char (if (markerp org-babel-current-src-block-location)
					  (marker-position org-babel-current-src-block-location)
					org-babel-current-src-block-location)))
			 (org-babel-read ref))))
	      (if (equal out ref)
		  (if (and (string-prefix-p "\"" ref)
			   (string-suffix-p "\"" ref))
		      (read ref)
		    (org-babel-ref-resolve ref))
		out))))))