[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 245/255: misc fixes
From: |
Eric Schulte |
Subject: |
[elpa] 245/255: misc fixes |
Date: |
Sun, 16 Mar 2014 01:02:57 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 723a5bd40cfb4b2effb8dc2298837987da37b79b
Author: Eric Schulte <address@hidden>
Date: Fri Aug 9 16:56:33 2013 -0600
misc fixes
---
back-ends/gtp-pipe.el | 37 +++++++++++++++++++++++--------------
go-board.el | 2 +-
2 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/back-ends/gtp-pipe.el b/back-ends/gtp-pipe.el
index fe01623..3b0529c 100644
--- a/back-ends/gtp-pipe.el
+++ b/back-ends/gtp-pipe.el
@@ -36,6 +36,9 @@
(defvar *gtp-pipe-last* nil
"Last move of the current game.")
+(defvar *gtp-pipe-inhibit* nil
+ "Prevent infinite loops of commands.")
+
(defun gtp-pipe-start (command)
"Connect a `gtp-pipe' instance to the process created by COMMAND.
Pass \"netcat -lp 6666\" as COMMAND to listen on a local port, or
@@ -47,22 +50,21 @@ port."
(defun gtp-pipe-process-filter (proc string)
(go-re-cond string
("^\\(black\\|white\\) \\(.*\\)$"
- (let ((color (match-string 1 string))
+ (let ((color (go-re-cond (match-string 1 string)
+ ("black" :B)
+ ("white" :W)))
(action (match-string 2 string)))
(go-re-cond action
- ("^pass" (go-pass *gtp-pipe-board*))
- ("^resign" (go-resign *gtp-pipe-board*))
- (t (let ((move (gtp-to-pos (go-re-cond
- ("black" :B)
- ("white" :W))
- (match-string 2 string))))
+ ("^pass" (let ((*gtp-pipe-inhibit* t)) (go-pass
*gtp-pipe-board*)))
+ ("^resign" (let ((*gtp-pipe-inhibit* t)) (go-resign
*gtp-pipe-board*)))
+ (t (let ((move (gtp-to-pos color action)))
(setf *gtp-pipe-last* move)
(setf (go-move *gtp-pipe-board*) move))))))
- ("^genmove_\\(black\\|white\\)" (message "gtp-pipe: %s's turn"
- (match-string 1 string)))
+ ("^genmove_\\(black\\|white\\)"
+ (message "gtp-pipe: %s's turn" (match-string 1 string)))
("^last_move" (go-to-gtp-command *gtp-pipe-last*))
- ("^quit" (message "gtp-pipe: QUIT") (go-quit *gtp-pipe-board*))
- ("^undo" (go-undo *gtp-pipe-board*))
+ ("^quit" (let ((*gtp-pipe-inhibit* t)) (go-quit *gtp-pipe-board*)))
+ ("^undo" (let ((*gtp-pipe-inhibit* t)) (go-undo *gtp-pipe-board*)))
("^string \\(.*\\)$" (message "gtp-pipe: %S" (match-string 1 string)))
(t (message "gtp-pipe unknown command: %S" string))))
@@ -80,6 +82,7 @@ port."
(with-current-buffer buf
(comint-mode)
(set (make-local-variable '*gtp-pipe-last*) nil)
+ (set (make-local-variable '*gtp-pipe-inhibit*) nil)
(set (make-local-variable '*gtp-pipe-board*)
(save-excursion
(make-instance 'board
@@ -91,9 +94,10 @@ port."
(defmethod gtp-command ((gtp-pipe gtp-pipe) command)
(with-current-buffer (buffer gtp-pipe)
- (goto-char (process-mark (get-buffer-process (current-buffer))))
- (insert command)
- (comint-send-input)))
+ (unless *gtp-pipe-inhibit*
+ (goto-char (process-mark (get-buffer-process (current-buffer))))
+ (insert command)
+ (comint-send-input))))
(defmethod go-comment ((gtp-pipe gtp-pipe))
(signal 'unsupported-back-end-command (list gtp-pipe :comment)))
@@ -109,6 +113,11 @@ port."
(defmethod go-size ((gtp-pipe gtp-pipe))
(read-from-minibuffer "GTP board size: " nil nil 'read))
+(defmethod go-quit ((gtp-pipe gtp-pipe))
+ (gtp-command gtp-pipe "quit")
+ (with-current-buffer (buffer gtp-pipe)
+ (signal-process (get-buffer-process) 'KILL)))
+
(defmethod go-player-name ((gtp-pipe gtp-pipe) color) "GTP pipe")
(defmethod set-player-name ((gtp-pipe gtp-pipe) color name)
diff --git a/go-board.el b/go-board.el
index b82712f..6ed29e9 100644
--- a/go-board.el
+++ b/go-board.el
@@ -566,6 +566,6 @@
(update-display)))
(defmethod go-quit ((board board))
- (with-board board (board-quit)))
+ (with-board board (go-quit)))
(provide 'go-board)
- [elpa] 241/255: igs class definitions up front for better loading, (continued)
- [elpa] 241/255: igs class definitions up front for better loading, Eric Schulte, 2014/03/15
- [elpa] 247/255: notes, Eric Schulte, 2014/03/15
- [elpa] 235/255: better line truncation, Eric Schulte, 2014/03/15
- [elpa] 250/255: mark dead stones at end of game, Eric Schulte, 2014/03/15
- [elpa] 229/255: igs TODO: consistent game un-observation, Eric Schulte, 2014/03/15
- [elpa] 242/255: need assoc for aget, Eric Schulte, 2014/03/15
- [elpa] 228/255: refresh the game list buffer, Eric Schulte, 2014/03/15
- [elpa] 211/255: scale column width by buffer width, Eric Schulte, 2014/03/15
- [elpa] 233/255: igs handle adjourned and resigned games, Eric Schulte, 2014/03/15
- [elpa] 244/255: igs-pipe handles resignation and comments, Eric Schulte, 2014/03/15
- [elpa] 245/255: misc fixes,
Eric Schulte <=
- [elpa] 169/255: igs: automatically collect a game listing, Eric Schulte, 2014/03/15
- [elpa] 248/255: try to fix gnugo Emacs crashes, Eric Schulte, 2014/03/15
- [elpa] 254/255: re-format README, Eric Schulte, 2014/03/15
- [elpa] 161/255: moving towards using images, Eric Schulte, 2014/03/15
- [elpa] 240/255: robust loading w/o load-path customization, Eric Schulte, 2014/03/15
- [elpa] 253/255: renamed el-go README, Eric Schulte, 2014/03/15
- [elpa] 227/255: TODO retain comments, Eric Schulte, 2014/03/15
- [elpa] 231/255: refresh message, Eric Schulte, 2014/03/15
- [elpa] 239/255: backend for GTP through arbitrary process, Eric Schulte, 2014/03/15
- [elpa] 232/255: gtp-num-to-char is being called but is undefined, Eric Schulte, 2014/03/15