[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 03/07: [gnugo frolic] Handle invalid branch more consistently.
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 03/07: [gnugo frolic] Handle invalid branch more consistently. |
Date: |
Wed, 09 Apr 2014 06:34:53 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 2a1fda8030fac07ab95ccc92974003e7cf57bdb2
Author: Thien-Thi Nguyen <address@hidden>
Date: Wed Apr 9 06:41:17 2014 +0200
[gnugo frolic] Handle invalid branch more consistently.
* packages/gnugo/gnugo.el (gnugo--awake):
If ‘col’ is too big or too small, return nil for ‘a’.
(gnugo--swiz, gnugo-frolic-prune-branch):
Throw error on invalid branch.
(gnugo-frolic-backward-branch): Take invalid branch as ‘width’.
(gnugo-frolic-forward-branch): Take invalid branch as -1.
---
packages/gnugo/gnugo.el | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 8495bb3..ea37ef1 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -939,10 +939,11 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(col (current-column)))
(values tree ends width
monkey (aref monkey 1)
- line col (if (> 10 col)
- -1
- (/ (- col 10)
- 6)))))
+ line col (unless (> 10 col)
+ (let ((try (/ (- col 10)
+ 6)))
+ (unless (<= width try)
+ try))))))
(defmacro gnugo--awakened (&rest body)
`(multiple-value-bind (tree ends width
@@ -954,8 +955,8 @@ are dimmed. Type \\[describe-mode] in that buffer for
details."
(defun gnugo--swiz (direction &optional blunt)
(gnugo--awakened
- (when (> 0 a)
- (setq a bidx))
+ (unless a
+ (user-error "No branch here"))
(let* ((b (cond ((numberp blunt)
(unless (and (< -1 blunt)
(< blunt width))
@@ -1014,6 +1015,8 @@ This fails if the monkey is on the current branch
\(a restriction that will probably be lifted Real Soon Now\)."
(interactive)
(gnugo--awakened
+ (unless a
+ (user-error "No branch here"))
;; todo: define meaningful eviction semantics; remove restriction
(when (= a bidx)
(user-error "Cannot prune with monkey on branch"))
@@ -1043,13 +1046,13 @@ This fails if the monkey is on the current branch
"Move backward N (default 1) branches."
(interactive "p")
(gnugo--awakened
- (move-to-column (+ 10 (* 6 (mod (- a n) width))))))
+ (move-to-column (+ 10 (* 6 (mod (- (or a width) n) width))))))
(defun gnugo-frolic-forward-branch (&optional n)
"Move forward N (default 1) branches."
(interactive "p")
(gnugo--awakened
- (move-to-column (+ 10 (* 6 (mod (+ a n) width))))))
+ (move-to-column (+ 10 (* 6 (mod (+ (or a -1) n) width))))))
(defun gnugo-boss-is-near ()
"Do `bury-buffer' until the current one is not a GNU Board."
- [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, 2014/04/09
- [elpa] 03/07: [gnugo frolic] Handle invalid branch more consistently.,
Thien-Thi Nguyen <=
- [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