temp files, was: how to re-define the HOME directory?




On Fri, 5 Jun 2009, Mario Rodriguez wrote:
 
< My solution was to include two global variables: one for the name of the file
< containing gnuplot commands, and the other to store the data. These two global
< variables are not documented.
< 
< 
< (%i1) load(draw)$
< (%i2) gnuplot_file_name : "my_commands_for_gnuplot"$
< (%i3) data_file_name : "my_data_for_gnuplot"$
< (%i4) draw2d(
<        file_name = "my_file",
<        explicit(x^2,x,-1,1),
<        terminal=png) $
 
Mario,
I have one comment and two requests:

C1/ This provides a means for a user to tailor draw*d filenames, but not
plot*d.

R1/ Please add the above comments to the documentation for draw2d.

R2/ In draw.lisp, you make a total of 6 calls to plot-temp-file. The
first 2 calls are necessary, in order to add the *maxima-tempdir* prefix
to $gnuplot_file_name and $data_file_name. However, the remaining 4
calls can be omitted if the results of the first 2 calls are stored in 
appropriate variables. I think this is better programming style, too.

The change I propose is encapsulated by the attached diff output. 

If you implement the change, then you treat plot-temp-file as a black box that
creates a name of a temporary file, without knowing how it does that.
Your code doesn't need to know the details of plot-temp-file.

--------------------------

With this change to draw.lisp, I am able to run all the examples in the
documentation of draw*d, plot2d and the examples in plot.lisp itself
with both randomised and non-randomised plot-temp-file.

See the attached files mktemp-test.mac and its output file
mktemp-test.txt.

--------------------------

Andrej,
I have provided a means to clean-up the temp files created by calls to
the randomised version of plot-temp-file. See the tail of
mktemp-test.txt.

--------------------------

Robert,
I have added a function $mktemp that implements mktemp in cl, except it
returns an output stream. There is also a function $mktemp_clean that
removes all temp files created by $mktemp.

Leo.
-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

-------------- next part --------------
;;; -*-  Mode: Lisp; Package: Maxima; Syntax: Common-Lisp; Base: 10 -*- ;;;;
;;
;; $Id: mktemp.lisp,v 1.4 2009/06/06 13:33:54 work Exp work $
;;
;; Copyright: Leo Butler (l.butler at ed.ac.uk)
;;
;; This file is part of the Maxima CAS code (http://maxima.sourceforge.net/)
;; 
;; It is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or (at your
;; option) any later version.
;; 
;; This software is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; 
;; You should have received a copy of the GNU General Public License
;; along with this file. If not, see http://www.gnu.org/licenses/. 
;;
(in-package :maxima)

(defvar *admissible-characters* (vector #\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m #\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\z #\A #\B #\C #\D #\E #\F #\G #\H #\I #\J #\K #\L #\M #\N #\O #\P #\Q #\R #\S #\T #\U #\V #\W #\X #\Y #\Z #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9))
(defvar *num-admissible-characters* (length *admissible-characters*))
(defvar *default-suffix-length* 6)
(defvar *default-tempfile-root* "maxima-temp-")
(defvar *default-special-char* #\X)
(defvar *last-random-state* (make-random-state))
(defvar $files_named_by_plot_temp_file '((mlist simp)))
(defvar $randomise_plot_files t)

(defun randomise-template (template &key (special-char *default-special-char*) (seed *random-state*))
  (declare (type 'string template) (type 'string-char special-char))
  (map 'string #'(lambda (u)
		   (if (char= u special-char)
		       (make-random-char :seed seed) u)) template))

(defun make-random-char (&key (seed *random-state*))
  (let* ((c (random *num-admissible-characters* seed)) (rand-char (aref *admissible-characters* c)))
    rand-char))

(defun make-template (&key
		      (root *default-tempfile-root*)
		      (suffix-length *default-suffix-length*)
		      (special-char *default-special-char*))
  (declare (type 'string root) (type 'fixnum suffix-length))
  (let ((suf ""))
    (if (> suffix-length 0)
	(progn
	  (setf suf (make-string suffix-length :initial-element special-char))
	  (concatenate 'string root suf))
      (make-template :root root :special-char special-char))))

(defun make-tempfilename (&key
			  (template *default-tempfile-root*)
			  (special-char *default-special-char*)
			  (seed *random-state*)
			  (suffix-length *default-suffix-length*))
  "Function: make-tempfilename (&key (template *default-tempfile-root*) (special-char *default-special-char*) (seed *random-state*))

>(make-tempfilename)                                                         --> \"maxima-temp-FcUwTn\"
>(make-tempfilename :template \"maxout-XXXXXX.gnuplot\")                     --> \"maxout-dlEDpX.gnuplot\"
>(make-tempfilename :template \"tmp-YYYYYY\" :seed #$2134 :special-char #\Y) --> \"tmp-UGBt7S\"   (GCL)

The seed is overwritten, so to re-use, you must save seed externally or pass a constant.
Implements the string manipulations of mkstemp.c in C-L (http://www.opensource.apple.com/source/shell_cmds/shell_cmds-118/mktemp/mktemp.c).
Due to portability issues (see http://www.faqs.org/faqs/lisp-faq/part2/section-19.html) we do not attempt to open/create files or directories."
  (declare (type 'string template))
  (when (string= template *default-tempfile-root*) 
    (setf template (make-template :root template)))
  (if (stringp template)
      (setf template (randomise-template template :special-char special-char :seed seed))
      (make-tempfilename :special-char special-char :seed seed))
  template)

;; Altered from src/plot.lisp
;; This adds 6 random chars at the end of
;; a file name, and returns this filename
;; if a file of that name does not exist.
;; randomise\? 0 -> no
;; randomise\? 1 -> yes, with a new seed
;; randomise\? 2 -> yes, with last seed
(defun plot-temp-file (file &key (depth 0) (randomise\? 1))
  "(plot-temp-file (file &key (depth 0) (randomise\? 1)))

This adds 6 random chars at the end of a string 'file', and returns this 
new string if a file of that name does not exist in *maxima-tempdir*.
randomise\? 0 -> no extra characters are appended
randomise\? 1 -> yes, with a new seed
randomise\? 2 -> yes, with last seed"
  (declare
   (type 'string file)
   (type (fixnum 0 most-positive-fixnum) depth)
   (type (integer 0 2) randomise\?))
  (let (tmp-file seed (max-depth most-positive-fixnum)) ;; 62^5 < most-positive-fixnum < 62^6
    (if *maxima-tempdir* 
	(setf tmp-file (format nil "~a/~a" *maxima-tempdir* file))
	(setf tmp-file file))
    (when $randomise_plot_files
      (cond
	((= randomise\? 1)
	 (setf seed (make-random-state *random-state*))
	 (setf *last-random-state* (make-random-state *random-state*))
	 (setf tmp-file (make-tempfilename :template (make-template :root tmp-file)))
	 (when (and (probe-file tmp-file) (< depth max-depth))
	   (plot-temp-file file :randomise\? 1 :depth (+ depth 1))))
	((= randomise\? 2)
	 (setf seed (make-random-state *last-random-state*))
	 (setf tmp-file (make-tempfilename :seed seed :template (make-template :root tmp-file))))
	(t nil))
      (push tmp-file (cdr $files_named_by_plot_temp_file)))
    tmp-file))

(defun clean-files (files)
  (when (listp files)
    (mapc #'(lambda (f) (cond ((probe-file f)
			       (delete-file f))
			      (t
			       nil)))
	  files)
    (setf files (remove-if-not #'(lambda (f) (probe-file f)) files))
    files))

(defun $exit ()
"($exit)
Cleans temporary files named by plot-temp-files, then quits Maxima."
  (unwind-protect (progn
		    (clean-files (cdr $files_named_by_plot_temp_file)))
    ($quit)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar $mktemp_files '((mlist simp)))
(defun $mktemp (template &optional (file-type #\f) (seed *random-state*))
  "($mktemp template &optional (file-type #\f) (seed *random-state*))

Creates a file/directory name based on the template, and returns the open
character filestream if file is created. Directories are automatically
created if they do not exist.

Usage:
($mktemp \"/tmp/tmp-XXXX\")
#<OUTPUT BUFFERED FILE-STREAM CHARACTER #P\"/tmp/tmp-VcuO\">
($mktemp \"/tmp/tmp-XXXX\" #\d)
NIL
"
  (let* ((strm nil)
	 (filename (make-tempfilename :template template))
	 (directory (or (char= file-type #\D) (char= file-type #\d))))
    (when (probe-file filename)
      ($mktemp template file-type)) ;; we need to randomise ; ;
    (cond (directory
	   (progn
	     (setf strm ($mktemp (concatenate 'string template "/X") #\f seed))
	     (close strm)
	     (delete-file strm)
	     (pop (cdr $mktemp_files))))
	  (t
	   (setf strm (open (ensure-directories-exist filename) :direction :output))))
    (push strm (cdr $mktemp_files))
    strm))

(defun $mktemp_clean ()
"($mktemp_clean)

Closes and deletes all files created by $mktemp.
Directories are left in place.
"
  (mapc #'(lambda (f) (cond ((probe-file f)
			     (close f)
			     (delete-file f))
			    (t
			     nil)))
	(cdr $mktemp_files))
  (setf (cdr $mktemp_files) (remove-if-not #'(lambda (f) (probe-file f)) (cdr $mktemp_files)))
  $mktemp_files)
  
-------------- next part --------------
load("/knoppix-home/work/lisp/mktemp.lisp");
load("/knoppix-home/work/maxima/maxima-5.18.1-clisp/share/draw/draw.lisp");

plot2d(sin(x), [x,-5,5])$
plot2d (sec(x), [x, -2, 2], [y, -20, 20], [nticks, 200])$
F(x) := x^2 $
:lisp (defun |$g| (x) (m* x x x))
H(x) := if x < 0 then x^4 - 1 else 1 - x^5 $
plot2d (F, [u, -1, 1])$
plot2d ([F, G, H], [u, -1, 1], [y, -1.5, 1.5])$
plot2d ([parametric, cos(t), sin(t), [t,-%pi,%pi],
  [nticks,80]], [x, -4/3, 4/3])$
plot2d ([parametric, cos(t), sin(t), [t, -%pi*2, %pi*2],
  [nticks, 8]], [x, -2, 2], [y, -1.5, 1.5])$
plot2d ([x^3+2, [parametric, cos(t), sin(t), [t, -5, 5],
  [nticks, 80]]], [x, -3, 3])$
plot2d (exp(3*s), [s, -2, 2], [logy])$
xx:[10, 20, 30, 40, 50]$
yy:[.6, .9, 1.1, 1.3, 1.4]$
xy:[[10,.6], [20,.9], [30,1.1], [40,1.3], [50,1.4]]$
plot2d([discrete, xy], [style, points])$
plot2d([[discrete,xy], 2*%pi*sqrt(l/980)], [l,0,50],
  [style, [points,5,2,6], [lines,1,1]],
  [legend,"experiment","theory"],
  [xlabel,"pendulum's length (cm)"], [ylabel,"period (s)"])$
plot2d (sin(x), [x, 0, 2*%pi], [psfile, "sin.eps"])$
plot2d ([gamma(x), 1/gamma(x)], [x, -4.5, 5], [y, -10, 10],
  [gnuplot_preamble, "set key bottom"])$
my_preamble: "set xtics ('-2pi' -6.283, \
                                   '-3pi/2' -4.712, '-pi' -3.1415, '-pi/2' -1.5708, '0' 0, \
                                             'pi/2' 1.5708, 'pi' 3.1415,'3pi/2' 4.712, '2pi' 6.283)"$

plot2d([cos(x), sin(x), tan(x), cot(x)],[x, -2*%pi, 2.1*%pi], [y, -2, 2], [axes, x],
  [gnuplot_preamble, my_preamble])$
my_preamble: "set xtics ('-2{/Symbol p}' \
                                        -6.283, '-3{/Symbol p}/2' -4.712, '-{/Symbol p}' -3.1415, \
                                                  '-{/Symbol p}/2' -1.5708, '0' 0,'{/Symbol p}/2' 1.5708, \
                                                            '{/Symbol p}' 3.1415,'3{/Symbol p}/2' 4.712, '2{/Symbol p}' \
                                                                      6.283)"$

plot2d ([cos(x), sin(x), tan(x)], [x, -2*%pi, 2*%pi],
  [y, -2, 2], [gnuplot_preamble, my_preamble],
  [psfile, "trig.eps"])$
/* plot of z^(1/3)...*/
plot3d(r^.33*cos(th/3),[r,0,1],[th,0,6*%pi],['grid,12,80],['transform_xy,polar_to_xy]) ;
/* plot of z^(1/2)...*/
plot3d(r^.5*cos(th/2),[r,0,1],[th,0,6*%pi],['grid,12,80],['transform_xy,polar_to_xy]) ;
/* moebius */
plot3d([cos(x)*(3+y*cos(x/2)),sin(x)*(3+y*cos(x/2)),y*sin(x/2)],[x,-%pi,%pi],[y,-1,1],['grid,50,15]) ;
/* klein bottle */
plot3d([5*cos(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0) - 10.0,
-5*sin(x)*(cos(x/2)*cos(y)+sin(x/2)*sin(2*y)+3.0),
5*(-sin(x/2)*cos(y)+cos(x/2)*sin(2*y))],[x,-%pi,%pi],[y,-%pi,%pi],
['grid,40,40])                          ;
/* torus */
plot3d([cos(y)*(10.0+6*cos(x)),
sin(y)*(10.0+6*cos(x)),
-6*sin(x)], [x,0,2*%pi],[y,0,2*%pi],['grid,40,40]) ;

contour_plot (x^2 + y^2, [x, -4, 4], [y, -4, 4]);
contour_plot (sin(y) * cos(x)^2, [x, -4, 4], [y, -4, 4]);
F(x, y) := x^3 + y^2;
contour_plot (F, [u, -4, 4], [v, -4, 4]);
contour_plot (F, [u, -4, 4], [v, -4, 4], [gnuplot_preamble, "set size ratio -1"]);
set_plot_option ([gnuplot_preamble, "set cntrparam levels 12"]);
contour_plot (F, [u, -4, 4], [v, -4, 4]);
set_plot_option ([plot_format, openmath]);
/* contour_plot (F, [u, -4, 4], [v, -4, 4]); /\*=> error: must be gnuplot format*\/ */
contour_plot (F, [u, -4, 4], [v, -4, 4], [plot_format, gnuplot]);

scene1: gr2d(title="Ellipse",
  nticks=30,
  parametric(2*cos(t),5*sin(t),t,0,2*%pi))$
scene2: gr2d(title="Triangle",
  polygon([4,5,7],[6,4,2]))$
draw(scene1, scene2, columns = 2)$
draw(gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1)));
draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1));

ls_cmd : concat("ls -t ",maxima_tempdir,"/maxo* ",maxima_tempdir,"/data*");
system(ls_cmd);
exit();
-------------- next part --------------
$ maxima --lisp=clisp -b ~/lisp/mktemp-test.mac > ~/lisp/mktemp-test.txt
Maxima 5.18.1 http://maxima.sourceforge.net
Using Lisp CLISP 2.44.1 (2008-02-23)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
WARNING: DEFUN/DEFMACRO: redefining function TEX-MQUOTIENT in /knoppix-home/work/maxima/maxima-5.18.1/share/utils/mactex-utilities.lisp, was defined in
         /knoppix-home/work/maxima/maxima-5.18.1/src/binary-clisp/mactex.fas
WARNING: DEFUN/DEFMACRO: redefining function TEX-MATRIX in /knoppix-home/work/maxima/maxima-5.18.1/share/utils/mactex-utilities.lisp, was defined in
         /knoppix-home/work/maxima/maxima-5.18.1/src/binary-clisp/mactex.fas

batching /knoppix-home/work/.maxima/maxima-init.lisp
WARNING: DEFUN/DEFMACRO: redefining function TEX-COMMENT in top-level, was defined in /knoppix-home/work/.maxima/maxima-init.lisp
TEX-COMMENT
TEX-COMMENT
(%i1) batch("/knoppix-home/work/lisp/mktemp-test.mac")

batching /knoppix-home/work/lisp/mktemp-test.mac
(%i2) load("/knoppix-home/work/lisp/mktemp.lisp")
WARNING: DEFUN/DEFMACRO: redefining function PLOT-TEMP-FILE in /knoppix-home/work/lisp/mktemp.lisp, was defined in
         /knoppix-home/work/maxima/maxima-5.18.1/src/binary-clisp/plot.fas
(%o2) "/knoppix-home/work/lisp/mktemp.lisp"
(%i3) load("/knoppix-home/work/maxima/maxima-5.18.1-clisp/share/draw/draw.lisp")
(%o3) "/knoppix-home/work/maxima/maxima-5.18.1-clisp/share/draw/draw.lisp"
(%i4) plot2d(sin(x),[x,-5,5])
(%i5) plot2d(sec(x),[x,-2,2],[y,-20,20],[nticks,200])
plot2d: expression evaluates to non-numeric value somewhere in plotting range.
(%i6) F(x):=x^2
$g
(%i7) H(x):=if x < 0 then x^4-1 else 1-x^5
(%i8) plot2d(F,[u,-1,1])
(%i9) plot2d([F,G,H],[u,-1,1],[y,-1.5,1.5])
(%i10) plot2d([parametric,cos(t),sin(t),[t,-%pi,%pi],[nticks,80]],
              [x,(-4)/3,4/3])
(%i11) plot2d([parametric,cos(t),sin(t),[t,-%pi*2,%pi*2],[nticks,8]],[x,-2,2],
              [y,-1.5,1.5])
(%i12) plot2d([2+x^3,[parametric,cos(t),sin(t),[t,-5,5],[nticks,80]]],
              [x,-3,3])
(%i13) plot2d(exp(3*s),[s,-2,2],[logy])
(%i14) xx:[10,20,30,40,50]
(%i15) yy:[0.6,0.9,1.1,1.3,1.4]
(%i16) xy:[[10,0.6],[20,0.9],[30,1.1],[40,1.3],[50,1.4]]
(%i17) plot2d([discrete,xy],[style,points])
(%i18) plot2d([[discrete,xy],2*%pi*sqrt(l/980)],[l,0,50],
              [style,[points,5,2,6],[lines,1,1]],
              [legend,"experiment","theory"],
              [xlabel,"pendulum's length (cm)"],[ylabel,"period (s)"])
(%i19) plot2d(sin(x),[x,0,2*%pi],[psfile,"sin.eps"])
(%i20) plot2d([gamma(x),1/gamma(x)],[x,-4.5,5],[y,-10,10],
              [gnuplot_preamble,"set key bottom"])
plot2d: expression evaluates to non-numeric value somewhere in plotting range.
plot2d: expression evaluates to non-numeric value somewhere in plotting range.
(%i21) my_preamble:"set xtics ('-2pi' -6.283,                                    '-3pi/2' -4.712, '-pi' -3.1415, '-pi/2' -1.5708, '0' 0,                                              'pi/2' 1.5708, 'pi' 3.1415,'3pi/2' 4.712, '2pi' 6.283)"
(%i22) plot2d([cos(x),sin(x),tan(x),cot(x)],[x,-2*%pi,2.1*%pi],[y,-2,2],
              [axes,x],[gnuplot_preamble,my_preamble])
plot2d: expression evaluates to non-numeric value somewhere in plotting range.
plot2d: expression evaluates to non-numeric value somewhere in plotting range.
(%i23) my_preamble:"set xtics ('-2{/Symbol p}'                                         -6.283, '-3{/Symbol p}/2' -4.712, '-{/Symbol p}' -3.1415,                                                   '-{/Symbol p}/2' -1.5708, '0' 0,'{/Symbol p}/2' 1.5708,                                                             '{/Symbol p}' 3.1415,'3{/Symbol p}/2' 4.712, '2{/Symbol p}'                                                                       6.283)"
(%i24) plot2d([cos(x),sin(x),tan(x)],[x,-2*%pi,2*%pi],[y,-2,2],
              [gnuplot_preamble,my_preamble],[psfile,"trig.eps"])
plot2d: expression evaluates to non-numeric value somewhere in plotting range.
(%i25) plot3d(r^0.33*cos(th/3),[r,0,1],[th,0,6*%pi],['grid,12,80],
              ['transform_xy,polar_to_xy])
(%o25) false
(%i26) plot3d(r^0.5*cos(th/2),[r,0,1],[th,0,6*%pi],['grid,12,80],
              ['transform_xy,polar_to_xy])
(%o26) false
(%i27) plot3d([cos(x)*(y*cos(x/2)+3),sin(x)*(y*cos(x/2)+3),y*sin(x/2)],
              [x,-%pi,%pi],[y,-1,1],['grid,50,15])
(%o27) false
(%i28) plot3d([5*cos(x)*(3.0+sin(x/2)*sin(2*y)+cos(x/2)*cos(y))-10.0,
               -5*sin(x)*(3.0+sin(x/2)*sin(2*y)+cos(x/2)*cos(y)),
               5*(cos(x/2)*sin(2*y)-sin(x/2)*cos(y))],[x,-%pi,%pi],
              [y,-%pi,%pi],['grid,40,40])
(%o28) false
(%i29) plot3d([cos(y)*(6*cos(x)+10.0),sin(y)*(6*cos(x)+10.0),-6*sin(x)],
              [x,0,2*%pi],[y,0,2*%pi],['grid,40,40])
(%o29) false
(%i30) contour_plot(y^2+x^2,[x,-4,4],[y,-4,4])
(%o30) false
(%i31) contour_plot(sin(y)*cos(x)^2,[x,-4,4],[y,-4,4])
(%o31) false
(%i32) F(x,y):=y^2+x^3
(%o32) F(x,y):=y^2+x^3
(%i33) contour_plot(F,[u,-4,4],[v,-4,4])
(%o33) false
(%i34) contour_plot(F,[u,-4,4],[v,-4,4],
                    [gnuplot_preamble,"set size ratio -1"])
(%o34) false
(%i35) set_plot_option([gnuplot_preamble,"set cntrparam levels 12"])
(%o35) [[x,-1.75555970201398E+305,1.75555970201398E+305],
        [y,-1.75555970201398E+305,1.75555970201398E+305],[t,-3,3],
        [grid,30,30],[transform_xy,false],[run_viewer,true],[axes,true],
        [plot_format,gnuplot_pipes],[gnuplot_term,default],
        [gnuplot_out_file,false],[nticks,29],[adapt_depth,5],
        [gnuplot_pm3d,false],[gnuplot_preamble,"set cntrparam levels 12"],
        [gnuplot_curve_titles,[default]],
        [gnuplot_curve_styles,
         ["with lines 3","with lines 1","with lines 2","with lines 5",
          "with lines 4","with lines 6","with lines 7"]],
        [gnuplot_default_term_command,"set term x11 font \"Helvetica,16\""],
        [gnuplot_dumb_term_command,"set term dumb 79 22"],
        [gnuplot_ps_term_command,
         "set size 1.5, 1.5\;set term postscript eps enhanced color solid 24"],
        [plot_realpart,false]]
(%i36) contour_plot(F,[u,-4,4],[v,-4,4])
(%o36) false
(%i37) set_plot_option([plot_format,openmath])
(%o37) [[x,-1.75555970201398E+305,1.75555970201398E+305],
        [y,-1.75555970201398E+305,1.75555970201398E+305],[t,-3,3],
        [grid,30,30],[transform_xy,false],[run_viewer,true],[axes,true],
        [plot_format,openmath],[gnuplot_term,default],
        [gnuplot_out_file,false],[nticks,29],[adapt_depth,5],
        [gnuplot_pm3d,false],[gnuplot_preamble,"set cntrparam levels 12"],
        [gnuplot_curve_titles,[default]],
        [gnuplot_curve_styles,
         ["with lines 3","with lines 1","with lines 2","with lines 5",
          "with lines 4","with lines 6","with lines 7"]],
        [gnuplot_default_term_command,"set term x11 font \"Helvetica,16\""],
        [gnuplot_dumb_term_command,"set term dumb 79 22"],
        [gnuplot_ps_term_command,
         "set size 1.5, 1.5\;set term postscript eps enhanced color solid 24"],
        [plot_realpart,false]]
(%i38) contour_plot(F,[u,-4,4],[v,-4,4],[plot_format,gnuplot])
(%o38) 
(%i39) scene1:gr2d(title = "Ellipse",nticks = 30,
                   parametric(2*cos(t),5*sin(t),t,0,2*%pi))
(%i40) scene2:gr2d(title = "Triangle",polygon([4,5,7],[6,4,2]))
(%i41) draw(scene1,scene2,columns = 2)
(%i42) draw(gr3d(explicit(y^2+x^2,x,-1,1,y,-1,1)))
(%o42) [gr3d(?explicit)]
(%i43) draw3d(explicit(y^2+x^2,x,-1,1,y,-1,1))
(%o43) [gr3d(?explicit)]
(%i44) ls_cmd:concat("ls -t ",maxima_tempdir,"/maxo* ",maxima_tempdir,
                     "/data*")
(%o44) "ls -t /tmp/maxo* /tmp/data*"
/tmp/data.gnuplotvE9quP
/tmp/maxout.gnuplotjFhQ1z
/tmp/data.gnuplotiVsPib
/tmp/maxout.gnuplotabRd2j
/tmp/data.gnuplot1h4bBW
/tmp/maxout.gnuplotvlnHWp
/tmp/maxout.gnuplotYZeUIq
/tmp/maxout.gnuplot_pipesu6pMGe
/tmp/maxout.gnuplot_pipesDbAKbn
/tmp/maxout.gnuplot_pipes2i2Pd5
/tmp/maxout.gnuplot_pipesKsNokW
/tmp/maxout.gnuplot_pipesc2X5c0
/tmp/maxout.gnuplot_pipesp7xb4I
/tmp/maxout.gnuplot_pipes7r8n5R
/tmp/maxout.gnuplot_pipes2mY8p3
/tmp/maxout.gnuplot_pipesTbUbSa
/tmp/maxout.gnuplot_pipesowevGB
/tmp/maxout.gnuplot_pipesTGHBbv
/tmp/maxout.gnuplot_pipesp7R81I
/tmp/maxout.gnuplot_pipesVL3aG7
/tmp/maxout.gnuplot_pipespD3hgk
/tmp/maxout.gnuplot_pipes0dpvMm
/tmp/maxout.gnuplot_pipesb5nKrS
/tmp/maxout.gnuplot_pipesCPKIkk
/tmp/maxout.gnuplot_pipesT49Ztb
/tmp/maxout.gnuplot_pipesBaKK6Y
/tmp/maxout.gnuplot_pipesOttFEh
/tmp/maxout.gnuplot_pipesUFICV7
/tmp/maxout.gnuplot_pipesOSulZj
/tmp/maxout.gnuplot_pipessuwAao
/tmp/maxout.gnuplot_pipescEJVcu
/tmp/maxout.gnuplot
/tmp/maxout.gnuplot_pipes
(%i45) system(ls_cmd)
(%o45) 0
(%i46) exit()

$ ls -t /tmp/maxo* /tmp/data* >> ~/lisp/mktemp-test.txt
ls: cannot access /tmp/data*: No such file or directory
/tmp/maxout.gnuplot
/tmp/maxout.gnuplot_pipes
-------------- next part --------------
3047,3048d3046
<     (setf $gnuplot_file_name_w_dir (plot-temp-file $gnuplot_file_name))
<     (setf $data_file_name_w_dir (plot-temp-file $data_file_name))
3050c3048
<           (open $gnuplot_file_name_w_dir
---
>           (open (plot-temp-file $gnuplot_file_name)
3053c3051
<           (open $data_file_name_w_dir
---
>           (open (plot-temp-file $data_file_name)
3055c3053
<     (setf datapath (format nil "'~a'" $data_file_name_w_dir))
---
>     (setf datapath (format nil "'~a'" (plot-temp-file $data_file_name)))
3208c3206
<                                   $gnuplot_file_name_w_dir) ))
---
>                                   (plot-temp-file $gnuplot_file_name)) ))
3229c3227
<                                                (format nil $gnuplot_view_args $gnuplot_file_name_w_dir))
---
>                                                (format nil $gnuplot_view_args (plot-temp-file $gnuplot_file_name)))
3232c3230
<                                                $gnuplot_file_name_w_dir))) )
---
>                                                (plot-temp-file $gnuplot_file_name)))) )
3239c3237
<                         (format nil "load '~a'" $gnuplot_file_name_w_dir))  ))))
---
>                         (format nil "load '~a'" (plot-temp-file $gnuplot_file_name)))  ))))