Fix long whitespace in colnames and long variable parsing
parent
e789251ce9
commit
494c4e2b79
3
init.jl
3
init.jl
|
@ -231,12 +231,13 @@ const Mimes = Dict(:org => "text/org",
|
||||||
|
|
||||||
function OrgBabelFormat(output_type::Symbol,
|
function OrgBabelFormat(output_type::Symbol,
|
||||||
output_file,
|
output_file,
|
||||||
dir, vars,
|
dir, vars_file,
|
||||||
src_file,
|
src_file,
|
||||||
silently::Bool,
|
silently::Bool,
|
||||||
pure::Bool,
|
pure::Bool,
|
||||||
kwargs)
|
kwargs)
|
||||||
content = read(src_file, String)
|
content = read(src_file, String)
|
||||||
|
vars = read(vars_file, String)
|
||||||
# Fake a prompt with the current input
|
# Fake a prompt with the current input
|
||||||
try
|
try
|
||||||
printstyled(IOContext(stdout, :color => true),
|
printstyled(IOContext(stdout, :color => true),
|
||||||
|
|
37
ob-julia.el
37
ob-julia.el
|
@ -224,20 +224,24 @@ values are Array taken from `VALUES', and assign it to `NAME'"
|
||||||
",")))
|
",")))
|
||||||
|
|
||||||
(defun org-babel-julia-assign-to-named-tuple (name column-names values)
|
(defun org-babel-julia-assign-to-named-tuple (name column-names values)
|
||||||
"Create a NamedTuple"
|
"Create a NamedTuple using (; zip([], [])...)"
|
||||||
(format "%s = [%s]" name
|
(let ((res (format "%s = [%s]" name
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (i)
|
(lambda (i)
|
||||||
(concat
|
(concat
|
||||||
"(" (mapconcat
|
"(; zip(["
|
||||||
(lambda (j)
|
(mapconcat
|
||||||
(format "%s=%S"
|
(lambda (col) (format "Symbol(\"%s\")" col))
|
||||||
(nth j column-names)
|
column-names ", ")
|
||||||
(nth j (nth i values))))
|
"],["
|
||||||
(number-sequence 0 (1- (length column-names)))
|
(mapconcat
|
||||||
",")
|
(lambda (cell) (format "\"%s\"" cell))
|
||||||
")"))
|
(nth i values)
|
||||||
(number-sequence 0 (1- (length values))) ", ")))
|
",")
|
||||||
|
"])...)"))
|
||||||
|
(number-sequence 0 (1- (length values))) ", "))))
|
||||||
|
(message res)
|
||||||
|
res))
|
||||||
|
|
||||||
(defun org-babel-variable-assignments:julia (params)
|
(defun org-babel-variable-assignments:julia (params)
|
||||||
"Return list of julia statements assigning the block's variables."
|
"Return list of julia statements assigning the block's variables."
|
||||||
|
@ -273,7 +277,8 @@ values are Array taken from `VALUES', and assign it to `NAME'"
|
||||||
OUTFILE and FILE can either be a string or nil.
|
OUTFILE and FILE can either be a string or nil.
|
||||||
If FILE is defined, output is _save()_d to a file with that name.
|
If FILE is defined, output is _save()_d to a file with that name.
|
||||||
else OUTFILE is used, and data is _write()_ to it."
|
else OUTFILE is used, and data is _write()_ to it."
|
||||||
(let* ((vars (org-babel-variable-assignments:julia params))
|
(let* ((vars (mapconcat 'concat (org-babel-variable-assignments:julia params) ";"))
|
||||||
|
(varsfile (make-temp-file "ob-julia-vars-" nil ".jl" vars))
|
||||||
(dir (or (cdr (assoc :dir params)) default-directory))
|
(dir (or (cdr (assoc :dir params)) default-directory))
|
||||||
(using-param (cdr (assoc :using params)))
|
(using-param (cdr (assoc :using params)))
|
||||||
(using (if using-param (split-string using-param) nil))
|
(using (if using-param (split-string using-param) nil))
|
||||||
|
@ -298,7 +303,7 @@ else OUTFILE is used, and data is _write()_ to it."
|
||||||
"OrgBabelFormat(%s,%S,%S,%S,%S,%s,%s,%S);"
|
"OrgBabelFormat(%s,%S,%S,%S,%S,%s,%s,%S);"
|
||||||
output-type outfile
|
output-type outfile
|
||||||
dir
|
dir
|
||||||
(mapconcat 'concat vars ";") srcfile
|
varsfile srcfile
|
||||||
(if org-babel-julia-silent-repl
|
(if org-babel-julia-silent-repl
|
||||||
"true" "false")
|
"true" "false")
|
||||||
(if (ob-julia-check-trueness params :let)
|
(if (ob-julia-check-trueness params :let)
|
||||||
|
|
Loading…
Reference in New Issue