[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo bc4abdc 238/357: [gnugo int] Centralize some "No
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo bc4abdc 238/357: [gnugo int] Centralize some "No stone at POS" errors. |
Date: |
Sun, 29 Nov 2020 14:51:30 -0500 (EST) |
branch: externals/gnugo
commit bc4abdcec1d5135b90607b05a92b8bad4f61c7ea
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[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.
---
gnugo.el | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 8cf2a7c..d926725 100644
--- a/gnugo.el
+++ b/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] externals/gnugo 8a064c5 184/357: [gnugo int] Incorporate *-play-stone into ‘gnugo-push-move’., (continued)
- [elpa] externals/gnugo 8a064c5 184/357: [gnugo int] Incorporate *-play-stone into ‘gnugo-push-move’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo ee09531 192/357: [gnugo] New command: ‘S’ (gnugo-request-suggestion), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo bc92d6d 202/357: [gnugo frolic] Type ‘Q’ to quit., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a3baa99 200/357: [gnugo int] Use ‘following-char’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e644695 203/357: [gnugo] Increase S/N for ‘C-u F’ comment., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7b29f73 219/357: [gnugo int] Decruft: Don't stash :proc-args., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 12d3d80 216/357: [gnugo] Keep GNUGO Board buffer read-only., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 4b6e204 221/357: [gnugo int] Move some prop jamming to ‘gnugo-board-mode’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d52bbc7 222/357: [gnugo int] Add abstraction: gnugo--nquery, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e837853 226/357: [gnugo int] Declare ‘lexical-binding: t’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo bc4abdc 238/357: [gnugo int] Centralize some "No stone at POS" errors.,
Stefan Monnier <=
- [elpa] externals/gnugo 78edde4 247/357: [gnugo maint] Update HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 52251ac 270/357: [gnugo int] Move karma state normalization down-chain., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5a201a8 286/357: [gnugo] Fix bug: For GTP "help COMMAND", leave point in right place., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3540673 272/357: [gnugo] Make SGF I/O commands change ‘default-directory’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo ac1adcd 276/357: [gnugo] Make ‘gnugo-xpms’ a normal var; drop it as feature., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 079b73c 279/357: [gnugo int] Commentary munging; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo de92f27 296/357: [gnugo imgen] Add autoload cookie., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7db9d5e 295/357: [gnugo] Declare package keywords., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo ab69d4b 294/357: [gnugo frolic] Promote frolic mode/funcs to feature., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 91f2d79 318/357: [gnugo int] Avoid latent order-of-evaluation error., Stefan Monnier, 2020/11/29