[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 9ae1363 236/357: [gnugo] Internalize ‘gnugo-magi
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 9ae1363 236/357: [gnugo] Internalize ‘gnugo-magic-undo’. |
Date: |
Sun, 29 Nov 2020 14:51:29 -0500 (EST) |
branch: externals/gnugo
commit 9ae13631f0e390216d02145636ea627a19cc28b2
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[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.
---
NEWS | 2 +-
gnugo.el | 39 +++++++++------------------------------
2 files changed, 10 insertions(+), 31 deletions(-)
diff --git a/NEWS b/NEWS
index cebe790..a11e43e 100644
--- a/NEWS
+++ b/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/gnugo.el b/gnugo.el
index 78c3f4b..ad6f15b 100644
--- a/gnugo.el
+++ b/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)
- [elpa] externals/gnugo 001228c 205/357: [gnugo] Drop support for ‘(gnugo-move-history 'count)’., (continued)
- [elpa] externals/gnugo 001228c 205/357: [gnugo] Drop support for ‘(gnugo-move-history 'count)’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 106a279 211/357: [gnugo int] Consolidate paren overlays access., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 17d907d 210/357: [gnugo int] Shave one ‘gnugo-other’ call., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1d6b241 214/357: [gnugo] Use ‘define-derived-mode’ for GNUGO Board mode., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 167ba89 213/357: [gnugo int] Decruft: Streamline game-over handling on SGF load., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b3d3da0 220/357: [gnugo int] Use functional style more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e96b88b 218/357: [gnugo] Decruft: Use ‘gnugo-program’ directly as executable., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3670b0b 228/357: [gnugo] On SGF load, leave cursor at last user board position., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1020a7f 237/357: [gnugo int] Simplify towards-root loop termination check., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7114ed6 234/357: [gnugo int] Add abstraction: gnugo--mem-with-played-stone, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9ae1363 236/357: [gnugo] Internalize ‘gnugo-magic-undo’.,
Stefan Monnier <=
- [elpa] externals/gnugo a92e184 255/357: fixup! [gnugo int] Decorate w/ plist instead of alist., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 71e1500 245/357: [gnugo] Fix bug: Use ‘gnugo-gate’ for abdication enable., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 46f49e3 246/357: [gnugo int] Use ‘gnugo-current-player’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 443903e 249/357: [gnugo int] Drop abstraction: pretty, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a0ecdea 257/357: [gnugo] Conditionalize xform warping on abdication disable., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 85e3d91 253/357: [gnugo int] Snoop ‘--handicap N’ for empty new board., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7c7d43c 261/357: [gnugo int] Avoid superfluous ‘gnugo-other’ call., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6ddf38f 269/357: [gnugo int] Add abstraction: gnugo--assist-state, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d48adca 244/357: [gnugo] On disable, transform in-flight user-move into suggestion., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 764251b 259/357: [gnugo int] Fix bug: Use correct color for "Not your turn yet"., Stefan Monnier, 2020/11/29