[Top][All Lists]

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

[elpa] externals/gnugo 6ddf38f 269/357: [gnugo int] Add abstraction: gnu

From: Stefan Monnier
Subject: [elpa] externals/gnugo 6ddf38f 269/357: [gnugo int] Add abstraction: gnugo--assist-state
Date: Sun, 29 Nov 2020 14:51:37 -0500 (EST)

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

    [gnugo int] Add abstraction: gnugo--assist-state
    * packages/gnugo/gnugo.el (gnugo--assist-state): New func.
    (gnugo--climb-towards-root, gnugo-assist-mode): Use it.
 gnugo.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 9159925..d453d78 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1732,6 +1732,13 @@ cursor to the suggested position.  Prefix arg inhibits 
 (defsubst gnugo--:karma (role)
   (gnugo--karma (gnugo-get role)))
+(defun gnugo--assist-state (&optional gate)
+  (let ((bool (when (gnugo--:karma :user-color)
+                t)))
+    (if (and bool gate)
+        (user-error "Sorry, Assist mode enabled")
+      bool)))
 (defun gnugo--user-play (pos-or-pass)
   (gnugo-gate t)
   ;; The "user" in this func's name used to signify both
@@ -1996,8 +2003,7 @@ If FILENAME already exists, Emacs confirms that you wish 
to overwrite it."
 (defun gnugo--climb-towards-root (spec &optional noalt keep)
-  (when (gnugo--:karma :user-color)
-    (user-error "Sorry, Assist mode enabled"))
+  (gnugo--assist-state t)
   (let* ((user-color (gnugo-get :user-color))
          (monkey (gnugo-get :monkey))
          (tree (gnugo-get :sgf-gametree))
@@ -2378,7 +2384,7 @@ When disabling, if GNU Go has already started thinking of
 a move to play for you, the thinking is not cancelled but instead
 transformed into a move suggestion (see `gnugo-request-suggestion')."
-  ((gnugo--:karma :user-color)
+  ((gnugo--assist-state)
    (lambda (bool)
      (gnugo--struggle :user-color bool))))

reply via email to

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