emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gnuplot 51756c3 015/184: Changed fetch-version-number to w


From: ELPA Syncer
Subject: [nongnu] elpa/gnuplot 51756c3 015/184: Changed fetch-version-number to work with older gnuplots
Date: Sun, 29 Aug 2021 11:03:06 -0400 (EDT)

branch: elpa/gnuplot
commit 51756c36d23f516258e95e23478c6e594477559e
Author: Jonathan Oddie <j.j.oddie@gmail.com>
Commit: Jonathan Oddie <j.j.oddie@gmail.com>

    Changed fetch-version-number to work with older gnuplots
    
    - "gnuplot --version" seems to be an addition to gnuplot v4 ; at least
      it didn't work with an old v3.7 I compiled. So we are back to the
      old method, but using a temp buffer and calling gnuplot-program
      synchronously for simplicity's sake. Using a temp buffer instead of
      `echo' and a pipe *might* also be slightly more likely to work on
      non-Unixy systems (windows?)
---
 gnuplot.el | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/gnuplot.el b/gnuplot.el
index 0bb66c2..d880d1f 100644
--- a/gnuplot.el
+++ b/gnuplot.el
@@ -1935,9 +1935,8 @@ buffer."
   "Determine the installed version of the gnuplot program.
 
 If `gnuplot-program-version' is already set, does
-nothing. Otherwise, runs `gnuplot-program' with the '--version'
-option, expecting to get a string beginning with something like
-\"gnuplot N.N ...\"
+nothing. Otherwise, runs `gnuplot-program' and searches the text
+printed at startup for a string like \"Version N.N\".
 
 Sets the variables `gnuplot-program-version',
 `gnuplot-program-major-version', `gnuplot-program-minor-version',
@@ -1945,34 +1944,33 @@ and `gnuplot-three-eight-p'.
 
 If the version number cannot be determined by this method, it
 defaults to 3.7."
-
   (unless gnuplot-program-version
     (message "gnuplot-mode %s -- determining gnuplot version ......"
             gnuplot-version)
-    ;; It's simpler and faster to use "gnuplot --version" instead of
-    ;; piping and parsing the output of "show version"; hopefully this
-    ;; also works with older versions? <jjo>
-    (let* ((command (concat gnuplot-program " --version"))
-          (version-string (shell-command-to-string command)))
-      (if (string-match "gnuplot\\s-+\\([0-9]+\\)\\.\\([0-9]+\\)" 
version-string)
+    (with-temp-buffer
+      (insert "show version")
+      (call-process-region (point-min) (point-max)
+                          gnuplot-program t (current-buffer))
+      (goto-char (point-min))
+      (if (and (re-search-forward "[Vv]ersion\\s-+" (point-max) t)
+              (looking-at "\\([0-9]\\)\\.\\([0-9]+\\)"))
          (progn
-           (setq gnuplot-program-version (concat (match-string 1 
version-string)
-                                                 "."
-                                                 (match-string 2 
version-string))
+           (setq gnuplot-program-version (match-string 0)
                  gnuplot-program-major-version (string-to-number
-                                                (match-string 1 
version-string))
+                                                (match-string 1))
                  gnuplot-program-minor-version (string-to-number
-                                                (match-string 2 
version-string))
+                                                (match-string 2))
                  gnuplot-three-eight-p
                  (>= (string-to-number gnuplot-program-version) 3.8)))
 
-       ;; Guess v3.7 otherwise
+       ;; Guess v3.7 if something went wrong
+       (message "Warning: could not determine gnuplot version, guessing 3.7")
        (setq gnuplot-program-version "3.7"
              gnuplot-program-major-version 3
              gnuplot-program-minor-version 7
-             gnuplot-three-eight-p nil)
-       (message "Warning: could not determine gnuplot version, guessing 3.7")))
-      
+             gnuplot-three-eight-p nil)))
+    
+    ;; Setup stuff that depends on version number
     (gnuplot-setup-menu-and-toolbar)))
 
 (defun gnuplot-setup-menu-and-toolbar ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]