forked from mirrors/org-mode
DONE deeply nested arguments still fails
added a function `org-babel-ref-split-args' for splitting arguments into top-level balanced expressions
This commit is contained in:
parent
b10c0fb70b
commit
66faa937f8
|
@ -100,7 +100,7 @@ return nil."
|
||||||
(when (> (length new-refere) 0)
|
(when (> (length new-refere) 0)
|
||||||
(if (> (length new-referent) 0)
|
(if (> (length new-referent) 0)
|
||||||
(setq args (mapcar (lambda (ref) (cons :var ref))
|
(setq args (mapcar (lambda (ref) (cons :var ref))
|
||||||
(split-string new-referent ",[ \f\t\n\r\v]*"))))
|
(org-babel-ref-split-args new-referent))))
|
||||||
(message "args=%S" args)
|
(message "args=%S" args)
|
||||||
(setq ref new-refere)))
|
(setq ref new-refere)))
|
||||||
(when (string-match "\\(.+\\):\\(.+\\)" ref)
|
(when (string-match "\\(.+\\):\\(.+\\)" ref)
|
||||||
|
@ -143,6 +143,23 @@ return nil."
|
||||||
(if (symbolp result) (format "%S" result) result))
|
(if (symbolp result) (format "%S" result) result))
|
||||||
('lob (setq result (org-babel-execute-src-block t lob-info args)))))))
|
('lob (setq result (org-babel-execute-src-block t lob-info args)))))))
|
||||||
|
|
||||||
|
(defun org-babel-ref-split-args (arg-string)
|
||||||
|
"Split ARG-STRING into top-level arguments of balanced parenthesis."
|
||||||
|
(let ((index 0) (depth 0) (buffer "") holder return)
|
||||||
|
;; crawl along string, splitting at any ","s which are on the top level
|
||||||
|
(while (< index (length arg-string))
|
||||||
|
(setq holder (substring arg-string index (+ 1 index)))
|
||||||
|
(setq buffer (concat buffer holder))
|
||||||
|
(setq index (+ 1 index))
|
||||||
|
(cond
|
||||||
|
((string= holder ",")
|
||||||
|
(when (= depth 0)
|
||||||
|
(setq return (reverse (cons (substring buffer 0 -1) return)))
|
||||||
|
(setq buffer "")))
|
||||||
|
((string= holder "(") (setq depth (+ 1 depth)))
|
||||||
|
((string= holder ")") (setq depth (- 1 depth)))))
|
||||||
|
(reverse (cons buffer return))))
|
||||||
|
|
||||||
(defun org-babel-ref-at-ref-p ()
|
(defun org-babel-ref-at-ref-p ()
|
||||||
"Return the type of reference located at point or nil if none
|
"Return the type of reference located at point or nil if none
|
||||||
of the supported reference types are found. Supported reference
|
of the supported reference types are found. Supported reference
|
||||||
|
|
|
@ -2558,7 +2558,7 @@ arg
|
||||||
#+resname:
|
#+resname:
|
||||||
: 99
|
: 99
|
||||||
|
|
||||||
*** TODO deeply nested arguments still fails
|
*** DONE deeply nested arguments still fails
|
||||||
|
|
||||||
#+srcname: level-one-nesting
|
#+srcname: level-one-nesting
|
||||||
#+begin_src python :var arg=adder(a=adder(a=one(),b=one()),b=adder(a=one(),b=one()))
|
#+begin_src python :var arg=adder(a=adder(a=one(),b=one()),b=adder(a=one(),b=one()))
|
||||||
|
@ -2566,7 +2566,7 @@ arg
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+resname:
|
#+resname:
|
||||||
: 99
|
: 8
|
||||||
|
|
||||||
results in this error
|
results in this error
|
||||||
: supplied params=nil
|
: supplied params=nil
|
||||||
|
@ -2581,7 +2581,8 @@ results in this error
|
||||||
: reference 'one(' not found in this buffer
|
: reference 'one(' not found in this buffer
|
||||||
|
|
||||||
Need to change the regexp in [[file:lisp/org-babel-ref.el::assign%20any%20arguments%20to%20pass%20to%20source%20block][org-babel-ref-resolve-reference]] so that
|
Need to change the regexp in [[file:lisp/org-babel-ref.el::assign%20any%20arguments%20to%20pass%20to%20source%20block][org-babel-ref-resolve-reference]] so that
|
||||||
it only matches when the parenthesis are balanced.
|
it only matches when the parenthesis are balanced. Maybe look at
|
||||||
|
[[http://www.gnu.org/software/emacs/elisp/html_node/List-Motion.html][this]].
|
||||||
|
|
||||||
** TODO allow srcname to omit function call parentheses
|
** TODO allow srcname to omit function call parentheses
|
||||||
Someone needs to revisit those regexps. Is there an argument for
|
Someone needs to revisit those regexps. Is there an argument for
|
||||||
|
|
Loading…
Reference in a new issue