[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 04/04: [gnugo] Make ‘=’ als o display move number.
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 04/04: [gnugo] Make ‘=’ als o display move number. |
Date: |
Sat, 12 Apr 2014 10:27:40 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 3a59e3eef74bf498448b473889ef691e2e5c6b9e
Author: Thien-Thi Nguyen <address@hidden>
Date: Sat Apr 12 12:31:47 2014 +0200
[gnugo] Make ‘=’ also display move number.
* packages/gnugo/gnugo.el (gnugo-describe-position):
If there a stone at that position, also display its move number.
---
packages/gnugo/NEWS | 1 +
packages/gnugo/gnugo.el | 25 +++++++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index f0148f6..99340b7 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -15,6 +15,7 @@ NB: "RCS: X..Y " means that the particular release includes
- avoid clobbering SGF property ‘EV’ on resignation
- follow main line in subtrees on read
- PASS for SZ <= 19 normalized to "" on read, written as ""
+ - ‘=’ also displays move number of the stone (if any) at that position
- 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)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 3b7b326..93ed2f3 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -2100,9 +2100,30 @@ which placed the stone at point."
(save-excursion (gnugo-refresh)))
(defun gnugo-describe-position ()
- "Display the board position under cursor in the echo area."
+ "Display the board position under cursor in the echo area.
+If there a stone at that position, also display its move number."
(interactive)
- (message "%s" (gnugo-position)))
+ (let ((pos (gnugo-position)) ; do first (can throw)
+ (color (case (following-char)
+ (?X :B)
+ (?O :W))))
+ (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))
+ ""))))
(defun gnugo-switch-to-another ()
"Switch to another GNU Go game buffer (if any)."