From fc7f4015c726e4a685002e8d69fad1eb1d605790 Mon Sep 17 00:00:00 2001 From: TEC Date: Wed, 8 Jul 2020 22:26:21 +0800 Subject: [PATCH 03/11] org-plot.el: add new custom gnuplot preamble * lisp/org-plot.el: Define new custom variable `org-plot/gnuplot-script-preamble' which can be either a string or a function. The value of this (when executed, in the case of the function) is inserted near the top of the generated gnuplot script. (org-plot/gnuplot-script): Use the new variable `org-plot/gnuplot-script-preamble' in the manner described. This allows for the user to set the font/colour-scheme, default precision, and much more. --- lisp/org-plot.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 6ff633130..f8db45273 100644 --- a/lisp/org-plot.el +++ b/lisp/org-plot.el @@ -181,6 +181,13 @@ and dependent variables." (setf back-edge "") (setf front-edge "")))) row-vals)) +(defcustom org-plot/gnuplot-script-preamble "" + "String or function which provides content to be inserted into the GNUPlot +script before the plot command. Not that this is in addition to, not instead of +other content generated in `org-plot/gnuplot-script'." + :group 'org-plot + :type '(choice string function)) + (defun org-plot/gnuplot-script (data-file num-cols params &optional preface) "Write a gnuplot script to DATA-FILE respecting the options set in PARAMS. NUM-COLS controls the number of columns plotted in a 2-d plot. @@ -213,6 +220,12 @@ manner suitable for prepending to a user-specified script." (when file ; output file (funcall ats (format "set term %s" (file-name-extension file))) (funcall ats (format "set output '%s'" file))) + + (funcall ats + (if (stringp org-plot/gnuplot-script-preamble) + org-plot/gnuplot-script-preamble + (org-plot/gnuplot-script-preamble))) + (pcase type ; type (`2d ()) (`3d (when map (funcall ats "set map"))) -- 2.28.0