[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 07/13: [gnugo int] Add abstraction: gnugo--q/ue
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 07/13: [gnugo int] Add abstraction: gnugo--q/ue |
Date: |
Mon, 21 Apr 2014 21:32:09 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 9ad395773e0904fe45b5681728bde657944ac419
Author: Thien-Thi Nguyen <address@hidden>
Date: Mon Apr 21 14:04:04 2014 +0200
[gnugo int] Add abstraction: gnugo--q/ue
* packages/gnugo/gnugo.el (gnugo--q/ue): New func.
(gnugo-push-move, gnugo-read-sgf-file, gnugo-magic-undo): Use it.
---
packages/gnugo/gnugo.el | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 7edebf6..10e29e2 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -420,6 +420,12 @@ status of the command. See also `gnugo-query'."
(prog1 (substring (process-get proc :srs) 0 -2)
(process-put proc :srs ""))))
+(defun gnugo--q/ue (fmt &rest args)
+ (let ((ans (apply 'gnugo--q fmt args)))
+ (unless (= ?= (aref ans 0))
+ (user-error "%s" ans))
+ (substring ans 2)))
+
(defun gnugo-query (message-format &rest args)
"Send GNU Go a command formatted with MESSAGE-FORMAT and ARGS.
Return a string that omits the first two characters (corresponding
@@ -1284,9 +1290,7 @@ This fails if the monkey is on the current branch
(onep (and head (gnugo--passp head)))
(donep (or resignp (and onep passp))))
(unless resignp
- (let ((accept (gnugo--q (format "play %s %s" color move))))
- (unless (= ?= (aref accept 0))
- (user-error "%s" accept))))
+ (gnugo--q/ue "play %s %s" color move))
(unless passp
(gnugo-merge-showboard-results))
(gnugo-put :last-mover color)
@@ -1885,14 +1889,10 @@ If FILENAME already exists, Emacs confirms that you
wish to overwrite it."
(interactive "fSGF file to load: ")
(when (file-directory-p filename)
(user-error "Cannot load a directory (try a filename with extension
.sgf)"))
- (let (ans play wait samep coll tree game-over)
+ (let (play wait samep coll tree game-over)
;; problem: requiring GTP `loadsgf' complicates network subproc support;
;; todo: skip it altogether when confident about `gnugo/sgf-create'
- (unless (= ?= (aref (setq ans (gnugo--q "loadsgf %s"
- (expand-file-name filename)))
- 0))
- (user-error "%s" ans))
- (setq play (substring ans 2)
+ (setq play (gnugo--q/ue "loadsgf %s" (expand-file-name filename))
wait (gnugo-other play)
samep (string= (gnugo-get :user-color) play))
(gnugo-put :last-mover wait)
@@ -1957,7 +1957,7 @@ when play resumes."
(tree (gnugo-get :sgf-gametree))
(ends (gnugo--tree-ends tree))
(remorseful (not (gnugo--no-regrets monkey ends)))
- done ans)
+ done)
(cond ((numberp spec)
(setq n (if (zerop spec)
(if (string= user-color (gnugo-get :last-mover))
@@ -1983,9 +1983,7 @@ when play resumes."
(when (gnugo-get :game-over)
(gnugo--unclose-game))
(while (not (funcall done))
- (setq ans (gnugo--q "undo"))
- (unless (= ?= (aref ans 0))
- (user-error "%s" ans))
+ (gnugo--q/ue "undo")
(pop (aref monkey 0))
(gnugo-put :last-mover (gnugo-current-player))
(gnugo-merge-showboard-results) ; all
- [elpa] branch master updated (1905244 -> a1fe7f0), Thien-Thi Nguyen, 2014/04/21
- [elpa] 01/13: [gnugo int] Add abstraction: gnugo--prop<-color, Thien-Thi Nguyen, 2014/04/21
- [elpa] 03/13: [gnugo int] Fix bug: On -l/--infile, don't set :last-mover., Thien-Thi Nguyen, 2014/04/21
- [elpa] 04/13: [gnugo int] Fix bug: On -l/--infile, inhibit first move if game over., Thien-Thi Nguyen, 2014/04/21
- [elpa] 05/13: [gnugo] Fix bug: DTRT for :last-user-bpos in undo-one-move ME-NEXT., Thien-Thi Nguyen, 2014/04/21
- [elpa] 06/13: [gnugo] Reduce modifier key bouncing for "quick peek" frolics., Thien-Thi Nguyen, 2014/04/21
- [elpa] 09/13: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’., Thien-Thi Nguyen, 2014/04/21
- [elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone, Thien-Thi Nguyen, 2014/04/21
- [elpa] 07/13: [gnugo int] Add abstraction: gnugo--q/ue,
Thien-Thi Nguyen <=
- [elpa] 10/13: [gnugo] Internalize ‘g nugo-magic-undo’., Thien-Thi Nguyen, 2014/04/21
- [elpa] 11/13: [gnugo int] Simplify towards-root loop termination check., Thien-Thi Nguyen, 2014/04/21
- [elpa] 13/13: [gnugo int] Move ‘gnug o-position’ call down-chain., Thien-Thi Nguyen, 2014/04/21
- [elpa] 12/13: [gnugo int] Centralize some "No stone at POS" errors., Thien-Thi Nguyen, 2014/04/21
- [elpa] 02/13: [gnugo] On SGF load, leave cursor at last user board position., Thien-Thi Nguyen, 2014/04/21