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

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

[elpa] 10/13: [gnugo] Internalize ‘g nugo-magic-undo’.


From: Thien-Thi Nguyen
Subject: [elpa] 10/13: [gnugo] Internalize ‘g nugo-magic-undo’.
Date: Mon, 21 Apr 2014 21:32:10 +0000

ttn pushed a commit to branch master
in repository elpa.

commit adb78ab0f1379d49b12f88466d14e7923978cbdc
Author: Thien-Thi Nguyen <address@hidden>
Date:   Mon Apr 21 22:43:45 2014 +0200

    [gnugo] Internalize ‘gnugo-magic-undo’.
    
    * packages/gnugo/gnugo.el (gnugo--climb-towards-root):
    Rename from ‘gnugo-magic-undo’; delete docstring.
    (gnugo-undo-one-move, gnugo-undo-two-moves, gnugo-oops)
    (gnugo-fancy-undo): Use ‘gnugo--climb-towards-root’.
    (:gnugo-gtp-command-spec undo)
    (:gnugo-gtp-command-spec gg-undo): Likewise.
---
 packages/gnugo/NEWS     |    2 +-
 packages/gnugo/gnugo.el |   39 +++++++++------------------------------
 2 files changed, 10 insertions(+), 31 deletions(-)

diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index cebe790..a11e43e 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -37,7 +37,7 @@ NB: "RCS: X..Y " means that the particular release includes
     - dropped var: ‘gnugo-inhibit-refresh’ (BI)
     - ‘gnugo/sgf-read-file’ renamed to ‘gnugo/sgf-create’ and enhanced
     - ‘:sgf-gametree’ internal representation inverted (BI)
-    - ‘gnugo-magic-undo’ handles SPEC ‘0’
+    - ‘gnugo-magic-undo’ internalized
     - new func: ‘gnugo-current-player’
     - new hook: ‘gnugo-start-game-hook’
     - ‘gnugo-board-mode-hook’ now unsuitable for prop munging (BI)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 78c3f4b..ad6f15b 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1940,27 +1940,7 @@ If FILENAME already exists, Emacs confirms that you wish 
to overwrite it."
             return mem
             finally return nil))))
 
-(defun gnugo-magic-undo (spec &optional noalt keep)
-  "Undo moves on the GNUGO Board, based on SPEC, a string or number.
-If SPEC is a string in the form of a board position (e.g., \"T19\"),
-check that the position is occupied by a stone of the user's color,
-and if so, remove moves from the history until that position is clear.
-If SPEC is a positive number, remove exactly that many moves from the
-history, signaling an error if the history is exhausted before finishing.
-If SPEC Is 0 (zero), remove either one or two moves,
-so that you are to play next.
-If SPEC is not recognized, signal \"bad spec\" error.
-
-Refresh the board for each move undone.  If (in the case where SPEC is
-a number) after finishing, the color to play is not the user's color,
-schedule a move by GNU Go.
-
-After undoing the move(s), schedule a move by GNU Go if it is GNU Go's
-turn to play.  Optional second arg NOALT non-nil inhibits this.
-
-Optional third arg KEEP non-nil means do not prune the undone moves
-from the gametree, such that they become a sub-gametree (variation)
-when play resumes."
+(defun gnugo--climb-towards-root (spec &optional noalt keep)
   (gnugo-gate)
   (let* ((n 0)
          (user-color (gnugo-get :user-color))
@@ -2032,7 +2012,7 @@ See also `gnugo-undo-two-moves'."
       (gnugo--who-is-who wait play (string= play (gnugo-get :user-color)))
       (gnugo-put :user-color play)
       (gnugo-put :gnugo-color wait)))
-  (gnugo-magic-undo 1 t))
+  (gnugo--climb-towards-root 1 t))
 
 (defun gnugo-undo-two-moves ()
   "Undo a pair of moves (GNU Go's and yours).
@@ -2040,7 +2020,7 @@ However, if you are the last mover, undo only one move.
 Regardless, after undoing, it is your turn to play again."
   (interactive)
   (gnugo-gate)
-  (gnugo-magic-undo 0))
+  (gnugo--climb-towards-root 0))
 
 (defun gnugo-oops (&optional position)
   "Like `gnugo-undo-two-moves', but keep the undone moves.
@@ -2049,10 +2029,10 @@ Prefix arg means, instead, undo repeatedly up to and 
including
 the move which placed the stone at point, like `\\[gnugo-fancy-undo]'."
   (interactive "P")
   (gnugo-gate)
-  (gnugo-magic-undo (if position
-                        (gnugo-position)
-                      0)
-                    nil t))
+  (gnugo--climb-towards-root (if position
+                                 (gnugo-position)
+                               0)
+                             nil t))
 
 (defun gnugo-okay (&optional full)
   "Redo a pair of undone moves.
@@ -2243,8 +2223,7 @@ Prefix arg COUNT means to undo that many moves.
 Otherwise, undo repeatedly up to and including the move
 which placed the stone at point."
   (interactive "P")
-  (gnugo-magic-undo
-   ;; TODO: Move this into `gnugo-magic-undo' proper.
+  (gnugo--climb-towards-root
    (cond ((numberp count) count)
          ((consp count) (car count))
          (t (gnugo-position)))))
@@ -2717,7 +2696,7 @@ See `gnugo-board-mode' for a full list of commands."
         (gnugo-read-sgf-file (car sel)))
 
       (deffull (undo gg-undo)
-        (gnugo-magic-undo
+        (gnugo--climb-towards-root
          (let (n)
            (cond ((not sel) 1)
                  ((cl-plusp (setq n (string-to-number (car sel)))) n)



reply via email to

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