[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 7114ed6 234/357: [gnugo int] Add abstraction: gnu
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 7114ed6 234/357: [gnugo int] Add abstraction: gnugo--mem-with-played-stone |
Date: |
Sun, 29 Nov 2020 14:51:29 -0500 (EST) |
branch: externals/gnugo
commit 7114ed66c838abb603436f062c258375c415f66c
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Add abstraction: gnugo--mem-with-played-stone
* packages/gnugo/gnugo.el (gnugo--mem-with-played-stone): New func.
(gnugo--node-with-played-stone): Use it; convert to defsubst.
---
gnugo.el | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 10e29e2..52aeb84 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1929,6 +1929,17 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
(set-buffer-modified-p nil)
(gnugo--who-is-who wait play samep)))
+(defun gnugo--mem-with-played-stone (pos)
+ (let ((color (case (following-char)
+ (?X :B)
+ (?O :W))))
+ (when color
+ (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
+ for mem on (aref (gnugo-get :monkey) 0)
+ when (equal fruit (caar mem))
+ 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\"),
@@ -2244,16 +2255,8 @@ which placed the stone at point."
(gnugo-toggle-image-display)
(save-excursion (gnugo-refresh)))
-(defun gnugo--node-with-played-stone (pos)
- (let ((color (case (following-char)
- (?X :B)
- (?O :W))))
- (when color
- (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
- for node in (aref (gnugo-get :monkey) 0)
- if (equal fruit (car node))
- return node
- finally return nil))))
+(defsubst gnugo--node-with-played-stone (pos)
+ (car (gnugo--mem-with-played-stone pos)))
(defun gnugo-describe-position ()
"Display the board position under cursor in the echo area.
- [elpa] externals/gnugo 32e8547 199/357: [gnugo int] Add abstraction: gnugo--user-play, (continued)
- [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
- [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 <=
- [elpa] externals/gnugo 9ae1363 236/357: [gnugo] Internalize ‘gnugo-magic-undo’., Stefan Monnier, 2020/11/29
- [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