[Top][All Lists]

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

[elpa] externals/gnugo e96b88b 218/357: [gnugo] Decruft: Use ‘gnugo-pro

From: Stefan Monnier
Subject: [elpa] externals/gnugo e96b88b 218/357: [gnugo] Decruft: Use ‘gnugo-program’ directly as executable.
Date: Sun, 29 Nov 2020 14:51:25 -0500 (EST)

branch: externals/gnugo
commit e96b88bac96f43d4422bd0f3fc5357036ce9d8de
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo] Decruft: Use ‘gnugo-program’ directly as executable.
    * packages/gnugo/gnugo.el (gnugo-program): Rewrite docstring.
    (gnugo): Add ‘gnugo-program’ sanity check prior to buffer
    switch; drop support for "PROGRAM OPTIONS..." value.
 NEWS     |  1 +
 gnugo.el | 36 ++++++++++++------------------------
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/NEWS b/NEWS
index c2da1c4..b803fd9 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ NB: "RCS: X..Y " means that the particular release includes
     - avoid clobbering SGF property ‘EV’ on resignation
     - follow main line in subtrees on read
     - for ‘F’ forced PASS moves, keep subproc informed as well
+  - dropped support for ‘gnugo-program’ of form "PROGRAM OPTIONS..."
   - dropped command: ‘t’ (gnugo-toggle-dead-group)
   - PASS for SZ <= 19 normalized to "" on read, written as ""
   - ‘=’ also displays move number of the stone (if any) at that position
diff --git a/gnugo.el b/gnugo.el
index be114cd..b1de724 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -94,14 +94,12 @@ This follows a MAJOR.MINOR.PATCH scheme.")
 ;;; Variables for the uninquisitive programmer
 (defvar gnugo-program "gnugo"
-  "Command to start an external program that speaks GTP, such as \"gnugo\".
-The value may also be in the form \"PROGRAM OPTIONS...\" in which case the
-the command `gnugo' will prefix OPTIONS in its default offering when it
-queries you for additional options.  It is an error for \"--mode\" to appear
-For more information on GTP and GNU Go, feel free to visit:
+  "Name of the GNU Go program (executable file).
+\\[gnugo] validates this using `executable-find'.
+This program must accept command line args:
+ --mode gtp --quiet
+For more information on GTP and GNU Go, please visit:
 (defvar gnugo-board-mode-map nil
   "Keymap for GNUGO Board mode.")
@@ -2431,24 +2429,13 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
                   (if (string= "" sel)
                       (car all)
                     (assoc sel all))))))
+      ;; sanity check
+      (unless (executable-find gnugo-program)
+        (user-error "Invalid `gnugo-program': %S" gnugo-program))
       ;; set up a new board
       (switch-to-buffer (generate-new-buffer "(Uninitialized GNUGO Board)"))
-      (let ((name (if (string-match "[ ]" gnugo-program)
-                      (let ((p (substring gnugo-program 0 (match-beginning 0)))
-                            (o (substring gnugo-program (match-end 0)))
-                            (h (or (car gnugo-option-history) "")))
-                        (when (string-match "--mode" o)
-                          (user-error "Found \"--mode\" in `gnugo-program'"))
-                        (when (and o (cl-plusp (length o))
-                                   h (cl-plusp (length o))
-                                   (or (< (length h) (length o))
-                                       (not (string= (substring h 0 (length o))
-                                                     o))))
-                          (push (concat o " " h) gnugo-option-history))
-                        p)
-                    gnugo-program))
-            (args (read-string "GNU Go options: "
+      (let ((args (read-string "GNU Go options: "
                                (car gnugo-option-history)
@@ -2471,7 +2458,8 @@ starting a new one.  See `gnugo-board-mode' documentation 
for more info."
         (let ((proc-args (split-string args)))
           (gnugo-put :proc-args proc-args)
           (gnugo-put :proc (setq proc (apply 'start-process "gnugo"
-                                             (current-buffer) name
+                                             (current-buffer)
+                                             gnugo-program
                                              "--mode" "gtp" "--quiet"
         (set-process-sentinel proc 'gnugo-sentinel)

reply via email to

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