[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 1fa7d59 204/357: [gnugo int] Add abstraction: gnu
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 1fa7d59 204/357: [gnugo int] Add abstraction: gnugo--plant-and-climb |
Date: |
Sun, 29 Nov 2020 14:51:22 -0500 (EST) |
branch: externals/gnugo
commit 1fa7d599790bc4f23c308d283a9291996d40d632
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Add abstraction: gnugo--plant-and-climb
* packages/gnugo/gnugo.el (gnugo--plant-and-climb): New func.
(gnugo-read-sgf-file, gnugo-board-mode): Use it.
---
gnugo.el | 53 +++++++++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 24 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 5cb0024..8047d5f 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1833,6 +1833,17 @@ If FILENAME already exists, Emacs confirms that you wish
to overwrite it."
(defsubst gnugo--SZ! (size)
(gnugo-put :SZ size))
+(defun gnugo--plant-and-climb (collection &optional sel)
+ (gnugo-put :sgf-collection collection)
+ (let ((tree (nth (or sel 0) collection)))
+ (gnugo-put :sgf-gametree tree)
+ (gnugo-put :monkey (vector
+ ;; mem
+ (aref (gnugo--tree-ends tree) 0)
+ ;; bidx
+ 0))
+ tree))
+
(defun gnugo-read-sgf-file (filename)
"Load the first game tree from FILENAME, a file in SGF format."
(interactive "fSGF file to load: ")
@@ -1853,25 +1864,22 @@ If FILENAME already exists, Emacs confirms that you
wish to overwrite it."
(gnugo-put :gnugo-color wait)
(gnugo-put :user-color play))
(setq coll (gnugo/sgf-create filename)
- tree (nth (let ((n (length coll)))
- ;; This is better:
- ;; (if (= 1 n)
- ;; 0
- ;; (let* ((q (format "Which game? (1-%d)" n))
- ;; (choice (1- (read-number q 1))))
- ;; (if (and (< -1 choice) (< choice n))
- ;; choice
- ;; (message "(Selecting the first game)")
- ;; 0)))
- ;; but this is what we use (for now) to accomodate
- ;; (aka faithfully mimic) GTP `loadsgf' limitations:
- (unless (= 1 n)
- (message "(Selecting the first game)"))
- 0)
- coll))
- (gnugo-put :sgf-collection coll)
- (gnugo-put :sgf-gametree tree)
- (gnugo-put :monkey (vector (aref (gnugo--tree-ends tree) 0) 0))
+ tree (gnugo--plant-and-climb
+ coll (let ((n (length coll)))
+ ;; This is better:
+ ;; (if (= 1 n)
+ ;; 0
+ ;; (let* ((q (format "Which game? (1-%d)" n))
+ ;; (choice (1- (read-number q 1))))
+ ;; (if (and (< -1 choice) (< choice n))
+ ;; choice
+ ;; (message "(Selecting the first game)")
+ ;; 0)))
+ ;; but this is what we use (for now) to accomodate
+ ;; (aka faithfully mimic) GTP `loadsgf' limitations:
+ (unless (= 1 n)
+ (message "(Selecting the first game)"))
+ 0)))
;; This is deliberately undocumented for now.
(gnugo--SZ! (gnugo--root-prop :SZ tree))
(let (game-over)
@@ -2449,11 +2457,8 @@ In this mode, keys do not self insert.
(gnugo-put :rparen-ov (let ((ov (make-overlay 1 1)))
(overlay-put ov 'display ")")
ov))
- (let* ((coll (gnugo/sgf-create "(;FF[4]GM[1])" t))
- (tree (car coll)))
- (gnugo-put :sgf-gametree tree)
- (gnugo-put :sgf-collection coll)
- (gnugo-put :monkey (vector (aref (gnugo--tree-ends tree) 0) 0)))
+ (gnugo--plant-and-climb
+ (gnugo/sgf-create "(;FF[4]GM[1])" t))
(gnugo--SZ! board-size)
(let ((root (gnugo--root-node)))
(cl-flet
- [elpa] externals/gnugo eae8444 113/357: [gnugo int] Specify STREAM to ‘pp’ directly., (continued)
- [elpa] externals/gnugo eae8444 113/357: [gnugo int] Specify STREAM to ‘pp’ directly., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 00ae088 120/357: [gnugo int] Use ‘gnugo--tree-ends’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo fa99b79 134/357: [gnugo int] Make ‘gnugo-board-buffer-p’ precise., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 8f99c83 151/357: [gnugo frolic int] Don't bother to awake w/ ‘col’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 283534a 157/357: [gnugo sgf int] Consolidate loops., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 671d7aa 147/357: [gnugo frolic] Sync column headers w/ buffer text; handle offsets., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 45fe672 169/357: [gnugo int] Move :SZ access into ‘gnugo--as-pos-func’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5e24ee5 182/357: [gnugo int] Use GTP ‘reg_genmove’ instead of ‘genmove’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e387d96 193/357: [gnugo int] Accept color for ‘gnugo-push-move’ 1st arg., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 876e0d3 195/357: [gnugo] New command: ‘C-c C-a’ (gnugo-toggle-abdication), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 1fa7d59 204/357: [gnugo int] Add abstraction: gnugo--plant-and-climb,
Stefan Monnier <=
- [elpa] externals/gnugo d96223f 209/357: [gnugo] Move most of ‘gnugo-board-mode’ to ‘gnugo’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo eb77485 215/357: [gnugo int] Don't make ‘font-lock-defaults’ buffer-local., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 4d5f998 217/357: [gnugo int] Decruft: Drop unused local var., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e6c0a07 229/357: [gnugo int] Fix bug: On -l/--infile, don't set :last-mover., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 11543e5 232/357: [gnugo] Reduce modifier key bouncing for "quick peek" frolics., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo dae8f08 231/357: [gnugo] Fix bug: DTRT for :last-user-bpos in undo-one-move ME-NEXT., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f102d7f 240/357: [gnugo] Allow user to move for GNU Go., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9969838 260/357: [gnugo int] Drop abstractions: gnugo--{ERR-wait, gate-game-over}, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b9fa668 265/357: [gnugo int] Drop redundant ‘gnugo-gate’ calls., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a766f0c 282/357: [gnugo] Replace ‘gnugo-toggle-grid’ w/ ‘gnugo-grid-mode’., Stefan Monnier, 2020/11/29