[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 5dcf9f6 185/357: [gnugo int] Add abstraction: gnu
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 5dcf9f6 185/357: [gnugo int] Add abstraction: gnugo--node-with-played-stone |
Date: |
Sun, 29 Nov 2020 14:51:18 -0500 (EST) |
branch: externals/gnugo
commit 5dcf9f6ac6d2baac88f6da87b6aa4f6aca144145
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Add abstraction: gnugo--node-with-played-stone
* packages/gnugo/gnugo.el (gnugo--node-with-played-stone): New func.
(gnugo-describe-position): Use ‘gnugo--node-with-played-stone’.
---
gnugo.el | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index bd1437a..7c52087 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -2126,30 +2126,30 @@ 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))))
+
(defun gnugo-describe-position ()
"Display the board position under cursor in the echo area.
If there a stone at that position, also display its move number."
(interactive)
- (let ((pos (gnugo-position)) ; do first (can throw)
- (color (case (following-char)
- (?X :B)
- (?O :W))))
+ (let* ((pos (gnugo-position)) ; do first (can throw)
+ (node (gnugo--node-with-played-stone pos)))
(message
"%s%s" pos
- (or (when color
- (loop
- with monkey = (gnugo-get :monkey)
- with tree = (gnugo-get :sgf-gametree)
- with mnum = (gnugo--tree-mnum tree)
- with as-cc = (gnugo--as-cc-func)
- with fruit = (cons color (funcall as-cc pos))
- for node in (aref monkey 0)
- if (member fruit node)
- return
- (format " (move %d)"
- (gethash node mnum))
- finally return
- nil))
+ (or (when node
+ (let* ((tree (gnugo-get :sgf-gametree))
+ (mnum (gnugo--tree-mnum tree))
+ (move-num (gethash node mnum)))
+ (format " (move %d)" move-num)))
""))))
(defun gnugo-switch-to-another ()
- [elpa] externals/gnugo 58d4d6d 117/357: [gnugo int] Add abstractions: gnugo--{, set-}tree-ends, (continued)
- [elpa] externals/gnugo 58d4d6d 117/357: [gnugo int] Add abstractions: gnugo--{, set-}tree-ends, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f107328 122/357: [gnugo int] Expand gametree IR: MNUM, KIDS, ROOT., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c3b3c3f 123/357: [gnugo int] Fix bug: Detect case for KIDS addition correctly., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a63d31b 128/357: [gnugo int] Comment munging; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3a7f75e 132/357: [gnugo] Define "GNUGO Frolic" mode., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo cb78651 138/357: [gnugo frolic] Add command to prune a branch., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7025924 156/357: [gnugo sgf] Fix bug: Add ‘\’-escapes on write., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e64f1ae 170/357: [gnugo frolic] Add previous/next move navigation commands., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c78119f 191/357: [gnugo int] Add abstraction: gnugo--finish-move, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a3d90aa 189/357: [gnugo maint] Update HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5dcf9f6 185/357: [gnugo int] Add abstraction: gnugo--node-with-played-stone,
Stefan Monnier <=
- [elpa] externals/gnugo 1367651 173/357: [gnugo int] Make ‘gnugo-gate’ slightly faster., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a4c246e 188/357: [gnugo frolic] Display "!" for comment; add as ‘help-echo’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8203f46 194/357: [gnugo int] Centralize some constant strings., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b1f2856 183/357: [gnugo] Fix bug: Keep subproc informed of forced PASS., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3112192 056/357: [gnugo int] Streamline subproc (de-)marshalling., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 294bdc1 047/357: [gnugo maint] Update NEWS; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b5f47cb 059/357: [gnugo int] Use ‘pcase’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8cabdfa 042/357: [gnugo int] Use internal macros more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b484515 064/357: [gnugo int] Use ‘loop’, functional style more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a7dffa0 067/357: [gnugo maint] Update NEWS; nfc., Stefan Monnier, 2020/11/29