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

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

[elpa] 05/08: [gnugo] On disable, transform in-flight user-move into sug


From: Thien-Thi Nguyen
Subject: [elpa] 05/08: [gnugo] On disable, transform in-flight user-move into suggestion.
Date: Wed, 23 Apr 2014 09:00:23 +0000

ttn pushed a commit to branch master
in repository elpa.

commit 55c5371f7e0bee83d242de2aaed517a273ede2dc
Author: Thien-Thi Nguyen <address@hidden>
Date:   Tue Apr 22 17:26:57 2014 +0200

    [gnugo] On disable, transform in-flight user-move into suggestion.
    
    * packages/gnugo/gnugo.el (gnugo-toggle-abdication):
    Don't signal "too soon" error; instead, transform scheduled
    user-move into a suggestion, include extra info in the
    status message and sleep for 2 sec after message display;
    update condition for ‘(gnugo-get-move gcolor)’ accordingly.
---
 packages/gnugo/gnugo.el |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 30090a9..90a2187 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -2283,21 +2283,25 @@ If COMMENT is nil or the empty string, remove the 
property entirely."
   "Toggle abdication, i.e., letting GNU Go play for you.
 When enabled, the mode line includes \"Abd\".
 Enabling signals error if the game is over.
-Disabling signals error if the color \"to play\" is the user color.
-This is to ensure that the user is the next to play after disabling."
+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')."
   (interactive)
   (let ((last-mover (gnugo-get :last-mover))
         (abd (gnugo-get :abd))
-        (warning ""))
+        xform)
     (if abd
         ;; disable
-        (let ((gcolor (gnugo-get :gnugo-color)))
-          (when (string= last-mover gcolor)
-            (gnugo--ERR-wait gcolor "Sorry, too soon"))
+        (let* ((gcolor (gnugo-get :gnugo-color))
+               (waiting (gnugo-get :waiting))
+               (userp (string= last-mover gcolor)))
+          (when (and userp waiting)
+            (gnugo--rename-buffer-portion)
+            (setcdr waiting (setq xform 'nowarp)))
           (when (timerp abd)
             (cancel-timer abd))
           (gnugo--forget :abd)
-          (unless (gnugo-get :waiting)
+          (unless (or userp waiting)
             (gnugo-get-move gcolor)))
       ;; enable
       (gnugo--gate-game-over t)
@@ -2307,7 +2311,12 @@ This is to ensure that the user is the next to play 
after disabling."
              (if (gnugo-get :abd)
                  "en"
                "dis")
-             warning)))
+             (if xform
+                 (format " (suggestion for %s forthcoming)"
+                         (gnugo-get :user-color))
+               ""))
+    (when xform
+      (sleep-for 2))))
 
 ;;;---------------------------------------------------------------------------
 ;;; Command properties and gnugo-command



reply via email to

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