summaryrefslogtreecommitdiff
path: root/lisp/calc/calc-graph.el
diff options
context:
space:
mode:
authorYuuki Harano <masm+github@masm11.me>2021-11-11 00:39:53 +0900
committerYuuki Harano <masm+github@masm11.me>2021-11-11 00:39:53 +0900
commit4dd1f56f29fc598a8339a345c2f8945250600602 (patch)
treeaf341efedffe027e533b1bcc0dbf270532e48285 /lisp/calc/calc-graph.el
parent4c49ec7f865bdad1629d2f125f71f4e506b258f2 (diff)
parent810fa21d26453f898de9747ece7205dfe6de9d08 (diff)
downloademacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.gz
emacs-4dd1f56f29fc598a8339a345c2f8945250600602.tar.bz2
emacs-4dd1f56f29fc598a8339a345c2f8945250600602.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'lisp/calc/calc-graph.el')
-rw-r--r--lisp/calc/calc-graph.el37
1 files changed, 21 insertions, 16 deletions
diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el
index 423d1e64126..7891e35c40f 100644
--- a/lisp/calc/calc-graph.el
+++ b/lisp/calc/calc-graph.el
@@ -391,6 +391,13 @@
((>= calc-gnuplot-version 3)
"dumb")
(t "postscript"))))
+ (unless (equal device calc-graph-last-device)
+ (setq calc-graph-last-device device)
+ (unless (calc-gnuplot-command "set terminal" device)
+ ;; If gnuplot doesn't support the terminal, then set it
+ ;; to "dumb".
+ (calc-gnuplot-command "set terminal dumb")
+ (setq device "dumb")))
(if (equal device "dumb")
(setq device (format "dumb %d %d"
(1- (frame-width)) (1- (frame-height)))))
@@ -404,10 +411,6 @@
(setq tempoutfile (calc-temp-file-name -1)
output tempoutfile))
(setq output (eval output t)))
- (or (equal device calc-graph-last-device)
- (progn
- (setq calc-graph-last-device device)
- (calc-gnuplot-command "set terminal" device)))
(or (equal output calc-graph-last-output)
(progn
(setq calc-graph-last-output output)
@@ -1025,7 +1028,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
(calc-pop-stack 1))))
(if (string-match "\\[.+\\]" range)
(setq range (substring range 1 -1)))
- (if (and (not (string-match ":" range))
+ (if (and (not (string-search ":" range))
(or (string-match "," range)
(string-match " " range)))
(aset range (match-beginning 0) ?\:))
@@ -1400,17 +1403,17 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
(or calc-graph-no-auto-view (sit-for 0))))
(defun calc-gnuplot-check-for-errors ()
- (if (save-excursion
- (prog2
- (progn
- (set-buffer calc-gnuplot-buffer)
- (goto-char calc-gnuplot-last-error-pos))
- (re-search-forward "^[ \t]+\\^$" nil t)
- (goto-char (point-max))
- (setq calc-gnuplot-last-error-pos (point-max))))
+ (if (with-current-buffer calc-gnuplot-buffer
+ (goto-char calc-gnuplot-last-error-pos)
+ (prog1
+ (re-search-forward "^[ \t]+\\^$" nil t)
+ (goto-char (point-max))
+ (setq calc-gnuplot-last-error-pos (point-max))))
(calc-graph-view-trail)))
(defun calc-gnuplot-command (&rest args)
+ "Send ARGS to Gnuplot.
+Returns nil if Gnuplot signalled an error."
(calc-graph-init)
(let ((cmd (concat (mapconcat 'identity args " ") "\n")))
(or (calc-graph-w32-p)
@@ -1428,9 +1431,11 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
(or (calc-graph-w32-p)
(accept-process-output (and (not calc-graph-no-wait)
calc-gnuplot-process)))
- (calc-gnuplot-check-for-errors)
- (if (get-buffer-window calc-gnuplot-buffer)
- (calc-graph-view-trail)))))
+ (prog1
+ ;; Return nil if we got an error.
+ (not (calc-gnuplot-check-for-errors))
+ (if (get-buffer-window calc-gnuplot-buffer)
+ (calc-graph-view-trail))))))
(defun calc-graph-init-buffers ()
(or (and calc-gnuplot-buffer