mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-25 07:27:57 +00:00
org-babel: nested calls inherit header args from enclosing scopes
And when merging header args, those from enclosing scopes take precedence. For example, output to file from a source block is implemented by (a) sending the output to file, and (b) having the source block return the file name as its result. Before this change, the file name returned could be set by a referenced source block (a nested call), regardless of the value of the :file header arg of the top-level source block.
This commit is contained in:
parent
6c0c2039dd
commit
0d10946cff
@ -57,10 +57,12 @@
|
||||
(defun org-babel-ref-variables (params)
|
||||
"Takes a parameter alist, and return an alist of variable
|
||||
names, and the emacs-lisp representation of the related value."
|
||||
(mapcar #'org-babel-ref-parse
|
||||
(delq nil (mapcar (lambda (pair) (if (eq (car pair) :var) (cdr pair))) params))))
|
||||
(let ((assignments
|
||||
(delq nil (mapcar (lambda (pair) (if (eq (car pair) :var) (cdr pair))) params)))
|
||||
(other-params (assq-delete-all :var params)))
|
||||
(mapcar (lambda (assignment) (org-babel-ref-parse assignment other-params)) assignments)))
|
||||
|
||||
(defun org-babel-ref-parse (assignment)
|
||||
(defun org-babel-ref-parse (assignment params)
|
||||
"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 as a reference to an external resource
|
||||
@ -74,7 +76,7 @@ emacs-lisp representation of the value of the variable."
|
||||
(ref (match-string 2 assignment)))
|
||||
(cons (intern var)
|
||||
(or (org-babel-ref-literal ref)
|
||||
(org-babel-ref-resolve-reference ref))))))
|
||||
(org-babel-ref-resolve-reference ref params))))))
|
||||
|
||||
(defun org-babel-ref-literal (ref)
|
||||
"Determine if the right side of a header argument variable
|
||||
@ -87,7 +89,7 @@ return nil."
|
||||
(read ref))
|
||||
out)))
|
||||
|
||||
(defun org-babel-ref-resolve-reference (ref)
|
||||
(defun org-babel-ref-resolve-reference (ref params)
|
||||
"Resolve the reference and return its value"
|
||||
(save-excursion
|
||||
(let ((case-fold-search t)
|
||||
@ -134,14 +136,14 @@ return nil."
|
||||
(beginning-of-line)
|
||||
(if (or (= (point) (point-min)) (= (point) (point-max)))
|
||||
(error "reference not found"))))
|
||||
;; (message "type=%S" type) ;; debugging
|
||||
(case type
|
||||
('results-line (org-babel-read-result))
|
||||
('table (org-babel-read-table))
|
||||
('source-block
|
||||
(setq result (org-babel-execute-src-block t nil args))
|
||||
(if (symbolp result) (format "%S" result) result))
|
||||
('lob (setq result (org-babel-execute-src-block t lob-info args)))))))
|
||||
(setq params (org-babel-merge-params params args))
|
||||
(setq result
|
||||
(case type
|
||||
('results-line (org-babel-read-result))
|
||||
('table (org-babel-read-table))
|
||||
('source-block (org-babel-execute-src-block t nil params))
|
||||
('lob (org-babel-execute-src-block t lob-info params))))
|
||||
(if (symbolp result) (format "%S" result) result))))
|
||||
|
||||
(defun org-babel-ref-split-args (arg-string)
|
||||
"Split ARG-STRING into top-level arguments of balanced parenthesis."
|
||||
|
Loading…
Reference in New Issue
Block a user