[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 12/13: [gnugo int] Centralize some "No stone at POS" errors.
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 12/13: [gnugo int] Centralize some "No stone at POS" errors. |
Date: |
Mon, 21 Apr 2014 21:32:10 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 0c2a2563c95908337174c9a3b0f660a9bd90ee85
Author: Thien-Thi Nguyen <address@hidden>
Date: Mon Apr 21 23:19:12 2014 +0200
[gnugo int] Centralize some "No stone at POS" errors.
* packages/gnugo/gnugo.el (gnugo--mem-with-played-stone):
Take optional arg NOERROR; if clear, when no ‘color’
found, signal "No stone at POS" error.
(gnugo--climb-towards-root): Drop "POS already clear" error
handling; use ‘gnugo--mem-with-played-stone’ rv directly.
(gnugo--node-with-played-stone): Take optional arg NOERROR;
pass it to ‘gnugo--mem-with-played-stone’.
(gnugo-describe-position): Specify
NOERROR to ‘gnugo--node-with-played-stone’.
(gnugo-comment): Drop "No stone at POS" error handling;
use ‘gnugo--node-with-played-stone’ rv directly.
---
packages/gnugo/gnugo.el | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 8cf2a7c..d926725 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1929,11 +1929,13 @@ If FILENAME already exists, Emacs confirms that you
wish to overwrite it."
(set-buffer-modified-p nil)
(gnugo--who-is-who wait play samep)))
-(defun gnugo--mem-with-played-stone (pos)
+(defun gnugo--mem-with-played-stone (pos &optional noerror)
(let ((color (case (following-char)
(?X :B)
(?O :W))))
- (when color
+ (if (not color)
+ (unless noerror
+ (user-error "No stone at %s" pos))
(loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
for mem on (aref (gnugo-get :monkey) 0)
when (equal fruit (caar mem))
@@ -1956,8 +1958,7 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
spec)
(aref monkey 0))
(let* ((pos spec)
- (hmm (or (gnugo--mem-with-played-stone pos)
- (user-error "%s already clear" pos))))
+ (hmm (gnugo--mem-with-played-stone pos)))
;; todo: relax ‘gnugo--user-play’ then lift restriction
(unless (eq (gnugo--prop<-color user-color)
(car (gnugo--move-prop (car hmm))))
@@ -2226,15 +2227,15 @@ which placed the stone at point."
(gnugo-toggle-image-display)
(save-excursion (gnugo-refresh)))
-(defsubst gnugo--node-with-played-stone (pos)
- (car (gnugo--mem-with-played-stone pos)))
+(defsubst gnugo--node-with-played-stone (pos &optional noerror)
+ (car (gnugo--mem-with-played-stone pos noerror)))
(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)
- (node (gnugo--node-with-played-stone pos)))
+ (node (gnugo--node-with-played-stone pos t)))
(message
"%s%s" pos
(or (when node
@@ -2263,8 +2264,7 @@ initial-input (see `read-string').
If COMMENT is nil or the empty string, remove the property entirely."
(interactive
(let* ((pos (gnugo-position))
- (node (or (gnugo--node-with-played-stone pos)
- (user-error "No stone at %s" pos))))
+ (node (gnugo--node-with-played-stone pos)))
(list node
(read-string (format "Comment for %s: "
(gnugo-describe-position))
- [elpa] 03/13: [gnugo int] Fix bug: On -l/--infile, don't set :last-mover., (continued)
- [elpa] 03/13: [gnugo int] Fix bug: On -l/--infile, don't set :last-mover., Thien-Thi Nguyen, 2014/04/21
- [elpa] 04/13: [gnugo int] Fix bug: On -l/--infile, inhibit first move if game over., Thien-Thi Nguyen, 2014/04/21
- [elpa] 05/13: [gnugo] Fix bug: DTRT for :last-user-bpos in undo-one-move ME-NEXT., Thien-Thi Nguyen, 2014/04/21
- [elpa] 06/13: [gnugo] Reduce modifier key bouncing for "quick peek" frolics., Thien-Thi Nguyen, 2014/04/21
- [elpa] 09/13: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’., Thien-Thi Nguyen, 2014/04/21
- [elpa] 08/13: [gnugo int] Add abstraction: gnugo--mem-with-played-stone, Thien-Thi Nguyen, 2014/04/21
- [elpa] 07/13: [gnugo int] Add abstraction: gnugo--q/ue, Thien-Thi Nguyen, 2014/04/21
- [elpa] 10/13: [gnugo] Internalize ‘g nugo-magic-undo’., Thien-Thi Nguyen, 2014/04/21
- [elpa] 11/13: [gnugo int] Simplify towards-root loop termination check., Thien-Thi Nguyen, 2014/04/21
- [elpa] 13/13: [gnugo int] Move ‘gnug o-position’ call down-chain., Thien-Thi Nguyen, 2014/04/21
- [elpa] 12/13: [gnugo int] Centralize some "No stone at POS" errors.,
Thien-Thi Nguyen <=
- [elpa] 02/13: [gnugo] On SGF load, leave cursor at last user board position., Thien-Thi Nguyen, 2014/04/21