]> code.delx.au - gnu-emacs-elpa/commitdiff
[gnugo] Make ‘C-u M-u’ switch roles.
authorThien-Thi Nguyen <ttn@gnu.org>
Tue, 11 Mar 2014 04:40:05 +0000 (05:40 +0100)
committerThien-Thi Nguyen <ttn@gnu.org>
Tue, 11 Mar 2014 04:40:21 +0000 (05:40 +0100)
* 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).

packages/gnugo/NEWS
packages/gnugo/gnugo.el

index d321bcaf39c52da9c9fbb2428f199435dd01149e..5f33ce3dc991ca4ec993cedfaa9c764cb6a848af 100644 (file)
@@ -10,6 +10,7 @@ Hint: (highlight-phrase "[0-9][.][0-9][.][0-9]+\\|[0-9]+[.][.][0-9]+"
 
 - next | NOT YET RELEASED
   - 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
index 00de3f1667b84158584ba77f74d29d4934b00a5f..3cfdabf3fa7fee2d85df3e30ee9cf31ff8c33503 100644 (file)
@@ -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-gate)
-  (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).