From 253b9d22ebee26ae89127de9071cac0ee6bfbd23 Mon Sep 17 00:00:00 2001 From: TEC Date: Wed, 8 Jul 2020 22:26:21 +0800 Subject: [PATCH 3/8] Add org-plot custom to add content to all plots Adds a new custom: `org-plot/gnuplot-script-preamble' which can be either a string or function (which is called to produce a string). This allows for the user to add gnuplot script to the code generated by `org-plot/gnuplot', setting say the font/colour-scheme, default precision, etc. --- lisp/org-plot.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lisp/org-plot.el b/lisp/org-plot.el index 25a0f605b..5a36fd624 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.27.0