org-babel: cleaner passing of parameter to language specific files

This commit is contained in:
Eric Schulte 2009-11-10 09:50:34 -07:00
parent 3ebaffe07e
commit 082fb84c34
3 changed files with 18 additions and 34 deletions

View File

@ -59,8 +59,9 @@
names, and the emacs-lisp representation of the related value."
(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)))
(others
(delq nil (mapcar (lambda (pair) (unless (eq :var (car pair)) pair)) params))))
(mapcar (lambda (assignment) (org-babel-ref-parse assignment others)) assignments)))
(defvar org-babel-ref-split-regexp
"[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*")

View File

@ -61,12 +61,11 @@
string))
(defmacro sbe (source-block &rest variables)
"Return the results of calling SOURCE-BLOCK with all assigning
every variable in VARIABLES. Each element of VARIABLES should be
a two element list, whose first element is the name of the
variable and second element is a string of its value. The
following call to `sbe' would be equivalent to the following
source code block.
"Return the results of calling SOURCE-BLOCK assigning every
variable in VARIABLES. Each element of VARIABLES should be a two
element list, whose first element is the name of the variable and
second element is a string of its value. The following call to
`sbe' would be equivalent to the following source code block.
(sbe 'source-block (n 2) (m 3))
@ -85,7 +84,9 @@ results
(format "%S=%s" (first var-spec) (second var-spec)))
',variables ", ")
")")))))
(org-babel-execute-src-block t (list "emacs-lisp" "results" params)))
(org-babel-execute-src-block
nil (list "emacs-lisp" "results"
(org-babel-merge-params '((:results . "silent")) params))))
"")))
(provide 'org-babel-table)

View File

@ -189,15 +189,17 @@ the header arguments specified at the source code block."
(result-type (fourth processed-params))
(cmd (intern (concat "org-babel-execute:" lang)))
result)
;; (message "params=%S" params) ;; debugging statement
;; (message "vars=%S" (second processed-params)) ;; debugging statement
;; (message "params=%S" params) ;; debugging
(unless (member lang org-babel-interpreters)
(error "Language is not in `org-babel-interpreters': %s" lang))
(when arg (setq result-params (cons "silent" result-params)))
(setq result (multiple-value-bind (session vars result-params result-type) processed-params
(funcall cmd body params)))
(setq result (funcall cmd body params))
(if (eq result-type 'value)
(setq result (org-babel-process-value-result result result-params)))
(setq result (if (and (or (member "vector" result-params)
(member "table" result-params))
(not (listp result)))
(list (list result))
result)))
(org-babel-insert-result result result-params info)
result))
@ -267,26 +269,6 @@ results already exist."
(insert (echo-res results))))))
t)))
(defun org-babel-process-value-result (result result-params)
"Process returned value for insertion in buffer.
Currently, this function forces to table output if :results
table or :results vector has been supplied.
You can see below the various fragments of results-processing
code that were present in the language-specific files. Out of
those fragments, I've moved the org-babel-python-table-or-results
and org-babel-import-elisp-from-file functionality into the
org-babel-*-evaluate functions. I think those should only be used
in the :results value case, as in the 'output case we are not
concerned with creating elisp versions of results. "
(if (and (or (member "vector" result-params)
(member "table" result-params))
(not (listp result)))
(list (list result))
result))
(defun org-babel-execute-buffer (&optional arg)
"Replace EVAL snippets in the entire buffer."
(interactive "P")