]> code.delx.au - gnu-emacs-elpa/commitdiff
[gnugo int] Add abstraction: gnugo--unclose-game
authorThien-Thi Nguyen <ttn@gnu.org>
Thu, 13 Feb 2014 11:29:19 +0000 (12:29 +0100)
committerThien-Thi Nguyen <ttn@gnu.org>
Mon, 24 Feb 2014 12:31:49 +0000 (13:31 +0100)
* packages/gnugo/gnugo.el (gnugo--unclose-game): New func.
(gnugo-magic-undo): Use it.
(boardsize, clear_board, fixed_handicap):
Likewise, in the value of the ‘:post-thunk’ property.

packages/gnugo/gnugo.el

index 593aba241a6f2de7c5d5925d4c92b7d60796183c..87778648af37d10c2ec86a20a542c4b785b53850 100644 (file)
@@ -695,6 +695,19 @@ For all other values of RSEL, do nothing and return nil."
         `((live ,@live)
           (dead ,@dead))))))
 
+(defun gnugo--unclose-game ()
+  (dolist (prop '(:game-over            ; all those in -close-game
+                  :scoring-seed
+                  :game-end-time))
+    (gnugo-put prop nil))
+  (let* ((root (car (gnugo-get :sgf-gametree)))
+         (cur (assq :RE root)))
+    (when cur
+      (assert (not (eq cur (car root))) nil
+              ":RE at head of root node: %S"
+              root)
+      (delq cur root))))
+
 (defun gnugo-push-move (userp move)
   (let* ((color (gnugo-get (if userp :user-color :gnugo-color)))
          (start (gnugo-get :waiting-start))
@@ -1325,7 +1338,7 @@ turn to play.  Optional second arg NOALT non-nil inhibits this."
                  (error "%s not occupied by %s" pos u)))))
           (t (error "Bad spec: %S" spec)))
     (when (gnugo-get :game-over)
-      (gnugo-put :game-over nil))
+      (gnugo--unclose-game))
     (while (not (funcall done))
       (setq ans (cdr (gnugo-synchronous-send/return "undo")))
       (unless (= ?= (aref ans 0))
@@ -1904,7 +1917,7 @@ starting a new one.  See `gnugo-board-mode' documentation for more info."
               fixed_handicap)
       :output :discard
       :post-thunk (lambda ()
-                    (gnugo-put :game-over nil)
+                    (gnugo--unclose-game)
                     (gnugo-put :last-mover nil)
                     (gnugo-refresh t)))