[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 38137d3 079/357: [gnugo int] Cache gametree prop
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 38137d3 079/357: [gnugo int] Cache gametree prop ‘:SZ’ as gnugo prop ‘:SZ’. |
Date: |
Sun, 29 Nov 2020 14:50:53 -0500 (EST) |
branch: externals/gnugo
commit 38137d356538e1da3aeeb620a877bed16b33787f
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Cache gametree prop ‘:SZ’ as gnugo prop ‘:SZ’.
* packages/gnugo/gnugo.el (gnugo-goto-pos)
(gnugo-propertize-board-buffer, gnugo-move-history)
(gnugo-note, gnugo-refresh, gnugo): Get board
size via ‘gnugo-get’ instead of ‘gnugo-treeroot’.
(gnugo--SZ!): New defsubst.
(gnugo-read-sgf-file, gnugo-board-mode)
(:gnugo-gtp-command-spec boardsize): Use ‘gnugo--SZ!’.
---
gnugo.el | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index a1da4de..7a3e84a 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -376,7 +376,7 @@ when you are sure the command cannot fail."
(defun gnugo-goto-pos (pos)
"Move point to board position POS, a letter-number string."
(goto-char (point-min))
- (forward-line (- (1+ (gnugo-treeroot :SZ))
+ (forward-line (- (1+ (gnugo-get :SZ))
(string-to-number (substring pos 1))))
(forward-char 1)
(forward-char (+ (if (= 32 (following-char)) 1 2)
@@ -464,7 +464,7 @@ when you are sure the command cannot fail."
(%lpad (gnugo-f 'lpad))
(%rpad (gnugo-f 'rpad))
(ispc-props (list 'category (gnugo-f 'ispc) 'rear-nonsticky t))
- (size (gnugo-treeroot :SZ))
+ (size (gnugo-get :SZ))
(size-string (number-to-string size)))
(goto-char (point-min))
(put-text-property (point) (1+ (point)) 'category (gnugo-f 'tpad))
@@ -629,7 +629,7 @@ moves thus far.
For all other values of RSEL, do nothing and return nil."
(interactive "P")
- (let ((size (gnugo-treeroot :SZ))
+ (let ((size (gnugo-get :SZ))
col
monkey mem
acc node mprop move)
@@ -671,7 +671,7 @@ For all other values of RSEL, do nothing and return nil."
(defun gnugo-note (property value &optional movep mogrifyp)
(when mogrifyp
- (let ((sz (gnugo-treeroot :SZ)))
+ (let ((sz (gnugo-get :SZ)))
(cl-labels
((mog (pos) (if (string= "PASS" pos)
"tt"
@@ -892,7 +892,7 @@ its move."
;; window update
(when (setq window (get-buffer-window (current-buffer)))
(let* ((gridp (not (memq :nogrid buffer-invisibility-spec)))
- (size (gnugo-treeroot :SZ))
+ (size (gnugo-get :SZ))
(under10p (< size 10))
(h (- (truncate (- (window-height window)
(* size (gnugo-get :hmul))
@@ -1274,6 +1274,9 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
"as before"
"NOTE: this is a switch!")))
+(defsubst gnugo--SZ! (size)
+ (gnugo-put :SZ size))
+
(defun gnugo-read-sgf-file (filename)
"Load the first game tree from FILENAME, a file in SGF format."
(interactive "fSGF file to load: ")
@@ -1312,6 +1315,8 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
coll))
(gnugo-put :sgf-collection coll)
(gnugo-put :sgf-gametree tree)
+ ;; This is deliberately undocumented for now.
+ (gnugo--SZ! (gnugo-treeroot :SZ))
(let* ((loc tree)
(count 0)
mem node play game-over)
@@ -1770,6 +1775,7 @@ In this mode, keys do not self insert.
(gnugo-put :sgf-gametree tree)
(gnugo-put :sgf-collection (list tree))
(gnugo-put :monkey (vector tree nil 0)))
+ (gnugo--SZ! board-size)
(let ((g-blackp (string= "white" user-color)))
(mapc (lambda (x) (apply 'gnugo-note x))
`((:SZ ,board-size)
@@ -1832,7 +1838,7 @@ starting a new one. See `gnugo-board-mode' documentation
for more info."
(assoc sel all))))))
;; set up a new board
(gnugo-board-mode)
- (let ((half (truncate (1+ (gnugo-treeroot :SZ)) 2)))
+ (let ((half (truncate (1+ (gnugo-get :SZ)) 2)))
(gnugo-goto-pos (format "A%d" half))
(forward-char (* 2 (1- half)))
(gnugo-put :last-user-bpos
@@ -1954,6 +1960,10 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
:post-thunk (lambda ()
(gnugo--unclose-game)
(gnugo-put :last-mover nil)
+ ;; ugh
+ (gnugo--SZ! (string-to-number
+ (gnugo-query
+ "query_boardsize")))
(gnugo-refresh t)))
(deffull loadsgf
- [elpa] externals/gnugo b1f2856 183/357: [gnugo] Fix bug: Keep subproc informed of forced PASS., (continued)
- [elpa] externals/gnugo b1f2856 183/357: [gnugo] Fix bug: Keep subproc informed of forced PASS., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3112192 056/357: [gnugo int] Streamline subproc (de-)marshalling., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 294bdc1 047/357: [gnugo maint] Update NEWS; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b5f47cb 059/357: [gnugo int] Use ‘pcase’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8cabdfa 042/357: [gnugo int] Use internal macros more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b484515 064/357: [gnugo int] Use ‘loop’, functional style more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a7dffa0 067/357: [gnugo maint] Update NEWS; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo d2b4549 068/357: [gnugo] Bind ‘M-u’ to ‘gnugo-undo-one-move’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f82c526 078/357: [gnugo int] Use ‘following-char’ instead of ‘char-after’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f29b22f 081/357: [gnugo int] Use ‘setq’ less., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 38137d3 079/357: [gnugo int] Cache gametree prop ‘:SZ’ as gnugo prop ‘:SZ’.,
Stefan Monnier <=
- [elpa] externals/gnugo d6f3956 089/357: [gnugo int] Decruft: Infer MOVEP from PROPERTY., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5ca5b0a 097/357: [gnugo int] Add abstraction: gnugo--nodep, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a86a897 013/357: [gnugo int] Use ‘redisplay’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3063f95 041/357: [gnugo] Make proc-status change mode-line elem more informative., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c2f7717 053/357: [gnugo slog] Fix bug: Avoid ‘cl-lib’ funcs; use only macros., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 02926a1 049/357: [gnugo] Rename var to ‘gnugo-inhibit-refresh’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5e4b5a8 051/357: [gnugo] Release: 2.3.0, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 400e27d 069/357: [gnugo int] Add abstraction: gnugo--who-is-who, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 3547cbe 080/357: [gnugo int] Add abstraction: gnugo--set-root-prop, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 11e545d 082/357: [gnugo int] Use ‘loop’ instead of ‘dolist’ + ‘destructuring-bind’., Stefan Monnier, 2020/11/29