[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 09/13: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg
From: |
Thien-Thi Nguyen |
Subject: |
[elpa] 09/13: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’. |
Date: |
Mon, 21 Apr 2014 21:32:10 +0000 |
ttn pushed a commit to branch master
in repository elpa.
commit 8022914d3455ebc99d422a4b8e2285e8ba55a931
Author: Thien-Thi Nguyen <address@hidden>
Date: Mon Apr 21 22:25:27 2014 +0200
[gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’.
* packages/gnugo/gnugo.el
(:gnugo-gtp-command-spec validpos): New internal func.
(:gnugo-gtp-command-spec undo)
(:gnugo-gtp-command-spec gg-undo): Use ‘validpos’.
---
packages/gnugo/NEWS | 1 +
packages/gnugo/gnugo.el | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/packages/gnugo/NEWS b/packages/gnugo/NEWS
index 48b02ac..cebe790 100644
--- a/packages/gnugo/NEWS
+++ b/packages/gnugo/NEWS
@@ -31,6 +31,7 @@ NB: "RCS: X..Y " means that the particular release includes
- new command: ‘C-c C-a’ (gnugo-toggle-abdication)
- new major mode: GNUGO Frolic (gnugo-frolic-mode)
- GNUGO Board mode now derived from Special mode
+ - position arg validated for direct GTP commands ‘undo’, ‘gg-undo’
- performance improvements
- of interest to hackers (see source, BI => backward incompatible)
- dropped var: ‘gnugo-inhibit-refresh’ (BI)
diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 52aeb84..78c3f4b 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -2642,6 +2642,19 @@ See `gnugo-board-mode' for a full list of commands."
((sget (x) (get x :gnugo-gtp-command-spec))
(jam (cmd prop val) (put cmd :gnugo-gtp-command-spec
(plist-put (sget cmd) prop val)))
+ (validpos (s &optional go)
+ (let ((pos (upcase s)))
+ (loop with size = (gnugo-get :SZ)
+ for c across (funcall (gnugo--as-cc-func)
+ pos)
+ do (let ((norm (- c ?a)))
+ (unless (and (< -1 norm)
+ (> size norm))
+ (user-error "Invalid position: %s"
+ pos))))
+ (when go
+ (gnugo-goto-pos pos))
+ pos))
(defgtp (x &rest props) (dolist (cmd (if (symbolp x) (list x) x))
(let ((ls props))
(while ls
@@ -2708,7 +2721,7 @@ See `gnugo-board-mode' for a full list of commands."
(let (n)
(cond ((not sel) 1)
((cl-plusp (setq n (string-to-number (car sel)))) n)
- (t (car sel)))))))))
+ (t (validpos (car sel) t)))))))))
(provide 'gnugo)
- [elpa] branch master updated (1905244 -> a1fe7f0), Thien-Thi Nguyen, 2014/04/21
- [elpa] 01/13: [gnugo int] Add abstraction: gnugo--prop<-color, Thien-Thi Nguyen, 2014/04/21
- [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 <=
- [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, 2014/04/21
- [elpa] 02/13: [gnugo] On SGF load, leave cursor at last user board position., Thien-Thi Nguyen, 2014/04/21