[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 02/07: [gnugo frolic] Add command to prune a branch.
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 02/07: [gnugo frolic] Add command to prune a branch. |
Date: |
Wed, 09 Apr 2014 06:34:52 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 0b4bcfe9faad9efd1612fce64206d9b7ec5923c7
Author: Thien-Thi Nguyen <address@hidden>
Date: Tue Apr 8 17:04:58 2014 +0200
[gnugo frolic] Add command to prune a branch.
* packages/gnugo/gnugo.el (gnugo-frolic-prune-branch): New command.
(gnugo-frolic-mode-map): Bind ‘C-M-p’ to it.
---
packages/gnugo/gnugo.el | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index b49841b..8495bb3 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1007,6 +1007,38 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(interactive)
(gnugo--swiz nil 0))
+(defun gnugo-frolic-prune-branch ()
+ "Remove the current branch from the gametree.
+This fails if there is only one branch in the tree.
+This fails if the monkey is on the current branch
+\(a restriction that will probably be lifted Real Soon Now\)."
+ (interactive)
+ (gnugo--awakened
+ ;; todo: define meaningful eviction semantics; remove restriction
+ (when (= a bidx)
+ (user-error "Cannot prune with monkey on branch"))
+ (when (= 1 width)
+ (user-error "Cannot prune last remaining branch"))
+ ;; A numeric line number is unreliable; branch points might vanish.
+ ;; Hang on to something more useful, instead.
+ (setq line (save-excursion
+ (when (re-search-backward "^ *[0-9]+ [BW]" nil t)
+ (match-string 0))))
+ (let ((new (append ends nil)))
+ (if (zerop a)
+ (pop new)
+ (pop (nthcdr a new)))
+ (gnugo--set-tree-ends tree (apply 'vector new)))
+ (when (< a bidx)
+ (aset monkey 1 (decf bidx)))
+ (gnugo-frolic-quit)
+ (gnugo-frolic-in-the-leaves)
+ (when line
+ (goto-char (point-min))
+ (search-forward line)
+ (beginning-of-line)
+ (forward-char (+ 10 (* 6 (min a (- width 2))))))))
+
(defun gnugo-frolic-backward-branch (&optional n)
"Move backward N (default 1) branches."
(interactive "p")
@@ -2282,6 +2314,7 @@ starting a new one. See `gnugo-board-mode' documentation
for more info."
("k" . gnugo-frolic-exchange-right)
("K" . gnugo-frolic-rotate-right)
("\C-m" . gnugo-frolic-set-as-main-line)
+ ("\C-\M-p" . gnugo-frolic-prune-branch)
("o" . gnugo-frolic-return-to-origin)))
(unless gnugo-board-mode-map
- [elpa] branch master updated (bbdff36 -> cc5eff1), Thien-Thi Nguyen, 2014/04/09
- [elpa] 02/07: [gnugo frolic] Add command to prune a branch.,
Thien-Thi Nguyen <=
- [elpa] 03/07: [gnugo frolic] Handle invalid branch more consistently., Thien-Thi Nguyen, 2014/04/09
- [elpa] 04/07: [gnugo frolic int] Assign ‘pop’ rv to avoid byte-compiler warning., Thien-Thi Nguyen, 2014/04/09
- [elpa] 05/07: [gnugo frolic int] Use ‘move-to-column’ more., Thien-Thi Nguyen, 2014/04/09
- [elpa] 06/07: [gnugo frolic int] Don't go through ‘gnugo-frolic-quit’ for refresh., Thien-Thi Nguyen, 2014/04/09
- [elpa] 07/07: [gnugo int] Fix bug: Unbreak SGF file output., Thien-Thi Nguyen, 2014/04/09
- [elpa] 01/07: [gnugo frolic] Add command to set the main line., Thien-Thi Nguyen, 2014/04/09