[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 4f96ca6 076/357: [gnugo sgf int] Add abstractions
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 4f96ca6 076/357: [gnugo sgf int] Add abstractions: seek, seek-into |
Date: |
Sun, 29 Nov 2020 14:50:52 -0500 (EST) |
branch: externals/gnugo
commit 4f96ca63114236ab2151f7ba0192b1838ef474b5
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo sgf int] Add abstractions: seek, seek-into
* packages/gnugo/gnugo.el (gnugo/sgf-read-file):
...here, as internal funcs via ‘cl-labels’.
(gnugo/sgf-read-file NODE): Rewrite.
(gnugo/sgf-read-file TREE): Likewise, w/ arg LEV.
(gnugo/sgf-read-file): Call ‘TREE’ once, w/ LEV 0.
---
gnugo.el | 42 ++++++++++++++++++++++--------------------
1 file changed, 22 insertions(+), 20 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index c93232e..02fe4e3 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -2143,28 +2143,30 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
(forward-char -1)
(nreverse ls))))
(forward-char 1))))))
- (NODE () (let (prop props)
- (sw) (short 'node)
- (when (= ?\; (char-after))
- (forward-char 1)
- (while (setq prop (PROP))
- (push prop props))
- (nreverse props))))
- (TREE () (let (nodes)
- (while (and (sw) (not (eobp)))
- (case (char-after)
- (?\; (push (NODE) nodes))
- (?\( (forward-char 1)
- (push (TREE) nodes))
- (?\) (forward-char 1))))
- (nreverse nodes))))
+ (seek (c) (and (sw) (not (eobp)) (= c (char-after))))
+ (seek-into (c) (when (seek c)
+ (forward-char 1)
+ t))
+ (NODE () (when (seek-into ?\;)
+ (loop with prop
+ while (setq prop (PROP))
+ collect prop)))
+ (TREE (lev) (prog1
+ ;; hmm
+ ;; ‘append’ => ([NODE...] [SUBTREE...])
+ ;; ‘cons’ => (([NODE...]) . [SUBTREE...])
+ (append
+ ;; nodes
+ (loop while (seek ?\;)
+ collect (NODE))
+ ;; subtrees
+ (loop while (seek-into ?\()
+ collect (TREE (1+ lev))))
+ (unless (zerop lev)
+ (assert (seek-into ?\)))))))
(with-temp-buffer
(insert-file-contents filename)
- (let (trees)
- (while (and (sw) (not (eobp)) (= 40 (char-after))) ; left paren
- (forward-char 1)
- (push (TREE) trees))
- (nreverse trees))))))
+ (TREE 0)))))
(defun gnugo/sgf-write-file (collection filename)
;; take responsibility for our actions
- [elpa] externals/gnugo fef1847 040/357: [gnugo] Use special constructs for keybindings in docstrings., (continued)
- [elpa] externals/gnugo fef1847 040/357: [gnugo] Use special constructs for keybindings in docstrings., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5c8f31d 043/357: [gnugo maint] Update HACKING; nfc., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 2d4c9ad 046/357: [gnugo] New command: ‘_’ and ‘M-_’ (gnugo-boss-is-near), Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 02c55b7 054/357: [gnugo] Release: 2.3.1, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c479509 044/357: [gnugo] Bind ‘DEL’ to ‘gnugo-undo-two-moves’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9748703 060/357: [gnugo int] Elide single-use local var., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 6573d16 065/357: [gnugo int] Add abstraction: gnugo--compare-strings, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a949e26 071/357: [gnugo int] Rename arg from SWITCH to ME-NEXT., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 558d778 072/357: [gnugo] Fix bug: Handle property value type ‘none’ normally., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 9469952 075/357: fixup! [gnugo sgf] Move gratuitous newline from after to before (sub)trees., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 4f96ca6 076/357: [gnugo sgf int] Add abstractions: seek, seek-into,
Stefan Monnier <=
- [elpa] externals/gnugo 98414ca 086/357: [gnugo int] Add abstractions: gnugo{--root-node, /sgf-root-node}, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 622b1eb 084/357: [gnugo] Handle ‘(gnugo-move-history 'two)’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 06586e9 093/357: [gnugo] Fix bug: Don't bother translating move "resign"., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7f380e4 006/357: [gnugo] Presume working time-date.el., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 74b839a 066/357: [gnugo int] Use ‘incf’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo ad774f4 074/357: [gnugo sgf] Move gratuitous newline from after to before (sub)trees., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a44da1b 073/357: [gnugo sgf int] Add abstractions: >>prop, >>node, >>tree, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a7f01be 083/357: [gnugo int] Add abstraction: nn, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo a07cf7c 109/357: [gnugo int] Use ‘gnugo--as-pos-func’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 71f163d 111/357: [gnugo int] Support growth also off of main line., Stefan Monnier, 2020/11/29