1 |
;; Calculator for GNU Emacs, part II [calc-graph.el] |
;;; calc-graph.el --- graph output functions for Calc |
2 |
|
|
3 |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
4 |
;; Written by Dave Gillespie, daveg@synaptics.com. |
|
5 |
|
;; Author: David Gillespie <daveg@synaptics.com> |
6 |
|
;; Maintainer: Colin Walters <walters@debian.org> |
7 |
|
|
8 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
9 |
|
|
22 |
;; file named COPYING. Among other things, the copyright notice |
;; file named COPYING. Among other things, the copyright notice |
23 |
;; and this notice must be preserved on all copies. |
;; and this notice must be preserved on all copies. |
24 |
|
|
25 |
|
;;; Commentary: |
26 |
|
|
27 |
|
;;; Code: |
28 |
|
|
29 |
;; This file is autoloaded from calc-ext.el. |
;; This file is autoloaded from calc-ext.el. |
30 |
(require 'calc-ext) |
(require 'calc-ext) |
37 |
;;; Graphics |
;;; Graphics |
38 |
|
|
39 |
;;; Note that some of the following initial values also occur in calc.el. |
;;; Note that some of the following initial values also occur in calc.el. |
40 |
(defvar calc-gnuplot-tempfile "/tmp/calc") |
(defvar calc-gnuplot-tempfile (expand-file-name "calc" temporary-file-directory)) |
41 |
|
|
42 |
(defvar calc-gnuplot-default-device "default") |
(defvar calc-gnuplot-default-device "default") |
43 |
(defvar calc-gnuplot-default-output "STDOUT") |
(defvar calc-gnuplot-default-output "STDOUT") |
63 |
(defvar calc-graph-var-cache nil) |
(defvar calc-graph-var-cache nil) |
64 |
(defvar calc-graph-data-cache nil) |
(defvar calc-graph-data-cache nil) |
65 |
(defvar calc-graph-data-cache-limit 10) |
(defvar calc-graph-data-cache-limit 10) |
66 |
|
(defvar calc-graph-no-auto-view nil) |
67 |
|
(defvar calc-graph-no-wait nil) |
68 |
|
|
69 |
(defun calc-graph-fast (many) |
(defun calc-graph-fast (many) |
70 |
(interactive "P") |
(interactive "P") |
915 |
(define-key calc-dumb-map "\C-c\C-c" 'exit-recursive-edit))) |
(define-key calc-dumb-map "\C-c\C-c" 'exit-recursive-edit))) |
916 |
(use-local-map calc-dumb-map) |
(use-local-map calc-dumb-map) |
917 |
(setq truncate-lines t) |
(setq truncate-lines t) |
918 |
(message "Type `q'%s to return to Calc." |
(message "Type `q'%s to return to Calc" |
919 |
(if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch) |
(if (eq (lookup-key (current-global-map) "\e#") 'calc-dispatch) |
920 |
" or `M-# M-#'" "")) |
" or `M-# M-#'" "")) |
921 |
(recursive-edit) |
(recursive-edit) |
1158 |
(if flag |
(if flag |
1159 |
(if (> (prefix-numeric-value flag) 0) |
(if (> (prefix-numeric-value flag) 0) |
1160 |
(if (equal res "") |
(if (equal res "") |
1161 |
(message "Default resolution is %d." |
(message "Default resolution is %d" |
1162 |
calc-graph-default-resolution) |
calc-graph-default-resolution) |
1163 |
(setq calc-graph-default-resolution (string-to-int res))) |
(setq calc-graph-default-resolution (string-to-int res))) |
1164 |
(if (equal res "") |
(if (equal res "") |
1165 |
(message "Default 3D resolution is %d." |
(message "Default 3D resolution is %d" |
1166 |
calc-graph-default-resolution-3d) |
calc-graph-default-resolution-3d) |
1167 |
(setq calc-graph-default-resolution-3d (string-to-int res)))) |
(setq calc-graph-default-resolution-3d (string-to-int res)))) |
1168 |
(calc-graph-set-command "samples" (if (not (equal res "")) res)))) |
(calc-graph-set-command "samples" (if (not (equal res "")) res)))) |
1176 |
(if flag |
(if flag |
1177 |
(if (> (prefix-numeric-value flag) 0) |
(if (> (prefix-numeric-value flag) 0) |
1178 |
(if (equal name "") |
(if (equal name "") |
1179 |
(message "Default GNUPLOT device is \"%s\"." |
(message "Default GNUPLOT device is \"%s\"" |
1180 |
calc-gnuplot-default-device) |
calc-gnuplot-default-device) |
1181 |
(setq calc-gnuplot-default-device name)) |
(setq calc-gnuplot-default-device name)) |
1182 |
(if (equal name "") |
(if (equal name "") |
1183 |
(message "GNUPLOT device for Print command is \"%s\"." |
(message "GNUPLOT device for Print command is \"%s\"" |
1184 |
calc-gnuplot-print-device) |
calc-gnuplot-print-device) |
1185 |
(setq calc-gnuplot-print-device name))) |
(setq calc-gnuplot-print-device name))) |
1186 |
(calc-graph-set-command "terminal" (if (not (equal name "")) |
(calc-graph-set-command "terminal" (if (not (equal name "")) |
1200 |
(if flag |
(if flag |
1201 |
(if (> (prefix-numeric-value flag) 0) |
(if (> (prefix-numeric-value flag) 0) |
1202 |
(if (equal name "") |
(if (equal name "") |
1203 |
(message "Default GNUPLOT output file is \"%s\"." |
(message "Default GNUPLOT output file is \"%s\"" |
1204 |
calc-gnuplot-default-output) |
calc-gnuplot-default-output) |
1205 |
(setq calc-gnuplot-default-output name)) |
(setq calc-gnuplot-default-output name)) |
1206 |
(if (equal name "") |
(if (equal name "") |
1207 |
(message "GNUPLOT output file for Print command is \"%s\"." |
(message "GNUPLOT output file for Print command is \"%s\"" |
1208 |
calc-gnuplot-print-output) |
calc-gnuplot-print-output) |
1209 |
(setq calc-gnuplot-print-output name))) |
(setq calc-gnuplot-print-output name))) |
1210 |
(calc-graph-set-command "output" (if (not (equal name "")) |
(calc-graph-set-command "output" (if (not (equal name "")) |
1213 |
(defun calc-graph-display (name) |
(defun calc-graph-display (name) |
1214 |
(interactive "sX display name: ") |
(interactive "sX display name: ") |
1215 |
(if (equal name "") |
(if (equal name "") |
1216 |
(message "Current X display is \"%s\"." |
(message "Current X display is \"%s\"" |
1217 |
(or calc-gnuplot-display "<none>")) |
(or calc-gnuplot-display "<none>")) |
1218 |
(setq calc-gnuplot-display name) |
(setq calc-gnuplot-display name) |
1219 |
(if (calc-gnuplot-alive) |
(if (calc-gnuplot-alive) |
1222 |
(defun calc-graph-geometry (name) |
(defun calc-graph-geometry (name) |
1223 |
(interactive "sX geometry spec (or \"default\"): ") |
(interactive "sX geometry spec (or \"default\"): ") |
1224 |
(if (equal name "") |
(if (equal name "") |
1225 |
(message "Current X geometry is \"%s\"." |
(message "Current X geometry is \"%s\"" |
1226 |
(or calc-gnuplot-geometry "default")) |
(or calc-gnuplot-geometry "default")) |
1227 |
(setq calc-gnuplot-geometry (and (not (equal name "default")) name)) |
(setq calc-gnuplot-geometry (and (not (equal name "default")) name)) |
1228 |
(if (calc-gnuplot-alive) |
(if (calc-gnuplot-alive) |
1333 |
(set-window-start win (point)) |
(set-window-start win (point)) |
1334 |
(goto-char (point-max))))) |
(goto-char (point-max))))) |
1335 |
(or calc-graph-no-auto-view (sit-for 0)))) |
(or calc-graph-no-auto-view (sit-for 0)))) |
|
(setq calc-graph-no-auto-view nil) |
|
1336 |
|
|
1337 |
(defun calc-gnuplot-check-for-errors () |
(defun calc-gnuplot-check-for-errors () |
1338 |
(if (save-excursion |
(if (save-excursion |
1365 |
(calc-gnuplot-check-for-errors) |
(calc-gnuplot-check-for-errors) |
1366 |
(if (get-buffer-window calc-gnuplot-buffer) |
(if (get-buffer-window calc-gnuplot-buffer) |
1367 |
(calc-graph-view-trail))))) |
(calc-graph-view-trail))))) |
|
(setq calc-graph-no-wait nil) |
|
1368 |
|
|
1369 |
(defun calc-graph-init-buffers () |
(defun calc-graph-init-buffers () |
1370 |
(or (and calc-gnuplot-buffer |
(or (and calc-gnuplot-buffer |
1406 |
args)) |
args)) |
1407 |
(process-kill-without-query calc-gnuplot-process)) |
(process-kill-without-query calc-gnuplot-process)) |
1408 |
(file-error |
(file-error |
1409 |
(error "Sorry, can't find \"%s\" on your system." |
(error "Sorry, can't find \"%s\" on your system" |
1410 |
calc-gnuplot-name))) |
calc-gnuplot-name))) |
1411 |
(save-excursion |
(save-excursion |
1412 |
(set-buffer calc-gnuplot-buffer) |
(set-buffer calc-gnuplot-buffer) |
1416 |
(memq (process-status calc-gnuplot-process) '(run stop))) |
(memq (process-status calc-gnuplot-process) '(run stop))) |
1417 |
(accept-process-output calc-gnuplot-process)) |
(accept-process-output calc-gnuplot-process)) |
1418 |
(or (memq (process-status calc-gnuplot-process) '(run stop)) |
(or (memq (process-status calc-gnuplot-process) '(run stop)) |
1419 |
(error "Unable to start GNUPLOT process.")) |
(error "Unable to start GNUPLOT process")) |
1420 |
(if (save-excursion |
(if (save-excursion |
1421 |
(goto-char origin) |
(goto-char origin) |
1422 |
(re-search-forward |
(re-search-forward |