[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 02/02: [gnugo] Decruft: Use ‘ gnugo-program’ directly as executab
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 02/02: [gnugo] Decruft: Use ‘ gnugo-program’ directly as executable. |
Date: |
Fri, 18 Apr 2014 09:05:11 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 0c8e3a10bcdb93dcc81db045419fb87ed834914a
Author: Thien-Thi Nguyen <address@hidden>
Date: Thu Apr 17 22:24:24 2014 +0200
[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.
---
packages/gnugo/NEWS | 1 +
packages/gnugo/gnugo.el | 36 ++++++++++++------------------------
2 files changed, 13 insertions(+), 24 deletions(-)
diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index c2da1c4..b803fd9 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/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/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index be114cd..b1de724 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/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
-in OPTIONS.
-
-For more information on GTP and GNU Go, feel free to visit:
-http://www.gnu.org/software/gnugo")
+ "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:
+<http://www.gnu.org/software/gnugo>")
(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)"))
(gnugo-board-mode)
- (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)
'gnugo-option-history))
proc
@@ -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"
proc-args))))
(set-process-sentinel proc 'gnugo-sentinel)