emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/gnugo 32e8547 199/357: [gnugo int] Add abstraction: gnu


From: Stefan Monnier
Subject: [elpa] externals/gnugo 32e8547 199/357: [gnugo int] Add abstraction: gnugo--user-play
Date: Sun, 29 Nov 2020 14:51:21 -0500 (EST)

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

    [gnugo int] Add abstraction: gnugo--user-play
    
    * packages/gnugo/gnugo.el (gnugo--user-play): New func.
    (gnugo-move, gnugo-pass): Use ‘gnugo--user-play’.
---
 gnugo.el | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index b58ff35..f3952a6 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1667,19 +1667,22 @@ cursor to the suggested position.  Prefix arg inhibits 
warp."
                       'nowarp
                     t)))
 
+(defun gnugo--user-play (pos-or-pass)
+  (gnugo-gate t)
+  (let ((donep (gnugo-push-move t pos-or-pass))
+        (buf (current-buffer)))
+    (gnugo--finish-move buf)
+    (unless donep
+      (with-current-buffer buf
+        (gnugo-get-move (gnugo-get :gnugo-color))))))
+
 (defun gnugo-move ()
   "Make a move on the GNUGO Board buffer.
 The position is computed from current point.
 Signal error if done out-of-turn or if game-over.
 To start a game try M-x gnugo."
   (interactive)
-  (gnugo-gate t)
-  (let* ((buf (current-buffer))
-         (pos (gnugo-position)))
-    (gnugo-push-move t pos)             ; value always nil for non-pass move
-    (gnugo--finish-move buf)
-    (with-current-buffer buf
-      (gnugo-get-move (gnugo-get :gnugo-color)))))
+  (gnugo--user-play (gnugo-position)))
 
 (defun gnugo-mouse-move (e)
   "Do `gnugo-move' at mouse location."
@@ -1693,13 +1696,7 @@ To start a game try M-x gnugo."
 Signal error if done out-of-turn or if game-over.
 To start a game try M-x gnugo."
   (interactive)
-  (gnugo-gate t)
-  (let ((donep (gnugo-push-move t "PASS"))
-        (buf (current-buffer)))
-    (gnugo--finish-move buf)
-    (unless donep
-      (with-current-buffer buf
-        (gnugo-get-move (gnugo-get :gnugo-color))))))
+  (gnugo--user-play "PASS"))
 
 (defun gnugo-mouse-pass (e)
   "Do `gnugo-pass' at mouse location."



reply via email to

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