[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 3903907 235/357: [gnugo] Validate position arg o
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 3903907 235/357: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’. |
Date: |
Sun, 29 Nov 2020 14:51:29 -0500 (EST) |
branch: externals/gnugo
commit 39039072e9acc1e57fc4886b6d49acc1ac4dde52
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[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’.
---
NEWS | 1 +
gnugo.el | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/NEWS b/NEWS
index 48b02ac..cebe790 100644
--- a/NEWS
+++ b/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/gnugo.el b/gnugo.el
index 52aeb84..78c3f4b 100644
--- a/gnugo.el
+++ b/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] externals/gnugo 891a97a 177/357: [gnugo int] Add abstraction: gnugo--decorate, (continued)
- [elpa] externals/gnugo 891a97a 177/357: [gnugo int] Add abstraction: gnugo--decorate, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 843cd96 163/357: [gnugo frolic int] Add abstraction: gnugo--sideways, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo eb13b8e 180/357: [gnugo] Dropped command: ‘t’ (gnugo-toggle-dead-group), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6c7e102 181/357: [gnugo int] Rename :waitingp to :waiting; save color there., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 425731b 196/357: [gnugo int] Add abstraction: gnugo--ERR-wait, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3f3af4b 208/357: [gnugo int] Remove from ‘gnugo-state’ instead of setting to nil., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f28d241 223/357: [gnugo int] Decruft: Don't set provisional :last-user-bpos., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8211cb9 224/357: [gnugo int] Couple :center-position and :SZ jamming., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 536960c 230/357: [gnugo int] Fix bug: On -l/--infile, inhibit first move if game over., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 50cc2b3 233/357: [gnugo int] Add abstraction: gnugo--q/ue, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3903907 235/357: [gnugo] Validate position arg of GTP commands ‘undo’, ‘gg-undo’.,
Stefan Monnier <=
- [elpa] externals/gnugo ab1f4c2 242/357: [gnugo] Fix bug: DTRT for suggestion ‘nowarp’ check., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e814724 243/357: [gnugo] Allow user to request suggestion for GNU Go., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5157534 241/357: [gnugo int] Use ‘destructuring-bind’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6c99d78 251/357: [gnugo int] Add abstraction: gnugo--no-worries, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9f5fcfc 250/357: [gnugo int] Add abstraction: gnugo--resignp, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 2612c6b 263/357: [gnugo] Replace abdication w/ Assist and Zombie minor modes., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b586e0c 268/357: [gnugo] Refuse to climb towards root when in Assist mode., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo af7aa4a 267/357: [gnugo] Fix bug: On role switch, flip karma after roles., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b6ac4ac 283/357: [gnugo frolic] Add command to navigate to end of branch., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5414994 277/357: [gnugo] Handle function for ‘gnugo-xpms’ value., Stefan Monnier, 2020/11/29