1 ;;; calc-graph.el --- graph output functions for Calc
3 ;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc.
5 ;; Author: David Gillespie <daveg@synaptics.com>
6 ;; Maintainers: D. Goel <deego@gnufans.org>
7 ;; Colin Walters <walters@debian.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY. No author or distributor
13 ;; accepts responsibility to anyone for the consequences of using it
14 ;; or for whether it serves any particular purpose or works at all,
15 ;; unless he says so in writing. Refer to the GNU Emacs General Public
16 ;; License for full details.
18 ;; Everyone is granted permission to copy, modify and redistribute
19 ;; GNU Emacs, but only under the conditions described in the
20 ;; GNU Emacs General Public License. A copy of this license is
21 ;; supposed to have been given to you along with GNU Emacs so you
22 ;; can know your rights and responsibilities. It should be in a
23 ;; file named COPYING. Among other things, the copyright notice
24 ;; and this notice must be preserved on all copies.
30 ;; This file is autoloaded from calc-ext.el.
35 (defun calc-Need-calc-graph () nil
)
40 ;;; Note that some of the following initial values also occur in calc.el.
41 (defvar calc-gnuplot-tempfile
"calc")
43 (defvar calc-gnuplot-default-device
"default")
44 (defvar calc-gnuplot-default-output
"STDOUT")
45 (defvar calc-gnuplot-print-device
"postscript")
46 (defvar calc-gnuplot-print-output
"auto")
47 (defvar calc-gnuplot-keep-outfile nil
)
48 (defvar calc-gnuplot-version nil
)
50 (defvar calc-gnuplot-display
(getenv "DISPLAY"))
51 (defvar calc-gnuplot-geometry nil
)
53 (defvar calc-graph-default-resolution
15)
54 (defvar calc-graph-default-resolution-3d
5)
55 (defvar calc-graph-default-precision
5)
57 (defvar calc-gnuplot-buffer nil
)
58 (defvar calc-gnuplot-input nil
)
60 (defvar calc-gnuplot-last-error-pos
1)
61 (defvar calc-graph-last-device nil
)
62 (defvar calc-graph-last-output nil
)
63 (defvar calc-graph-file-cache nil
)
64 (defvar calc-graph-var-cache nil
)
65 (defvar calc-graph-data-cache nil
)
66 (defvar calc-graph-data-cache-limit
10)
67 (defvar calc-graph-no-auto-view nil
)
68 (defvar calc-graph-no-wait nil
)
70 (defun calc-graph-fast (many)
72 (let ((calc-graph-no-auto-view t
))
75 (calc-graph-plot nil
)))
77 (defun calc-graph-fast-3d (many)
79 (let ((calc-graph-no-auto-view t
))
81 (calc-graph-add-3d many
)
82 (calc-graph-plot nil
)))
84 (defun calc-graph-delete (all)
89 (set-buffer calc-gnuplot-input
)
90 (and (calc-graph-find-plot t all
)
92 (if (looking-at "s?plot")
94 (setq calc-graph-var-cache nil
)
95 (delete-region (point) (point-max)))
96 (delete-region (point) (1- (point-max)))))))
97 (calc-graph-view-commands)))
99 (defun calc-graph-find-plot (&optional before all
)
100 (goto-char (point-min))
101 (and (re-search-forward "^s?plot[ \t]+" nil t
)
103 (goto-char (point-max))
105 (not (search-backward "," nil t
))
110 (beginning-of-line)))
112 (re-search-forward ",[ \t]+")))
115 (defun calc-graph-add (many)
120 (calc-graph-add-curve (calc-graph-lookup (calc-top-n 2))
121 (calc-graph-lookup (calc-top-n 1))))
122 ((or (consp many
) (eq many
0))
123 (let ((xdata (calc-graph-lookup (calc-top-n 2)))
124 (ylist (calc-top-n 1)))
125 (or (eq (car-safe ylist
) 'vec
)
126 (error "Y argument must be a vector"))
127 (while (setq ylist
(cdr ylist
))
128 (calc-graph-add-curve xdata
(calc-graph-lookup (car ylist
))))))
129 ((> (setq many
(prefix-numeric-value many
)) 0)
130 (let ((xdata (calc-graph-lookup (calc-top-n (1+ many
)))))
132 (calc-graph-add-curve xdata
133 (calc-graph-lookup (calc-top-n many
)))
134 (setq many
(1- many
)))))
139 (setq pair
(calc-top-n many
))
140 (or (and (eq (car-safe pair
) 'vec
)
142 (error "Argument must be an [x,y] vector"))
143 (calc-graph-add-curve (calc-graph-lookup (nth 1 pair
))
144 (calc-graph-lookup (nth 2 pair
)))
145 (setq many
(1- many
))))))
146 (calc-graph-view-commands)))
148 (defun calc-graph-add-3d (many)
153 (calc-graph-add-curve (calc-graph-lookup (calc-top-n 3))
154 (calc-graph-lookup (calc-top-n 2))
155 (calc-graph-lookup (calc-top-n 1))))
156 ((or (consp many
) (eq many
0))
157 (let ((xdata (calc-graph-lookup (calc-top-n 3)))
158 (ydata (calc-graph-lookup (calc-top-n 2)))
159 (zlist (calc-top-n 1)))
160 (or (eq (car-safe zlist
) 'vec
)
161 (error "Z argument must be a vector"))
162 (while (setq zlist
(cdr zlist
))
163 (calc-graph-add-curve xdata ydata
164 (calc-graph-lookup (car zlist
))))))
165 ((> (setq many
(prefix-numeric-value many
)) 0)
166 (let ((xdata (calc-graph-lookup (calc-top-n (+ many
2))))
167 (ydata (calc-graph-lookup (calc-top-n (+ many
1)))))
169 (calc-graph-add-curve xdata ydata
170 (calc-graph-lookup (calc-top-n many
)))
171 (setq many
(1- many
)))))
176 (setq curve
(calc-top-n many
))
177 (or (and (eq (car-safe curve
) 'vec
)
178 (= (length curve
) 4))
179 (error "Argument must be an [x,y,z] vector"))
180 (calc-graph-add-curve (calc-graph-lookup (nth 1 curve
))
181 (calc-graph-lookup (nth 2 curve
))
182 (calc-graph-lookup (nth 3 curve
)))
183 (setq many
(1- many
))))))
184 (calc-graph-view-commands)))
186 (defun calc-graph-add-curve (xdata ydata
&optional zdata
)
187 (let ((num (calc-graph-count-curves))
188 (pstyle (calc-var-value 'var-PointStyles
))
189 (lstyle (calc-var-value 'var-LineStyles
)))
191 (set-buffer calc-gnuplot-input
)
192 (goto-char (point-min))
193 (if (re-search-forward (if zdata
"^plot[ \t]" "^splot[ \t]")
195 (error "Can't mix 2d and 3d curves on one graph"))
196 (if (re-search-forward "^s?plot[ \t]" nil t
)
200 (goto-char (point-max))
201 (or (eq (preceding-char) ?
\n)
203 (insert (if zdata
"splot" "plot") " \n")
205 (insert "{" (symbol-name (nth 1 xdata
))
206 ":" (symbol-name (nth 1 ydata
)))
208 (insert ":" (symbol-name (nth 1 zdata
))))
210 "title \"" (symbol-name (nth 1 ydata
)) "\" "
212 (setq pstyle
(and (eq (car-safe pstyle
) 'vec
) (nth (1+ num
) pstyle
)))
213 (setq lstyle
(and (eq (car-safe lstyle
) 'vec
) (nth (1+ num
) lstyle
))))
214 (calc-graph-set-styles
215 (or (and (Math-num-integerp lstyle
) (math-trunc lstyle
))
217 (or (and (Math-num-integerp pstyle
) (math-trunc pstyle
))
218 (if (eq (car-safe (calc-var-value (nth 2 ydata
))) 'vec
)
221 (defun calc-graph-lookup (thing)
222 (if (and (eq (car-safe thing
) 'var
)
223 (calc-var-value (nth 2 thing
)))
225 (let ((found (assoc thing calc-graph-var-cache
)))
228 (setq varname
(concat "PlotData"
230 (1+ (length calc-graph-var-cache
))))
231 var
(list 'var
(intern varname
)
232 (intern (concat "var-" varname
)))
233 found
(cons thing var
)
234 calc-graph-var-cache
(cons found calc-graph-var-cache
))
235 (set (nth 2 var
) thing
)))
238 (defun calc-graph-juggle (arg)
242 (set-buffer calc-gnuplot-input
)
244 (let ((num (calc-graph-count-curves)))
247 (setq arg
(+ arg num
))))))
248 (while (>= (setq arg
(1- arg
)) 0)
249 (calc-graph-do-juggle))))
251 (defun calc-graph-count-curves ()
253 (set-buffer calc-gnuplot-input
)
254 (if (re-search-forward "^s?plot[ \t]" nil t
)
256 (goto-char (point-min))
257 (while (search-forward "," nil t
)
262 (defun calc-graph-do-juggle ()
264 (and (calc-graph-find-plot t t
)
267 (calc-graph-find-plot t nil
)
268 (or (eq base
(point))
269 (let ((str (buffer-substring (+ (point) 2) (1- (point-max)))))
270 (delete-region (point) (1- (point-max)))
271 (goto-char (+ base
5))
272 (insert str
", ")))))))
274 (defun calc-graph-print (flag)
276 (calc-graph-plot flag t
))
278 (defun calc-graph-plot (flag &optional printing
)
281 (let ((calcbuf (current-buffer))
282 (tempbuf (get-buffer-create "*Gnuplot Temp-2*"))
286 (refine (and flag
(> (prefix-numeric-value flag
) 0)))
287 (recompute (and flag
(< (prefix-numeric-value flag
) 0)))
290 cache-env is-splot device output resolution precision samples-pos
)
291 (or (boundp 'calc-graph-prev-kill-hook
)
292 (setq calc-graph-prev-kill-hook nil
)
293 (add-hook 'kill-emacs-hook
'calc-graph-kill-hook
))
298 (set-buffer calc-gnuplot-input
)
299 (goto-char (point-min))
300 (setq is-splot
(re-search-forward "^splot[ \t]" nil t
))
301 (let ((str (buffer-string))
302 (ver calc-gnuplot-version
))
303 (set-buffer (get-buffer-create "*Gnuplot Temp*"))
305 (insert "# (Note: This is a temporary copy---do not edit!)\n")
307 (insert "set noarrow\nset nolabel\n"
308 "set autoscale xy\nset nologscale xy\n"
309 "set xlabel\nset ylabel\nset title\n"
310 "set noclip points\nset clip one\nset clip two\n"
311 "set format \"%g\"\nset tics\nset xtics\nset ytics\n"
312 "set data style linespoints\n"
313 "set nogrid\nset nokey\nset nopolar\n"))
315 (insert "set surface\nset nocontour\n"
316 "set " (if is-splot
"" "no") "parametric\n"
317 "set notime\nset border\nset ztics\nset zeroaxis\n"
318 "set view 60,30,1,1\nset offsets 0,0,0,0\n"))
319 (setq samples-pos
(point))
321 (goto-char (point-min))
324 (error "This option works only for 2d plots")
326 (let ((calc-gnuplot-input (current-buffer))
327 (calc-graph-no-auto-view t
))
329 (setq device calc-gnuplot-print-device
330 output calc-gnuplot-print-output
)
331 (setq device
(calc-graph-find-command "terminal")
332 output
(calc-graph-find-command "output"))
334 (setq device calc-gnuplot-default-device
))
336 (setq output
(car (read-from-string output
)))
337 (setq output calc-gnuplot-default-output
)))
338 (if (or (equal device
"") (equal device
"default"))
339 (setq device
(if printing
341 (if (or (eq window-system
'x
) (getenv "DISPLAY"))
343 (if (>= calc-gnuplot-version
3)
344 "dumb" "postscript")))))
345 (if (equal device
"dumb")
346 (setq device
(format "dumb %d %d"
347 (1- (frame-width)) (1- (frame-height)))))
348 (if (equal device
"big")
349 (setq device
(format "dumb %d %d"
350 (* 4 (- (frame-width) 3))
351 (* 4 (- (frame-height) 3)))))
353 (if (or (equal output
"auto")
354 (and (equal output
"tty") (setq tty-output t
)))
355 (setq tempoutfile
(calc-temp-file-name -
1)
357 (setq output
(eval output
)))
358 (or (equal device calc-graph-last-device
)
360 (setq calc-graph-last-device device
)
361 (calc-gnuplot-command "set terminal" device
)))
362 (or (equal output calc-graph-last-output
)
364 (setq calc-graph-last-output output
)
365 (calc-gnuplot-command "set output"
366 (if (equal output
"STDOUT")
368 (prin1-to-string output
)))))
369 (setq resolution
(calc-graph-find-command "samples"))
371 (setq resolution
(string-to-int resolution
))
372 (setq resolution
(if is-splot
373 calc-graph-default-resolution-3d
374 calc-graph-default-resolution
)))
375 (setq precision
(calc-graph-find-command "precision"))
377 (setq precision
(string-to-int precision
))
378 (setq precision calc-graph-default-precision
))
379 (calc-graph-set-command "terminal")
380 (calc-graph-set-command "output")
381 (calc-graph-set-command "samples")
382 (calc-graph-set-command "precision"))
383 (goto-char samples-pos
)
384 (insert "set samples " (int-to-string (max (if is-splot
20 200)
385 (+ 5 resolution
))) "\n")
386 (while (re-search-forward "{\\*[^}]+}[^,\n]*" nil t
)
387 (delete-region (match-beginning 0) (match-end 0))
390 (while (memq (preceding-char) '(?\s ?
\t))
392 (if (eq (preceding-char) ?\
,)
393 (delete-backward-char 1))))
396 (setq cache-env
(list calc-angle-mode
402 (if (and (not recompute
)
403 (equal (cdr (car calc-graph-data-cache
)) cache-env
))
404 (while (> (length calc-graph-data-cache
)
405 calc-graph-data-cache-limit
)
406 (setcdr calc-graph-data-cache
407 (cdr (cdr calc-graph-data-cache
))))
408 (setq calc-graph-data-cache
(list (cons nil cache-env
)))))
409 (calc-graph-find-plot t t
)
410 (while (re-search-forward
412 "{\\([^{}:\n]+\\):\\([^{}:\n]+\\):\\([^{}:\n]+\\)}"
413 "{\\([^{}:\n]+\\)\\(:\\)\\([^{}:\n]+\\)}")
415 (setq curve-num
(1+ curve-num
))
416 (let* ((xname (buffer-substring (match-beginning 1) (match-end 1)))
417 (xvar (intern (concat "var-" xname
)))
418 (xvalue (math-evaluate-expr (calc-var-value xvar
)))
419 (y3name (and is-splot
420 (buffer-substring (match-beginning 2)
422 (y3var (and is-splot
(intern (concat "var-" y3name
))))
423 (y3value (and is-splot
(calc-var-value y3var
)))
424 (yname (buffer-substring (match-beginning 3) (match-end 3)))
425 (yvar (intern (concat "var-" yname
)))
426 (yvalue (calc-var-value yvar
))
428 (delete-region (match-beginning 0) (match-end 0))
429 (setq filename
(calc-temp-file-name curve-num
))
436 (xlow nil
) (xhigh nil
) (y3low nil
) (y3high nil
)
437 xvec xval xstep var-DUMMY
438 y3vec y3val y3step var-DUMMY2
(zval nil
)
439 yvec yval ycache ycacheptr yvector
441 (keep-file (and (not is-splot
) (file-exists-p filename
)))
443 (calc-symbolic-mode nil
)
444 (calc-prefer-frac nil
)
445 (calc-internal-prec (max 3 precision
))
446 (calc-simplify-mode (and (not (memq calc-simplify-mode
451 (math-working-step 0)
452 (math-working-step-2 nil
))
455 (calc-graph-compute-3d)
456 (calc-graph-compute-2d))
458 (goto-char (point-max))
462 (insert ":" yname
"\n\n")
463 (setq tempbuftop
(point))
464 (let ((calc-group-digits nil
)
465 (calc-leading-zeros nil
)
466 (calc-number-radix 10)
467 (entry (and (not is-splot
)
468 (list xp yp xhigh numsteps
))))
470 (nth 1 (nth (1+ curve-num
)
471 calc-graph-file-cache
)))
472 (setq keep-file nil
))
473 (setcar (cdr (nth (1+ curve-num
) calc-graph-file-cache
))
476 (calc-graph-format-data)))
480 (error "No valid data points for %s:%s"
482 (write-region tempbuftop
(point-max) filename
484 (insert (prin1-to-string filename
))))
486 (setcdr cache-env nil
))
489 (calc-gnuplot-command "clear")
490 (calc-clear-command-flag 'clear-message
)
491 (message "No data to plot!"))
492 (setq calc-graph-data-cache-limit
(max curve-num
493 calc-graph-data-cache-limit
)
494 filename
(calc-temp-file-name 0))
495 (write-region (point-min) (point-max) filename nil
'quiet
)
496 (calc-gnuplot-command "load" (prin1-to-string filename
))
497 (or (equal output
"STDOUT")
498 calc-gnuplot-keep-outfile
499 (progn ; need to close the output file before printing/plotting
500 (setq calc-graph-last-output
"STDOUT")
501 (calc-gnuplot-command "set output")))
502 (let ((command (if printing
503 calc-gnuplot-print-command
504 (or calc-gnuplot-plot-command
505 (and (string-match "^dumb" device
)
506 'calc-graph-show-dumb
)
508 'calc-graph-show-tty
)))))
510 (if (stringp command
)
511 (calc-gnuplot-command
514 calc-gnuplot-print-output
)))
515 (if (symbolp command
)
516 (funcall command output
)
517 (eval command
))))))))))
519 (defun calc-graph-compute-2d ()
520 (if (setq yvec
(eq (car-safe yvalue
) 'vec
))
521 (if (= (setq numsteps
(1- (length yvalue
))) 0)
522 (error "Can't plot an empty vector")
523 (if (setq xvec
(eq (car-safe xvalue
) 'vec
))
524 (or (= (1- (length xvalue
)) numsteps
)
525 (error "%s and %s have different lengths" xname yname
))
526 (if (and (eq (car-safe xvalue
) 'intv
)
527 (math-constp xvalue
))
528 (setq xstep
(math-div (math-sub (nth 3 xvalue
)
531 xvalue
(nth 2 xvalue
))
532 (if (math-realp xvalue
)
534 (error "%s is not a suitable basis for %s" xname yname
)))))
535 (or (math-realp yvalue
)
537 (setq yvalue
(math-evaluate-expr yvalue
))
538 (calc-default-formula-arglist yvalue
)
540 (error "%s does not contain any unassigned variables" yname
))
542 (error "%s contains more than one variable: %s"
544 (setq yvalue
(math-expr-subst yvalue
545 (math-build-var-name (car arglist
))
546 '(var DUMMY var-DUMMY
)))))
547 (setq ycache
(assoc yvalue calc-graph-data-cache
))
548 (delq ycache calc-graph-data-cache
)
549 (nconc calc-graph-data-cache
550 (list (or ycache
(setq ycache
(list yvalue
)))))
551 (if (and (not (setq xvec
(eq (car-safe xvalue
) 'vec
)))
552 refine
(cdr (cdr ycache
)))
553 (calc-graph-refine-2d)
554 (calc-graph-recompute-2d))))
556 (defun calc-graph-refine-2d ()
558 ycacheptr
(cdr ycache
))
559 (if (and (setq xval
(calc-graph-find-command "xrange"))
560 (string-match "\\`\\[\\([0-9.eE+-]*\\):\\([0-9.eE+-]*\\)\\]\\'"
562 (let ((b2 (match-beginning 2))
564 (setq xlow
(math-read-number (substring xval
567 xhigh
(math-read-number (substring xval b2 e2
))))
569 (while (and (cdr ycacheptr
)
570 (Math-lessp (car (nth 1 ycacheptr
)) xlow
))
571 (setq ycacheptr
(cdr ycacheptr
)))))
572 (setq math-working-step-2
(1- (length ycacheptr
)))
573 (while (and (cdr ycacheptr
)
575 (Math-lessp (car (car ycacheptr
)) xhigh
)))
576 (setq var-DUMMY
(math-div (math-add (car (car ycacheptr
))
577 (car (nth 1 ycacheptr
)))
579 math-working-step
(1+ math-working-step
)
580 yval
(math-evaluate-expr yvalue
))
581 (setcdr ycacheptr
(cons (cons var-DUMMY yval
)
583 (setq ycacheptr
(cdr (cdr ycacheptr
))))
587 (defun calc-graph-recompute-2d ()
588 (setq ycacheptr ycache
)
590 (setq numsteps
(1- (length xvalue
))
592 (if (and (eq (car-safe xvalue
) 'intv
)
593 (math-constp xvalue
))
594 (setq numsteps resolution
598 xstep
(math-div (math-sub xhigh xlow
)
600 xvalue
(nth 2 xvalue
))
601 (error "%s is not a suitable basis for %s"
603 (setq math-working-step-2 numsteps
)
604 (while (>= (setq numsteps
(1- numsteps
)) 0)
605 (setq math-working-step
(1+ math-working-step
))
610 (and (not (eq ycacheptr ycache
))
611 (consp (car ycacheptr
))
612 (not (Math-lessp (car (car ycacheptr
)) xval
))
613 (setq ycacheptr ycache
)))
615 (setq xval xhigh
) ; avoid cumulative roundoff
617 xvalue
(math-add xvalue xstep
))))
618 (while (and (cdr ycacheptr
)
619 (Math-lessp (car (nth 1 ycacheptr
)) xval
))
620 (setq ycacheptr
(cdr ycacheptr
)))
621 (or (and (cdr ycacheptr
)
622 (Math-equal (car (nth 1 ycacheptr
)) xval
))
626 (setcdr ycacheptr
(cons (cons xval
(math-evaluate-expr yvalue
))
628 (setq ycacheptr
(cdr ycacheptr
))
630 (setq yvector
(cons (cdr (car ycacheptr
)) yvector
))
631 (or yp
(setq yp ycacheptr
))))
635 yp
(cons 'vec
(nreverse yvector
))
636 numsteps
(1- (length xp
)))
637 (setq numsteps
1000000)))
639 (defun calc-graph-compute-3d ()
640 (if (setq yvec
(eq (car-safe yvalue
) 'vec
))
641 (if (math-matrixp yvalue
)
643 (setq numsteps
(1- (length yvalue
))
644 numsteps3
(1- (length (nth 1 yvalue
))))
645 (if (eq (car-safe xvalue
) 'vec
)
646 (or (= (1- (length xvalue
)) numsteps
)
647 (error "%s has wrong length" xname
))
648 (if (and (eq (car-safe xvalue
) 'intv
)
649 (math-constp xvalue
))
650 (setq xvalue
(calcFunc-index numsteps
653 (math-sub (nth 3 xvalue
)
656 (if (math-realp xvalue
)
657 (setq xvalue
(calcFunc-index numsteps xvalue
1))
658 (error "%s is not a suitable basis for %s" xname yname
))))
659 (if (eq (car-safe y3value
) 'vec
)
660 (or (= (1- (length y3value
)) numsteps3
)
661 (error "%s has wrong length" y3name
))
662 (if (and (eq (car-safe y3value
) 'intv
)
663 (math-constp y3value
))
664 (setq y3value
(calcFunc-index numsteps3
667 (math-sub (nth 3 y3value
)
670 (if (math-realp y3value
)
671 (setq y3value
(calcFunc-index numsteps3 y3value
1))
672 (error "%s is not a suitable basis for %s" y3name yname
))))
677 (while (setq xvalue
(cdr xvalue
) yvalue
(cdr yvalue
))
678 (setq xp
(nconc xp
(make-list (1+ numsteps3
) (car xvalue
)))
679 yp
(nconc yp
(cons 0 (copy-sequence (cdr y3value
))))
680 zp
(nconc zp
(cons '(skip)
681 (copy-sequence (cdr (car yvalue
)))))))
682 (setq numsteps
(1- (* numsteps
(1+ numsteps3
)))))
683 (if (= (setq numsteps
(1- (length yvalue
))) 0)
684 (error "Can't plot an empty vector"))
685 (or (and (eq (car-safe xvalue
) 'vec
)
686 (= (1- (length xvalue
)) numsteps
))
687 (error "%s is not a suitable basis for %s" xname yname
))
688 (or (and (eq (car-safe y3value
) 'vec
)
689 (= (1- (length y3value
)) numsteps
))
690 (error "%s is not a suitable basis for %s" y3name yname
))
695 (or (math-realp yvalue
)
697 (setq yvalue
(math-evaluate-expr yvalue
))
698 (calc-default-formula-arglist yvalue
)
699 (setq arglist
(sort arglist
'string-lessp
))
701 (error "%s does not contain enough unassigned variables" yname
))
702 (and (cdr (cdr arglist
))
703 (error "%s contains too many variables: %s" yname arglist
))
704 (setq yvalue
(math-multi-subst yvalue
705 (mapcar 'math-build-var-name
707 '((var DUMMY var-DUMMY
)
708 (var DUMMY2 var-DUMMY2
))))))
709 (if (setq xvec
(eq (car-safe xvalue
) 'vec
))
710 (setq numsteps
(1- (length xvalue
)))
711 (if (and (eq (car-safe xvalue
) 'intv
)
712 (math-constp xvalue
))
713 (setq numsteps resolution
714 xvalue
(calcFunc-index numsteps
716 (math-div (math-sub (nth 3 xvalue
)
719 (error "%s is not a suitable basis for %s"
721 (if (setq y3vec
(eq (car-safe y3value
) 'vec
))
722 (setq numsteps3
(1- (length y3value
)))
723 (if (and (eq (car-safe y3value
) 'intv
)
724 (math-constp y3value
))
725 (setq numsteps3 resolution
726 y3value
(calcFunc-index numsteps3
728 (math-div (math-sub (nth 3 y3value
)
731 (error "%s is not a suitable basis for %s"
737 (setq math-working-step
0)
738 (while (setq xvalue
(cdr xvalue
))
739 (setq xp
(nconc xp
(make-list (1+ numsteps3
) (car xvalue
)))
740 yp
(nconc yp
(cons 0 (copy-sequence (cdr y3value
))))
743 var-DUMMY
(car xvalue
)
744 math-working-step-2
0
745 math-working-step
(1+ math-working-step
))
746 (while (setq y3step
(cdr y3step
))
747 (setq math-working-step-2
(1+ math-working-step-2
)
748 var-DUMMY2
(car y3step
)
749 zp
(cons (math-evaluate-expr yvalue
) zp
))))
750 (setq zp
(nreverse zp
)
751 numsteps
(1- (* numsteps
(1+ numsteps3
))))))
753 (defun calc-graph-format-data ()
754 (while (<= (setq stepcount
(1+ stepcount
)) numsteps
)
764 xvalue
(math-add xvalue xstep
)
767 (setq xval
(car (car yp
))
771 (and xhigh
(equal xval xhigh
)))
774 (if (and (eq (car-safe zval
) 'calcFunc-xyz
)
776 (setq xval
(nth 1 zval
)
779 (if (and (eq (car-safe yval
) 'calcFunc-xyz
)
784 (set-buffer (get-buffer-create "*Gnuplot Temp*"))
786 (goto-char (point-max))
787 (re-search-backward "^plot[ \t]")
788 (insert "set parametric\ns")
789 (setq surprise-splot t
))))
790 (setq xval
(nth 1 yval
)
793 (if (and (eq (car-safe yval
) 'calcFunc-xy
)
795 (setq xval
(nth 1 yval
)
796 yval
(nth 2 yval
)))))
797 (if (and (Math-realp xval
)
799 (or (not zval
) (Math-realp zval
)))
803 (if (Math-integerp xval
)
804 (insert (math-format-number xval
))
805 (if (eq (car xval
) 'frac
)
806 (setq xval
(math-float xval
)))
807 (insert (math-format-number (nth 1 xval
))
808 "e" (int-to-string (nth 2 xval
))))
810 (if (Math-integerp yval
)
811 (insert (math-format-number yval
))
812 (if (eq (car yval
) 'frac
)
813 (setq yval
(math-float yval
)))
814 (insert (math-format-number (nth 1 yval
))
815 "e" (int-to-string (nth 2 yval
))))
819 (if (Math-integerp zval
)
820 (insert (math-format-number zval
))
821 (if (eq (car zval
) 'frac
)
822 (setq zval
(math-float zval
)))
823 (insert (math-format-number (nth 1 zval
))
824 "e" (int-to-string (nth 2 zval
))))))
826 (and (not (equal zval
'(skip)))
827 (boundp 'var-PlotRejects
)
828 (eq (car-safe var-PlotRejects
) 'vec
)
829 (nconc var-PlotRejects
834 (calc-refresh-evaltos 'var-PlotRejects
))
840 (defun calc-temp-file-name (num)
841 (while (<= (length calc-graph-file-cache
) (1+ num
))
842 (setq calc-graph-file-cache
(nconc calc-graph-file-cache
(list nil
))))
843 (car (or (nth (1+ num
) calc-graph-file-cache
)
844 (setcar (nthcdr (1+ num
) calc-graph-file-cache
)
845 (list (make-temp-file
846 (concat calc-gnuplot-tempfile
848 (char-to-string (- ?A num
))
849 (int-to-string num
))))
852 (defun calc-graph-delete-temps ()
853 (while calc-graph-file-cache
854 (and (car calc-graph-file-cache
)
855 (file-exists-p (car (car calc-graph-file-cache
)))
857 (delete-file (car (car calc-graph-file-cache
)))
859 (setq calc-graph-file-cache
(cdr calc-graph-file-cache
))))
861 (defun calc-graph-kill-hook ()
862 (calc-graph-delete-temps)
863 (if calc-graph-prev-kill-hook
864 (funcall calc-graph-prev-kill-hook
)))
866 (defun calc-graph-show-tty (output)
867 "Default calc-gnuplot-plot-command for \"tty\" output mode.
868 This is useful for tek40xx and other graphics-terminal types."
869 (call-process-region 1 1 shell-file-name
870 nil calc-gnuplot-buffer nil
871 "-c" (format "cat %s >/dev/tty; rm %s" output output
)))
873 (defun calc-graph-show-dumb (&optional output
)
874 "Default calc-gnuplot-plot-command for Pinard's \"dumb\" terminal type.
875 This \"dumb\" driver will be present in Gnuplot 3.0."
877 (save-window-excursion
878 (switch-to-buffer calc-gnuplot-buffer
)
879 (delete-other-windows)
880 (goto-char calc-gnuplot-trail-mark
)
881 (or (search-forward "\f" nil t
)
883 (goto-char (point-max))
884 (re-search-backward "\f\\|^[ \t]+\\^$\\|G N U P L O T")
885 (setq found-pt
(point))
886 (if (looking-at "\f")
889 (if (eolp) (forward-line 1))
890 (or (calc-graph-find-command "time")
891 (calc-graph-find-command "title")
892 (calc-graph-find-command "ylabel")
894 (insert-before-markers (format "(%s)" (current-time-string)))
896 (set-window-start (selected-window) (point))
897 (goto-char (point-max)))
901 (or (boundp 'calc-dumb-map
)
903 (setq calc-dumb-map
(make-sparse-keymap))
904 (define-key calc-dumb-map
"\n" 'scroll-up
)
905 (define-key calc-dumb-map
" " 'scroll-up
)
906 (define-key calc-dumb-map
"\177" 'scroll-down
)
907 (define-key calc-dumb-map
"<" 'scroll-left
)
908 (define-key calc-dumb-map
">" 'scroll-right
)
909 (define-key calc-dumb-map
"{" 'scroll-down
)
910 (define-key calc-dumb-map
"}" 'scroll-up
)
911 (define-key calc-dumb-map
"q" 'exit-recursive-edit
)
912 (define-key calc-dumb-map
"\C-c\C-c" 'exit-recursive-edit
)))
913 (use-local-map calc-dumb-map
)
914 (setq truncate-lines t
)
915 (message "Type `q'%s to return to Calc"
916 (if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch
)
919 (bury-buffer "*Gnuplot Trail*")))
921 (defun calc-graph-clear ()
923 (if calc-graph-last-device
924 (if (or (equal calc-graph-last-device
"x11")
925 (equal calc-graph-last-device
"X11"))
926 (calc-gnuplot-command "set output"
927 (if (equal calc-graph-last-output
"STDOUT")
929 (prin1-to-string calc-graph-last-output
)))
930 (calc-gnuplot-command "clear"))))
932 (defun calc-graph-title-x (title)
933 (interactive "sX axis title: ")
934 (calc-graph-set-command "xlabel" (if (not (equal title
""))
935 (prin1-to-string title
))))
937 (defun calc-graph-title-y (title)
938 (interactive "sY axis title: ")
939 (calc-graph-set-command "ylabel" (if (not (equal title
""))
940 (prin1-to-string title
))))
942 (defun calc-graph-title-z (title)
943 (interactive "sZ axis title: ")
944 (calc-graph-set-command "zlabel" (if (not (equal title
""))
945 (prin1-to-string title
))))
947 (defun calc-graph-range-x (range)
948 (interactive "sX axis range: ")
949 (calc-graph-set-range "xrange" range
))
951 (defun calc-graph-range-y (range)
952 (interactive "sY axis range: ")
953 (calc-graph-set-range "yrange" range
))
955 (defun calc-graph-range-z (range)
956 (interactive "sZ axis range: ")
957 (calc-graph-set-range "zrange" range
))
959 (defun calc-graph-set-range (cmd range
)
960 (if (equal range
"$")
962 (let ((val (calc-top-n 1)))
963 (if (and (eq (car-safe val
) 'intv
) (math-constp val
))
965 (math-format-number (math-float (nth 2 val
))) ":"
966 (math-format-number (math-float (nth 3 val
)))))
967 (if (and (eq (car-safe val
) 'vec
)
970 (math-format-number (math-float (nth 1 val
))) ":"
971 (math-format-number (math-float (nth 2 val
)))))
972 (error "Range specification must be an interval or 2-vector")))
973 (calc-pop-stack 1))))
974 (if (string-match "\\[.+\\]" range
)
975 (setq range
(substring range
1 -
1)))
976 (if (and (not (string-match ":" range
))
977 (or (string-match "," range
)
978 (string-match " " range
)))
979 (aset range
(match-beginning 0) ?\
:))
980 (calc-graph-set-command cmd
(if (not (equal range
""))
981 (concat "[" range
"]"))))
983 (defun calc-graph-log-x (flag)
985 (calc-graph-set-log flag
0 0))
987 (defun calc-graph-log-y (flag)
989 (calc-graph-set-log 0 flag
0))
991 (defun calc-graph-log-z (flag)
993 (calc-graph-set-log 0 0 flag
))
995 (defun calc-graph-set-log (xflag yflag zflag
)
996 (let* ((old (or (calc-graph-find-command "logscale") ""))
997 (xold (string-match "x" old
))
998 (yold (string-match "y" old
))
999 (zold (string-match "z" old
))
1001 (setq str
(concat (if (if xflag
1002 (if (eq xflag
0) xold
1003 (> (prefix-numeric-value xflag
) 0))
1006 (if (eq yflag
0) yold
1007 (> (prefix-numeric-value yflag
) 0))
1010 (if (eq zflag
0) zold
1011 (> (prefix-numeric-value zflag
) 0))
1012 (not zold
)) "z" "")))
1013 (calc-graph-set-command "logscale" (if (not (equal str
"")) str
))))
1015 (defun calc-graph-line-style (style)
1017 (calc-graph-set-styles (and style
(prefix-numeric-value style
)) t
))
1019 (defun calc-graph-point-style (style)
1021 (calc-graph-set-styles t
(and style
(prefix-numeric-value style
))))
1023 (defun calc-graph-set-styles (lines points
)
1026 (set-buffer calc-gnuplot-input
)
1027 (or (calc-graph-find-plot nil nil
)
1028 (error "No data points have been set!"))
1029 (let ((base (point))
1030 (mode nil
) (lstyle nil
) (pstyle nil
)
1031 start end lenbl penbl
)
1032 (re-search-forward "[,\n]")
1034 (setq end
(point) start end
)
1036 (if (looking-at "[^,\n]*[^,\n \t]\\([ \t]+with\\)")
1038 (setq start
(match-beginning 1))
1039 (goto-char (match-end 0))
1040 (if (looking-at "[ \t]+\\([a-z]+\\)")
1041 (setq mode
(buffer-substring (match-beginning 1)
1043 (if (looking-at "[ \ta-z]+\\([0-9]+\\)")
1044 (setq lstyle
(string-to-int
1045 (buffer-substring (match-beginning 1)
1047 (if (looking-at "[ \ta-z]+[0-9]+[ \t]+\\([0-9]+\\)")
1048 (setq pstyle
(string-to-int
1049 (buffer-substring (match-beginning 1)
1051 (setq lenbl
(or (equal mode
"lines") (equal mode
"linespoints"))
1052 penbl
(or (equal mode
"points") (equal mode
"linespoints")))
1056 lenbl
(>= lines
0)))
1057 (setq lenbl
(not lenbl
)))
1061 penbl
(>= points
0)))
1062 (setq penbl
(not penbl
)))
1063 (delete-region start end
)
1067 (if penbl
"linespoints" "lines")
1068 (if penbl
"points" "dots")))
1069 (if (and pstyle
(> pstyle
0))
1070 (insert " " (if (and lstyle
(> lstyle
0)) (int-to-string lstyle
) "1")
1071 " " (int-to-string pstyle
))
1072 (if (and lstyle
(> lstyle
0))
1073 (insert " " (int-to-string lstyle
))))))
1074 (calc-graph-view-commands))
1076 (defun calc-graph-zero-x (flag)
1078 (calc-graph-set-command "noxzeroaxis"
1080 (<= (prefix-numeric-value flag
) 0)
1081 (not (calc-graph-find-command "noxzeroaxis")))
1084 (defun calc-graph-zero-y (flag)
1086 (calc-graph-set-command "noyzeroaxis"
1088 (<= (prefix-numeric-value flag
) 0)
1089 (not (calc-graph-find-command "noyzeroaxis")))
1092 (defun calc-graph-name (name)
1093 (interactive "sTitle for current curve: ")
1096 (set-buffer calc-gnuplot-input
)
1097 (or (calc-graph-find-plot nil nil
)
1098 (error "No data points have been set!"))
1099 (let ((base (point))
1101 (re-search-forward "[,\n]\\|[ \t]+with")
1102 (setq end
(match-beginning 0))
1104 (if (looking-at "[^,\n]*[^,\n \t]\\([ \t]+title\\)")
1106 (goto-char (match-beginning 1))
1107 (delete-region (point) end
))
1109 (insert " title " (prin1-to-string name
))))
1110 (calc-graph-view-commands))
1112 (defun calc-graph-hide (flag)
1115 (and (calc-graph-find-plot nil nil
)
1117 (or (looking-at "{")
1118 (error "Can't hide this curve (wrong format)"))
1120 (if (looking-at "*")
1121 (if (or (null flag
) (<= (prefix-numeric-value flag
) 0))
1123 (if (or (null flag
) (> (prefix-numeric-value flag
) 0))
1126 (defun calc-graph-header (title)
1127 (interactive "sTitle for entire graph: ")
1128 (calc-graph-set-command "title" (if (not (equal title
""))
1129 (prin1-to-string title
))))
1131 (defun calc-graph-border (flag)
1133 (calc-graph-set-command "noborder"
1135 (<= (prefix-numeric-value flag
) 0)
1136 (not (calc-graph-find-command "noborder")))
1139 (defun calc-graph-grid (flag)
1141 (calc-graph-set-command "grid" (and (if flag
1142 (> (prefix-numeric-value flag
) 0)
1143 (not (calc-graph-find-command "grid")))
1146 (defun calc-graph-key (flag)
1148 (calc-graph-set-command "key" (and (if flag
1149 (> (prefix-numeric-value flag
) 0)
1150 (not (calc-graph-find-command "key")))
1153 (defun calc-graph-num-points (res flag
)
1154 (interactive "sNumber of data points: \nP")
1156 (if (> (prefix-numeric-value flag
) 0)
1158 (message "Default resolution is %d"
1159 calc-graph-default-resolution
)
1160 (setq calc-graph-default-resolution
(string-to-int res
)))
1162 (message "Default 3D resolution is %d"
1163 calc-graph-default-resolution-3d
)
1164 (setq calc-graph-default-resolution-3d
(string-to-int res
))))
1165 (calc-graph-set-command "samples" (if (not (equal res
"")) res
))))
1167 (defun calc-graph-device (name flag
)
1168 (interactive "sDevice name: \nP")
1169 (if (equal name
"?")
1171 (calc-gnuplot-command "set terminal")
1172 (calc-graph-view-trail))
1174 (if (> (prefix-numeric-value flag
) 0)
1176 (message "Default GNUPLOT device is \"%s\""
1177 calc-gnuplot-default-device
)
1178 (setq calc-gnuplot-default-device name
))
1180 (message "GNUPLOT device for Print command is \"%s\""
1181 calc-gnuplot-print-device
)
1182 (setq calc-gnuplot-print-device name
)))
1183 (calc-graph-set-command "terminal" (if (not (equal name
""))
1186 (defun calc-graph-output (name flag
)
1187 (interactive "FOutput file name: \np")
1188 (cond ((string-match "\\<[aA][uU][tT][oO]$" name
)
1190 ((string-match "\\<[tT][tT][yY]$" name
)
1192 ((string-match "\\<[sS][tT][dD][oO][uU][tT]$" name
)
1193 (setq name
"STDOUT"))
1194 ((equal (file-name-nondirectory name
) "")
1196 (t (setq name
(expand-file-name name
))))
1198 (if (> (prefix-numeric-value flag
) 0)
1200 (message "Default GNUPLOT output file is \"%s\""
1201 calc-gnuplot-default-output
)
1202 (setq calc-gnuplot-default-output name
))
1204 (message "GNUPLOT output file for Print command is \"%s\""
1205 calc-gnuplot-print-output
)
1206 (setq calc-gnuplot-print-output name
)))
1207 (calc-graph-set-command "output" (if (not (equal name
""))
1208 (prin1-to-string name
)))))
1210 (defun calc-graph-display (name)
1211 (interactive "sX display name: ")
1213 (message "Current X display is \"%s\""
1214 (or calc-gnuplot-display
"<none>"))
1215 (setq calc-gnuplot-display name
)
1216 (if (calc-gnuplot-alive)
1217 (calc-gnuplot-command "exit"))))
1219 (defun calc-graph-geometry (name)
1220 (interactive "sX geometry spec (or \"default\"): ")
1222 (message "Current X geometry is \"%s\""
1223 (or calc-gnuplot-geometry
"default"))
1224 (setq calc-gnuplot-geometry
(and (not (equal name
"default")) name
))
1225 (if (calc-gnuplot-alive)
1226 (calc-gnuplot-command "exit"))))
1228 (defun calc-graph-find-command (cmd)
1231 (set-buffer calc-gnuplot-input
)
1232 (goto-char (point-min))
1233 (if (re-search-forward (concat "^set[ \t]+" cmd
"[ \t]*\\(.*\\)$") nil t
)
1234 (buffer-substring (match-beginning 1) (match-end 1)))))
1236 (defun calc-graph-set-command (cmd &rest args
)
1239 (set-buffer calc-gnuplot-input
)
1240 (goto-char (point-min))
1241 (if (re-search-forward (concat "^set[ \t]+" cmd
"[ \t\n]") nil t
)
1245 (let ((end (point)))
1247 (delete-region (point) (1+ end
))))
1248 (if (calc-graph-find-plot t t
)
1249 (if (eq (preceding-char) ?
\n)
1251 (goto-char (1- (point-max)))))
1252 (if (and args
(car args
))
1256 (insert "set " (mapconcat 'identity
(cons cmd args
) " ") "\n"))))
1257 (calc-graph-view-commands))
1259 (defun calc-graph-command (cmd)
1260 (interactive "sGNUPLOT command: ")
1263 (calc-graph-view-trail)
1264 (calc-gnuplot-command cmd
)
1265 (accept-process-output)
1266 (calc-graph-view-trail)))
1268 (defun calc-graph-kill (&optional no-view
)
1270 (calc-graph-delete-temps)
1271 (if (calc-gnuplot-alive)
1273 (or no-view
(calc-graph-view-trail))
1274 (let ((calc-graph-no-wait t
))
1275 (calc-gnuplot-command "exit"))
1277 (if (process-status calc-gnuplot-process
)
1278 (delete-process calc-gnuplot-process
))
1279 (setq calc-gnuplot-process nil
))))
1281 (defun calc-graph-quit ()
1283 (if (get-buffer-window calc-gnuplot-input
)
1284 (calc-graph-view-commands t
))
1285 (if (get-buffer-window calc-gnuplot-buffer
)
1286 (calc-graph-view-trail t
))
1287 (calc-graph-kill t
))
1289 (defun calc-graph-view-commands (&optional no-need
)
1291 (or calc-graph-no-auto-view
(calc-graph-init-buffers))
1292 (calc-graph-view calc-gnuplot-input calc-gnuplot-buffer
(null no-need
)))
1294 (defun calc-graph-view-trail (&optional no-need
)
1296 (or calc-graph-no-auto-view
(calc-graph-init-buffers))
1297 (calc-graph-view calc-gnuplot-buffer calc-gnuplot-input
(null no-need
)))
1299 (defun calc-graph-view (buf other-buf need
)
1301 (or calc-graph-no-auto-view
1302 (if (setq win
(get-buffer-window buf
))
1304 (and (eq buf calc-gnuplot-buffer
)
1307 (not (pos-visible-in-window-p (point-max) win
))))
1310 (bury-buffer other-buf
)
1311 (let ((curwin (selected-window)))
1313 (switch-to-buffer nil
)
1314 (select-window curwin
))))
1315 (if (setq win
(get-buffer-window other-buf
))
1316 (set-window-buffer win buf
)
1317 (if (eq major-mode
'calc-mode
)
1319 (< (window-height) (1- (frame-height))))
1320 (display-buffer buf
))
1321 (switch-to-buffer buf
)))))
1324 (if (and (eq buf calc-gnuplot-buffer
)
1325 (setq win
(get-buffer-window buf
))
1326 (not (pos-visible-in-window-p (point-max) win
)))
1328 (goto-char (point-max))
1329 (vertical-motion (- 6 (window-height win
)))
1330 (set-window-start win
(point))
1331 (goto-char (point-max)))))
1332 (or calc-graph-no-auto-view
(sit-for 0))))
1334 (defun calc-gnuplot-check-for-errors ()
1338 (set-buffer calc-gnuplot-buffer
)
1339 (goto-char calc-gnuplot-last-error-pos
))
1340 (re-search-forward "^[ \t]+\\^$" nil t
)
1341 (goto-char (point-max))
1342 (setq calc-gnuplot-last-error-pos
(point-max))))
1343 (calc-graph-view-trail)))
1345 (defun calc-gnuplot-command (&rest args
)
1347 (let ((cmd (concat (mapconcat 'identity args
" ") "\n")))
1348 (accept-process-output)
1350 (set-buffer calc-gnuplot-buffer
)
1351 (calc-gnuplot-check-for-errors)
1352 (goto-char (point-max))
1353 (setq calc-gnuplot-trail-mark
(point))
1354 (or (>= calc-gnuplot-version
3)
1356 (set-marker (process-mark calc-gnuplot-process
) (point))
1357 (process-send-string calc-gnuplot-process cmd
)
1358 (if (get-buffer-window calc-gnuplot-buffer
)
1359 (calc-graph-view-trail))
1360 (accept-process-output (and (not calc-graph-no-wait
)
1361 calc-gnuplot-process
))
1362 (calc-gnuplot-check-for-errors)
1363 (if (get-buffer-window calc-gnuplot-buffer
)
1364 (calc-graph-view-trail)))))
1366 (defun calc-graph-init-buffers ()
1367 (or (and calc-gnuplot-buffer
1368 (buffer-name calc-gnuplot-buffer
))
1369 (setq calc-gnuplot-buffer
(get-buffer-create "*Gnuplot Trail*")))
1370 (or (and calc-gnuplot-input
1371 (buffer-name calc-gnuplot-input
))
1372 (setq calc-gnuplot-input
(get-buffer-create "*Gnuplot Commands*"))))
1374 (defun calc-graph-init ()
1375 (or (calc-gnuplot-alive)
1376 (let ((process-connection-type t
)
1378 (if calc-gnuplot-process
1380 (delete-process calc-gnuplot-process
)
1381 (setq calc-gnuplot-process nil
)))
1382 (calc-graph-init-buffers)
1384 (set-buffer calc-gnuplot-buffer
)
1385 (insert "\nStarting gnuplot...\n")
1386 (setq origin
(point)))
1387 (setq calc-graph-last-device nil
)
1388 (setq calc-graph-last-output nil
)
1390 (let ((args (append (and calc-gnuplot-display
1391 (not (equal calc-gnuplot-display
1392 (getenv "DISPLAY")))
1394 calc-gnuplot-display
))
1395 (and calc-gnuplot-geometry
1397 calc-gnuplot-geometry
)))))
1398 (setq calc-gnuplot-process
1399 (apply 'start-process
1404 (set-process-query-on-exit-flag calc-gnuplot-process nil
))
1406 (error "Sorry, can't find \"%s\" on your system"
1407 calc-gnuplot-name
)))
1409 (set-buffer calc-gnuplot-buffer
)
1410 (while (and (not (save-excursion
1412 (search-forward "gnuplot> " nil t
)))
1413 (memq (process-status calc-gnuplot-process
) '(run stop
)))
1414 (accept-process-output calc-gnuplot-process
))
1415 (or (memq (process-status calc-gnuplot-process
) '(run stop
))
1416 (error "Unable to start GNUPLOT process"))
1420 "G N U P L O T.*\n.*version \\([0-9]+\\)\\." nil t
))
1421 (setq calc-gnuplot-version
(string-to-int (buffer-substring
1424 (setq calc-gnuplot-version
1))
1425 (goto-char (point-max)))))
1427 (set-buffer calc-gnuplot-input
)
1428 (if (= (buffer-size) 0)
1429 (insert "# Commands for running gnuplot\n\n\n")
1430 (or calc-graph-no-auto-view
1431 (eq (char-after (1- (point-max))) ?
\n)
1433 (goto-char (point-max))
1436 ;;; arch-tag: e4b06a52-c386-4d54-a2bb-7c0a0ef533c2
1437 ;;; calc-graph.el ends here