diff --git a/lisp/ob-maxima.el b/lisp/ob-maxima.el index d1d7c7424..848811628 100644 --- a/lisp/ob-maxima.el +++ b/lisp/ob-maxima.el @@ -48,6 +48,33 @@ :group 'org-babel :type 'string) +(defcustom org-babel-maxima-command-arguments + "--very-quiet" + "Command-line arguments used when calling the Maxima executable. See `org-babel-maxima-batch/load' and `org-babel-execute:maxima'." + :group 'org-babel + :type 'string) + +(defcustom org-babel-maxima-batch/load + "batchload" + "The Maxima function used to read and execute Maxima code: `batchload' and `batch' are two alternatives, although a user-defined Maxima function may also be used. See `org-babel-execute:maxima'." + :options '("batchload" "batch") + :group 'org-babel + :type 'string) + +(defcustom org-babel-maxima-graphic-file-format-string + "(set_plot_option ('[gnuplot_term, png]), set_plot_option ('[gnuplot_out_file, %S]))$" + "A string with the Maxima code to set the graphic file terminal and name. It must contain `%S' to set the filename. See `org-babel-maxima-expand'." + :options '("(set_plot_option ('[gnuplot_term, png]), set_plot_option ('[gnuplot_out_file, %S]))$" "(load(draw), set_draw_option(terminal='pngcairo,file_name=%S))$") + :group 'org-babel + :type 'string) + + +(defcustom org-babel-maxima-default-epilogue + "gnuplot_close ()$" + "A string with the final Maxima code executed. See `org-babel-maxima-expand'." + :group 'org-babel + :type 'string) + (defun org-babel-maxima-expand (body params) "Expand a block of Maxima code according to its header arguments." (let ((vars (org-babel--get-vars params)) @@ -60,9 +87,7 @@ ;; graphic output (let ((graphic-file (ignore-errors (org-babel-graphical-output-file params)))) (if graphic-file - (format - "set_plot_option ([gnuplot_term, png]); set_plot_option ([gnuplot_out_file, %S]);" - graphic-file) + (format org-babel-maxima-graphic-file-format-string graphic-file) "")) ;; variables (mapconcat 'org-babel-maxima-var-to-maxima vars "\n") @@ -70,7 +95,7 @@ body ;; Any code from the specified epilogue at the end. epilogue - "gnuplot_close ()$") + org-babel-maxima-default-epilogue) "\n"))) (defun org-babel-execute:maxima (body params) @@ -81,10 +106,11 @@ This function is called by `org-babel-execute-src-block'." (result (let* ((cmdline (or (cdr (assq :cmdline params)) "")) (in-file (org-babel-temp-file "maxima-" ".max")) - (cmd (format "%s --very-quiet -r %s %s" + (cmd (format "%s %s -r %s %s" org-babel-maxima-command + org-babel-maxima-command-arguments (shell-quote-argument - (format "batchload(%S)$" in-file)) + (format "%s(%S)$" org-babel-maxima-batch/load in-file)) cmdline))) (with-temp-file in-file (insert (org-babel-maxima-expand body params))) (message cmd)