aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-01-13 17:50:16 +0200
committerEli Zaretskii2019-01-13 17:50:16 +0200
commitb26d6373c48ca26a7cfc81fd03ec8d7f50c13962 (patch)
tree0a14c77b721472c1d7063e9afa008bcde64ad245
parent03818b0a9509e5e54aaee8a40c25f7da099fb7df (diff)
downloademacs-b26d6373c48ca26a7cfc81fd03ec8d7f50c13962.tar.gz
emacs-b26d6373c48ca26a7cfc81fd03ec8d7f50c13962.zip
Fix Calc graph output on MS-Windows
The previous code relied on "pgnuplot" executable, which is no longer provided with Gnuplot 5.x. * lisp/calc/calc.el (calc-gnuplot-name): Set to "pgnuplot" on MS-Windows only if such an executable exists. * lisp/calc/calc-graph.el (calc-graph-w32-p): New defsubst. (calc-graph-plot, calc-graph-command, calc-gnuplot-command) (calc-graph-init): Call calc-graph-w32-p wherever we need to do something special for invoking gnuplot on MS-Windows, instead of comparing against calc-gnuplot-name. (calc-graph-plot): Set the terminal to "qt" on MS-Windows when pgnuplot.exe is not available. (calc-graph-kill): Delete the temporary files only after killing the gnuplot process, otherwise the deletion might fail on MS-Windows because the files are still in use.
-rw-r--r--lisp/calc/calc-graph.el35
-rw-r--r--lisp/calc/calc.el11
2 files changed, 31 insertions, 15 deletions
diff --git a/lisp/calc/calc-graph.el b/lisp/calc/calc-graph.el
index ff7f12d9faf..317f403ead6 100644
--- a/lisp/calc/calc-graph.el
+++ b/lisp/calc/calc-graph.el
@@ -65,6 +65,9 @@
65(defvar calc-graph-no-wait nil) 65(defvar calc-graph-no-wait nil)
66(defvar calc-gnuplot-trail-mark) 66(defvar calc-gnuplot-trail-mark)
67 67
68(defsubst calc-graph-w32-p ()
69 (eq system-type 'windows-nt))
70
68(defun calc-graph-fast (many) 71(defun calc-graph-fast (many)
69 (interactive "P") 72 (interactive "P")
70 (let ((calc-graph-no-auto-view t)) 73 (let ((calc-graph-no-auto-view t))
@@ -376,8 +379,13 @@
376 ;; Check MS-Windows before X, in case they have 379 ;; Check MS-Windows before X, in case they have
377 ;; $DISPLAY set for some reason (e.g., Cygwin or 380 ;; $DISPLAY set for some reason (e.g., Cygwin or
378 ;; whatever) 381 ;; whatever)
379 ((string= calc-gnuplot-name "pgnuplot") 382 ((string= calc-gnuplot-name "pgnuplot")
380 "windows") 383 "windows")
384 ;; Versions of gnuplot that come without pgnuplot
385 ;; only work on MS-Windows with "qt" as the
386 ;; terminal, for some reason.
387 ((calc-graph-w32-p)
388 "qt")
381 ((or (eq window-system 'x) (getenv "DISPLAY")) 389 ((or (eq window-system 'x) (getenv "DISPLAY"))
382 "x11") 390 "x11")
383 ((>= calc-gnuplot-version 3) 391 ((>= calc-gnuplot-version 3)
@@ -1321,14 +1329,13 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1321 (calc-graph-init) 1329 (calc-graph-init)
1322 (calc-graph-view-trail) 1330 (calc-graph-view-trail)
1323 (calc-gnuplot-command cmd) 1331 (calc-gnuplot-command cmd)
1324 (or (string= calc-gnuplot-name "pgnuplot") 1332 (or (calc-graph-w32-p)
1325 (progn 1333 (progn
1326 (accept-process-output) 1334 (accept-process-output)
1327 (calc-graph-view-trail))))) 1335 (calc-graph-view-trail)))))
1328 1336
1329(defun calc-graph-kill (&optional no-view) 1337(defun calc-graph-kill (&optional no-view)
1330 (interactive) 1338 (interactive)
1331 (calc-graph-delete-temps)
1332 (if (calc-gnuplot-alive) 1339 (if (calc-gnuplot-alive)
1333 (calc-wrapper 1340 (calc-wrapper
1334 (or no-view (calc-graph-view-trail)) 1341 (or no-view (calc-graph-view-trail))
@@ -1337,7 +1344,8 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1337 (sit-for 1) 1344 (sit-for 1)
1338 (if (process-status calc-gnuplot-process) 1345 (if (process-status calc-gnuplot-process)
1339 (delete-process calc-gnuplot-process)) 1346 (delete-process calc-gnuplot-process))
1340 (setq calc-gnuplot-process nil)))) 1347 (setq calc-gnuplot-process nil)))
1348 (calc-graph-delete-temps))
1341 1349
1342(defun calc-graph-quit () 1350(defun calc-graph-quit ()
1343 (interactive) 1351 (interactive)
@@ -1404,7 +1412,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1404(defun calc-gnuplot-command (&rest args) 1412(defun calc-gnuplot-command (&rest args)
1405 (calc-graph-init) 1413 (calc-graph-init)
1406 (let ((cmd (concat (mapconcat 'identity args " ") "\n"))) 1414 (let ((cmd (concat (mapconcat 'identity args " ") "\n")))
1407 (or (string= calc-gnuplot-name "pgnuplot") 1415 (or (calc-graph-w32-p)
1408 (accept-process-output)) 1416 (accept-process-output))
1409 (with-current-buffer calc-gnuplot-buffer 1417 (with-current-buffer calc-gnuplot-buffer
1410 (calc-gnuplot-check-for-errors) 1418 (calc-gnuplot-check-for-errors)
@@ -1416,7 +1424,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1416 (process-send-string calc-gnuplot-process cmd) 1424 (process-send-string calc-gnuplot-process cmd)
1417 (if (get-buffer-window calc-gnuplot-buffer) 1425 (if (get-buffer-window calc-gnuplot-buffer)
1418 (calc-graph-view-trail)) 1426 (calc-graph-view-trail))
1419 (or (string= calc-gnuplot-name "pgnuplot") 1427 (or (calc-graph-w32-p)
1420 (accept-process-output (and (not calc-graph-no-wait) 1428 (accept-process-output (and (not calc-graph-no-wait)
1421 calc-gnuplot-process))) 1429 calc-gnuplot-process)))
1422 (calc-gnuplot-check-for-errors) 1430 (calc-gnuplot-check-for-errors)
@@ -1445,8 +1453,9 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1445 (setq origin (point))) 1453 (setq origin (point)))
1446 (setq calc-graph-last-device nil) 1454 (setq calc-graph-last-device nil)
1447 (setq calc-graph-last-output nil) 1455 (setq calc-graph-last-output nil)
1448 (if (string= calc-gnuplot-name "pgnuplot") 1456 (if (calc-graph-w32-p)
1449 (let ((version-str (shell-command-to-string "pgnuplot -V"))) 1457 (let ((version-str
1458 (shell-command-to-string (concat calc-gnuplot-name " -V"))))
1450 (if (string-match "gnuplot \\([0-9]+\\)\\." version-str) 1459 (if (string-match "gnuplot \\([0-9]+\\)\\." version-str)
1451 (setq calc-gnuplot-version (string-to-number 1460 (setq calc-gnuplot-version (string-to-number
1452 (substring version-str 1461 (substring version-str
@@ -1457,11 +1466,11 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1457 (let ((args (append (and calc-gnuplot-display 1466 (let ((args (append (and calc-gnuplot-display
1458 (not (equal calc-gnuplot-display 1467 (not (equal calc-gnuplot-display
1459 (getenv "DISPLAY"))) 1468 (getenv "DISPLAY")))
1460 (not (string= calc-gnuplot-name "pgnuplot")) 1469 (not (calc-graph-w32-p))
1461 (list "-display" 1470 (list "-display"
1462 calc-gnuplot-display)) 1471 calc-gnuplot-display))
1463 (and calc-gnuplot-geometry 1472 (and calc-gnuplot-geometry
1464 (not (string= calc-gnuplot-name "pgnuplot")) 1473 (not (calc-graph-w32-p))
1465 (list "-geometry" 1474 (list "-geometry"
1466 calc-gnuplot-geometry))))) 1475 calc-gnuplot-geometry)))))
1467 (setq calc-gnuplot-process 1476 (setq calc-gnuplot-process
@@ -1475,7 +1484,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1475 (error "Sorry, can't find \"%s\" on your system" 1484 (error "Sorry, can't find \"%s\" on your system"
1476 calc-gnuplot-name))) 1485 calc-gnuplot-name)))
1477 (with-current-buffer calc-gnuplot-buffer 1486 (with-current-buffer calc-gnuplot-buffer
1478 (while (and (not (string= calc-gnuplot-name "pgnuplot")) 1487 (while (and (not (calc-graph-w32-p))
1479 (not (save-excursion 1488 (not (save-excursion
1480 (goto-char origin) 1489 (goto-char origin)
1481 (search-forward "gnuplot> " nil t))) 1490 (search-forward "gnuplot> " nil t)))
@@ -1483,7 +1492,7 @@ This \"dumb\" driver will be present in Gnuplot 3.0."
1483 (accept-process-output calc-gnuplot-process)) 1492 (accept-process-output calc-gnuplot-process))
1484 (or (memq (process-status calc-gnuplot-process) '(run stop)) 1493 (or (memq (process-status calc-gnuplot-process) '(run stop))
1485 (error "Unable to start GNUPLOT process")) 1494 (error "Unable to start GNUPLOT process"))
1486 (if (not (string= calc-gnuplot-name "pgnuplot")) 1495 (if (not (calc-graph-w32-p))
1487 (if (save-excursion 1496 (if (save-excursion
1488 (goto-char origin) 1497 (goto-char origin)
1489 (re-search-forward 1498 (re-search-forward
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index ef850a44fe6..1d403b73943 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -395,10 +395,17 @@ This is not required to be present for user-written mode annotations."
395 (string :tag "Closing annotation delimiter")))) 395 (string :tag "Closing annotation delimiter"))))
396 396
397(defcustom calc-gnuplot-name 397(defcustom calc-gnuplot-name
398 (if (eq system-type 'windows-nt) "pgnuplot" "gnuplot") 398 (if (and (eq system-type 'windows-nt)
399 ;; Gnuplot v4.x on MS-Windows came with a special
400 ;; pipe-enabled gnuplot executable for batch-mode
401 ;; execution; newer versions allow using gnuplot.exe.
402 (executable-find "pgnuplot"))
403 "pgnuplot"
404 "gnuplot")
399 "Name of GNUPLOT program, for calc-graph features." 405 "Name of GNUPLOT program, for calc-graph features."
400 :group 'calc 406 :group 'calc
401 :type '(string)) 407 :type '(string)
408 :version "26.2")
402 409
403(defcustom calc-gnuplot-plot-command 410(defcustom calc-gnuplot-plot-command
404 nil 411 nil