[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 02/03: [gnugo int] Add abstraction: gnugo--assist-state
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 02/03: [gnugo int] Add abstraction: gnugo--assist-state |
Date: |
Wed, 30 Apr 2014 07:30:57 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 5f70f776c4809d8614f6f109268c198e6e10f975
Author: Thien-Thi Nguyen <address@hidden>
Date: Wed Apr 30 09:29:48 2014 +0200
[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.
---
packages/gnugo/gnugo.el | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 9159925..d453d78 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1732,6 +1732,13 @@ cursor to the suggested position. Prefix arg inhibits
warp."
(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)
(gnugo-gate)
- (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')."
:variable
- ((gnugo--:karma :user-color)
+ ((gnugo--assist-state)
.
(lambda (bool)
(gnugo--struggle :user-color bool))))