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

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

[elpa] 02/02: [gnugo] Make ‘C-u M-u ’ switch roles.


From: Thien-Thi Nguyen
Subject: [elpa] 02/02: [gnugo] Make ‘C-u M-u ’ switch roles.
Date: Tue, 11 Mar 2014 04:36:46 +0000

ttn pushed a commit to branch master
in repository elpa.

commit 235a70f6f675d86b65cc4daba5a5187b6ec5751b
Author: Thien-Thi Nguyen <address@hidden>
Date:   Tue Mar 11 05:40:05 2014 +0100

    [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).
---
 packages/gnugo/NEWS     |    1 +
 packages/gnugo/gnugo.el |   19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index d321bca..5f33ce3 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -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
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 00de3f1..3cfdabf 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/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-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).



reply via email to

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