[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 1ac646f 172/357: [gnugo] New command: ‘O’ (gnugo
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 1ac646f 172/357: [gnugo] New command: ‘O’ (gnugo-okay) |
Date: |
Sun, 29 Nov 2020 14:51:15 -0500 (EST) |
branch: externals/gnugo
commit 1ac646f85b922f2e77f05a1a8d7541d59a361c09
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo] New command: ‘O’ (gnugo-okay)
* packages/gnugo/gnugo.el (gnugo-okay): New command.
(gnugo-board-mode-map): Add binding for ‘O’.
---
NEWS | 1 +
gnugo.el | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/NEWS b/NEWS
index 99340b7..4c39fde 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ NB: "RCS: X..Y " means that the particular release includes
- new keybinding for ‘gnugo-undo-one-move’: M-u
- ‘gnugo-undo-one-move’ can optionally arrange for you to play next
- new command: ‘o’ (gnugo-oops)
+ - new command: ‘O’ (gnugo-okay)
- new command: ‘L’ (gnugo-frolic-in-the-leaves)
- new major mode: GNUGO Frolic (gnugo-frolic-mode)
- ‘gnugo-move-history’ returns last two moves w/ RSEL ‘two’
diff --git a/gnugo.el b/gnugo.el
index 2afca86..4f00a34 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1996,6 +1996,53 @@ the move which placed the stone at point, like
`\\[gnugo-fancy-undo]'."
0)
nil t))
+(defun gnugo-okay (&optional full)
+ "Redo a pair of undone moves.
+Prefix arg means to redo all the undone moves."
+ (interactive "P")
+ (gnugo-gate)
+ (let* ((tree (gnugo-get :sgf-gametree))
+ (ends (gnugo--tree-ends tree))
+ (monkey (gnugo-get :monkey)))
+ (if (gnugo--no-regrets monkey ends)
+ (message "Oop ack!")
+ (let* ((as-pos (gnugo--as-pos-func))
+ (mnum (gnugo--tree-mnum tree))
+ (mem (aref monkey 0))
+ (bidx (aref monkey 1))
+ (end (aref ends bidx))
+ (ucolor (gnugo-get :user-color))
+ (gcolor (gnugo-other ucolor))
+ (uprop (if (gnugo--blackp ucolor)
+ :B :W)))
+ (cl-flet ((mvno (node) (gethash node mnum)))
+ (loop
+ with ok = (if full
+ (mvno (car end))
+ (+ 2 (mvno (car mem))))
+ with (node move todo)
+ for ls on end
+ do (progn
+ (setq node (car ls)
+ move (gnugo--move-prop node))
+ (when (and move (>= ok (mvno node)))
+ (let ((userp (eq uprop (car move))))
+ (push (list (if userp ucolor gcolor)
+ userp
+ (funcall as-pos (cdr move)))
+ todo))))
+ until (eq mem (cdr ls))
+ finally do
+ (loop
+ for (color userp pos) in todo
+ do (let* ((move (format "play %s %s" color pos))
+ (accept (gnugo--q move)))
+ (unless (= ?= (aref accept 0))
+ (user-error "%s" accept))
+ (gnugo-push-move userp pos)
+ (gnugo-refresh)
+ (redisplay)))))))))
+
(defun gnugo-display-final-score ()
"Display final score and other info in another buffer (when game over).
If the game is still ongoing, Emacs asks if you wish to stop play (by
@@ -2454,6 +2501,7 @@ starting a new one. See `gnugo-board-mode' documentation
for more info."
("u" . gnugo-undo-two-moves)
("\C-?" . gnugo-undo-two-moves)
("o" . gnugo-oops)
+ ("O" . gnugo-okay)
("\C-l" . gnugo-refresh)
("\M-_" . gnugo-boss-is-near)
("_" . gnugo-boss-is-near)
- [elpa] externals/gnugo c6795aa 140/357: [gnugo frolic int] Assign ‘pop’ rv to avoid byte-compiler warning., (continued)
- [elpa] externals/gnugo c6795aa 140/357: [gnugo frolic int] Assign ‘pop’ rv to avoid byte-compiler warning., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 13c8f82 149/357: [gnugo frolic] Doc fix., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo de40b22 152/357: [gnugo int] Move vectorization into ‘gnugo--set-tree-ends’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e8833a9 161/357: [gnugo int] Fix syntax error in ‘loop’ destructuring., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3e3fbea 155/357: [gnugo sgf] Fix bug: Preserve whitespace for ‘text’ values., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 0f3f4b6 165/357: [gnugo int] Use ‘ignore’ to avoid byte-compiler warnings., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 082d56c 178/357: [gnugo int] Use ‘gnugo--decorate’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e382633 190/357: [gnugo] Drop var: gnugo-inhibit-refresh, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo dd6b6f8 186/357: [gnugo] New command: ‘C’ (gnugo-comment), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo cba406b 176/357: [gnugo] Include root node in :sgf-gametree description., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1ac646f 172/357: [gnugo] New command: ‘O’ (gnugo-okay),
Stefan Monnier <=
- [elpa] externals/gnugo 3f13bbf 168/357: [gnugo] Make ‘=’ also display move number., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f3c90cd 187/357: [gnugo] Make ‘C-u F’ add the blurb as a comment to the last node., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo bcc912b 164/357: [gnugo frolic int] Add var selection to awakening parameterization., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 66c29d0 197/357: [gnugo int] Add abstraction: gnugo--gate-game-over, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5bbec0e 179/357: [gnugo int] Incorporate ‘gnugo-note’ into unique caller., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 82b6000 198/357: [gnugo] Mention ‘gnugo-frolic-mode-hook’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 32e8547 199/357: [gnugo int] Add abstraction: gnugo--user-play, Stefan Monnier, 2020/11/29
- [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