[Top][All Lists]

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

[elpa] externals/gnugo 8e3f44e 070/357: [gnugo] Make ‘C-u M-u’ switch r

From: Stefan Monnier
Subject: [elpa] externals/gnugo 8e3f44e 070/357: [gnugo] Make ‘C-u M-u’ switch roles.
Date: Sun, 29 Nov 2020 14:50:51 -0500 (EST)

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

    [gnugo] Make ‘C-u M-u’ switch roles.
    * packages/gnugo/gnugo.el (gnugo-undo-one-move):
    Add optional arg SWITCH; if specified, arrange for user
    to play the color of the next move (and GNU Go the opposite).
 NEWS     |  1 +
 gnugo.el | 19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index d321bca..5f33ce3 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Hint: (highlight-phrase 
   - new keybinding for ‘gnugo-undo-one-move’: M-u
+  - ‘gnugo-undo-one-move’ can optionally switch colors
   - performance improvements
 - 2.3.1 | 2014-02-27
diff --git a/gnugo.el b/gnugo.el
index 00de3f1..3cfdabf 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1415,13 +1415,26 @@ turn to play.  Optional second arg NOALT non-nil 
inhibits this."
       (when (and ulastp (not noalt))
         (gnugo-get-move (gnugo-get :gnugo-color))))))
-(defun gnugo-undo-one-move ()
+(defun gnugo-undo-one-move (&optional switch)
   "Undo exactly one move (perhaps GNU Go's, perhaps yours).
 Do not schedule a move by GNU Go even if it is GNU Go's turn to play.
+Prefix arg SWITCH means to arrange for you to play
+the color of the next move (and GNU Go the opposite).
+This is useful after loading an SGF file whose last
+move was done by the color you prefer to play:
+ \\[gnugo-read-sgf-file] FILENAME RET
+ C-u \\[gnugo-undo-one-move]
 See also `gnugo-undo-two-moves'."
-  (interactive)
+  (interactive "P")
-  (gnugo-magic-undo 1 t))
+  (gnugo-magic-undo 1 t)
+  (when switch
+    (let* ((wait (gnugo-get :last-mover))
+           (play (gnugo-other wait)))
+      (gnugo--who-is-who wait play (string= play (gnugo-get :user-color)))
+      (gnugo-put :user-color play)
+      (gnugo-put :gnugo-color wait))))
 (defun gnugo-undo-two-moves ()
   "Undo a pair of moves (GNU Go's and yours).

reply via email to

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