diff --git a/lisp/langs/org-babel-gnuplot.el b/lisp/langs/org-babel-gnuplot.el index 2947b6473..973ec8c4d 100644 --- a/lisp/langs/org-babel-gnuplot.el +++ b/lisp/langs/org-babel-gnuplot.el @@ -77,12 +77,13 @@ called by `org-babel-execute-src-block'." (y-labels (plist-get params :ylabels)) (time-ind (plist-get params :timeind))) ;; insert variables into code body - (mapc - (lambda (pair) - (setq body - (replace-regexp-in-string - (regexp-quote (format "%s" (car pair))) (cdr pair) body))) - vars) + (setq body + (concat + (mapconcat + (lambda (pair) (format "%s = \"%s\"" (car pair) (cdr pair))) + vars "\n") + "\n" + body)) ;; append header argument settings to body (when title (add-to-script (format "set title '%s'" title))) ;; title (when lines (mapc (lambda (el) (add-to-script el)) lines)) ;; line diff --git a/org-babel.org b/org-babel.org index 5f7b9a31c..d79e92d51 100644 --- a/org-babel.org +++ b/org-babel.org @@ -2119,12 +2119,14 @@ This could probably be added to [[file:lisp/org-babel-script.el][org-babel-scrip #+srcname: implementing-gnuplot #+begin_src gnuplot :var data=gnuplot-data set title "Implementing Gnuplot" -plot "data" using 1:2 with lines +plot data using 1:2 with lines #+end_src - - **** DONE add variables + gnuplot 4.2 and up support user defined variables. This is how + we will handle variables with org-babel (meaning we will need to + require gnuplot 4.2 and up for variable support). + - scalar variables should be replaced in the body of the gnuplot code - vector variables should be exported to tab-separated files, and the variable names should be replaced with the path to the files