[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo e64f1ae 170/357: [gnugo frolic] Add previous/next
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo e64f1ae 170/357: [gnugo frolic] Add previous/next move navigation commands. |
Date: |
Sun, 29 Nov 2020 14:51:14 -0500 (EST) |
branch: externals/gnugo
commit e64f1aef3688fd8c272c6d02f506d3cf53d6b394
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo frolic] Add previous/next move navigation commands.
* packages/gnugo/gnugo.el (gnugo-frolic-in-the-leaves fsi):
Take first arg PROPERTIES, pushing other args later;
use them to ‘propertize’ the formatted string.
(gnugo-frolic-in-the-leaves): Propertize "move" lines
w/ property ‘n’, column text additionally w/ property ‘bx’.
(gnugo--vertical): New func.
(gnugo-frolic-previous-move): New command.
(gnugo-frolic-next-move): Likewise.
(gnugo-frolic-mode-map): Add bindings for ‘C-p’, ‘C-n’.
---
gnugo.el | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index d1e811d..05c05b5 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -799,8 +799,10 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(gethash node seen))
(emph (s face)
(propertize s 'face face))
- (fsi (fmt &rest args)
- (insert (apply 'format fmt args))))
+ (fsi (properties fmt &rest args)
+ (insert (apply 'propertize
+ (apply 'format fmt args)
+ properties))))
;; breathe in
(loop
for bx below width
@@ -857,14 +859,17 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(set (make-local-variable 'gnugo-state)
(buffer-local-value 'gnugo-state from))
(loop
+ with props
for n ; move number
from max-move-num downto 1
+ do (setq props (list 'n n))
do
(loop
with (move forks br)
initially (progn
(goto-char (point-min))
- (fsi "%3d %s -- "
+ (fsi props
+ "%3d %s -- "
n (aref ["W" "B"] (logand 1 n))))
for bx below width
do (let* ((node (unless (< (aref valid bx) n)
@@ -878,7 +883,8 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(when (and ok (setq br (gethash node soil)))
(push (cons bx (sort br '<))
forks))
- (fsi " %-5s"
+ (fsi (list* 'bx bx props)
+ " %-5s"
(cond ((and (eq at node)
(or ok (= bx bidx)))
(when (= bx bidx)
@@ -890,7 +896,7 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(emph s dimmed-node-face))
(t s))))
finally do
- (when (progn (newline)
+ (when (progn (fsi props "\n")
(setq forks (nreverse forks)))
(let* ((margin (make-string 11 ?\s))
(heads (mapcar #'car forks))
@@ -1102,6 +1108,38 @@ This fails if the monkey is on the current branch
(interactive "p")
(gnugo--sideways nil n))
+(defun gnugo--vertical (n direction)
+ (when (> 0 n)
+ (setq n (- n)
+ direction (- direction)))
+ (gnugo--awakened ((line . numeric)
+ (omit tree ends monkey bidx))
+ (let ((stop (if (> 0 direction)
+ 0
+ (max 0 (1- (count-lines (point-min)
+ (point-max))))))
+ (col (unless a
+ (current-column))))
+ (loop while (not (= line stop))
+ do (loop do (progn
+ (forward-line direction)
+ (incf line direction))
+ until (get-text-property (point) 'n))
+ until (zerop (decf n)))
+ (if a
+ (gnugo--move-to-bcol a)
+ (move-to-column col)))))
+
+(defun gnugo-frolic-previous-move (&optional n)
+ "Move to the Nth (default 1) previous move."
+ (interactive "p")
+ (gnugo--vertical n -1))
+
+(defun gnugo-frolic-next-move (&optional n)
+ "Move to the Nth (default 1) next move."
+ (interactive "p")
+ (gnugo--vertical n 1))
+
(defun gnugo-boss-is-near ()
"Do `bury-buffer' until the current one is not a GNU Board."
(interactive)
@@ -2389,6 +2427,8 @@ starting a new one. See `gnugo-board-mode' documentation
for more info."
("C" . gnugo-frolic-quit) ; like ‘View-kill-and-leave’
("\C-b" . gnugo-frolic-backward-branch)
("\C-f" . gnugo-frolic-forward-branch)
+ ("\C-p" . gnugo-frolic-previous-move)
+ ("\C-n" . gnugo-frolic-next-move)
("j" . gnugo-frolic-exchange-left)
("J" . gnugo-frolic-rotate-left)
("k" . gnugo-frolic-exchange-right)
- [elpa] externals/gnugo 7c3a30f 100/357: [gnugo int] Use ‘pop’ more., (continued)
- [elpa] externals/gnugo 7c3a30f 100/357: [gnugo int] Use ‘pop’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a35692a 106/357: [gnugo int] Add abstraction: gnugo--move-prop, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6ee477d 112/357: [gnugo int] Remove abstraction: continue-on, Stefan Monnier, 2020/11/29
- [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 <=
- [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, 2020/11/29
- [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