Add support for elisp list type
This commit is contained in:
parent
2a48331bb2
commit
50496a2cc8
1 changed files with 14 additions and 8 deletions
22
ob-sclang.el
22
ob-sclang.el
|
@ -5,7 +5,7 @@
|
||||||
;; Author: Michal Seta
|
;; Author: Michal Seta
|
||||||
;; Keywords: supercollider, literate programming, reproducible research
|
;; Keywords: supercollider, literate programming, reproducible research
|
||||||
;; Homepage: https://github.com/djiamnot/ob-sclang.git
|
;; Homepage: https://github.com/djiamnot/ob-sclang.git
|
||||||
;; Version: 0.01
|
;; Version: 0.02
|
||||||
|
|
||||||
;;; License:
|
;;; License:
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
'((:results . "none")))
|
'((:results . "none")))
|
||||||
|
|
||||||
(defun org-babel-expand-body:sclang (body params)
|
(defun org-babel-expand-body:sclang (body params)
|
||||||
;; "Expand BODY according to PARAMS, return the expanded body."
|
"Expand BODY according to PARAMS, return the expanded body."
|
||||||
(let ((vars (org-babel--get-vars params)))
|
(let ((vars (org-babel--get-vars params)))
|
||||||
(mapc
|
(mapc
|
||||||
(lambda (pair)
|
(lambda (pair)
|
||||||
|
@ -50,16 +50,22 @@
|
||||||
(setq body
|
(setq body
|
||||||
(replace-regexp-in-string
|
(replace-regexp-in-string
|
||||||
(regexp-quote name)
|
(regexp-quote name)
|
||||||
(cond
|
(org-babel-sclang-var-to-sclang value)
|
||||||
((stringp value) (format "%S" value))
|
|
||||||
((floatp value) (format "%f" value))
|
|
||||||
((integerp value) (format "%d" value))
|
|
||||||
((symbolp value) (concat (format "%S" (symbol-name value)) ".asSymbol"))
|
|
||||||
)
|
|
||||||
body))))
|
body))))
|
||||||
vars)
|
vars)
|
||||||
body))
|
body))
|
||||||
|
|
||||||
|
(defun org-babel-sclang-var-to-sclang (var)
|
||||||
|
"Convert an elisp value to a string of sclang code represting the value of the
|
||||||
|
variable with correct type."
|
||||||
|
(if (listp var)
|
||||||
|
(concat "[" (mapconcat #'org-babel-sclang-var-to-sclang var ", ") "]")
|
||||||
|
(cond ((stringp var) (format "%S" var))
|
||||||
|
((floatp var) (format "%f" var))
|
||||||
|
((integerp var) (format "%d" var))
|
||||||
|
((symbolp var) (concat (format "%S" (symbol-name var)) ".asSymbol")))
|
||||||
|
))
|
||||||
|
|
||||||
(defun org-babel-execute:sclang (body params)
|
(defun org-babel-execute:sclang (body params)
|
||||||
"Execute a block of Sclang code with org-babel.
|
"Execute a block of Sclang code with org-babel.
|
||||||
This function is called by `org-babel-execute-src-block'"
|
This function is called by `org-babel-execute-src-block'"
|
||||||
|
|
Loading…
Reference in a new issue