[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gnugo 3547cbe 080/357: [gnugo int] Add abstraction: gnu
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gnugo 3547cbe 080/357: [gnugo int] Add abstraction: gnugo--set-root-prop |
Date: |
Sun, 29 Nov 2020 14:50:53 -0500 (EST) |
branch: externals/gnugo
commit 3547cbeaeb29564e2654ab718c2660585d77c0aa
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>
[gnugo int] Add abstraction: gnugo--set-root-prop
* packages/gnugo/gnugo.el (gnugo--set-root-prop): New func.
(gnugo-display-final-score, gnugo/sgf-write-file): Use it.
---
gnugo.el | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/gnugo.el b/gnugo.el
index 7a3e84a..d92eea5 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -373,6 +373,14 @@ when you are sure the command cannot fail."
(defsubst gnugo-treeroot (prop)
(cdr (assq prop (car (gnugo-get :sgf-gametree)))))
+(defun gnugo--set-root-prop (prop value &optional tree)
+ (let* ((root (car (or tree (gnugo-get :sgf-gametree))))
+ (cur (assq prop root)))
+ (if cur
+ (setcdr cur value)
+ (push (cons prop value)
+ (cdr (last root))))))
+
(defun gnugo-goto-pos (pos)
"Move point to board position POS, a letter-number string."
(goto-char (point-min))
@@ -1558,11 +1566,7 @@ Also, add the `:RE' SGF property to the root node of the
game tree."
(yep "Game start" beg)
(yep " end" end))))
(setq blurb (apply 'concat (nreverse blurb)))
- (let* ((root (car (gnugo-get :sgf-gametree)))
- (cur (assq :RE root)))
- (if cur
- (setcdr cur result)
- (setcdr (last root) (list (cons :RE result)))))
+ (gnugo--set-root-prop :RE result)
(switch-to-buffer (format "%s*GNUGO Final Score*" (gnugo-get :diamond)))
(erase-buffer)
(insert blurb)))
@@ -2181,13 +2185,9 @@ starting a new one. See `gnugo-board-mode'
documentation for more info."
(defun gnugo/sgf-write-file (collection filename)
;; take responsibility for our actions
- (dolist (tree collection)
- (let* ((root (car tree))
- (who (assq :AP root))
- (fruit (cons "gnugo.el" gnugo-version)))
- (if who
- (setcdr who fruit)
- (setcdr (last root) (list (cons :AP fruit))))))
+ (let ((me (cons "gnugo.el" gnugo-version)))
+ (dolist (tree collection)
+ (gnugo--set-root-prop :AP me tree)))
;; write it out
(let ((aft-newline-appreciated '(:AP :GN :PB :PW :HA :KM :RU :RE))
(specs (mapcar (lambda (full)
- [elpa] externals/gnugo f29b22f 081/357: [gnugo int] Use ‘setq’ less., (continued)
- [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, 2020/11/29
- [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 <=
- [elpa] externals/gnugo 11e545d 082/357: [gnugo int] Use ‘loop’ instead of ‘dolist’ + ‘destructuring-bind’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 5eeb99b 087/357: [gnugo int] Use ‘incf’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 7293802 088/357: [gnugo int] Use ‘setq’ less., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo 35b1551 091/357: [gnugo int] Use ‘loop’ instead of ‘mapc’ + ‘apply’., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo b5990a0 085/357: [gnugo int] Use ‘gnugo-treeroot’ more., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo f9668f0 090/357: [gnugo int] Add abstraction: gnugo--blackp, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo c164c40 092/357: [gnugo int] Add abstraction: gnugo--passp, Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo bf04735 094/357: [gnugo] Fix bug: Don't misuse SGF prop ‘:EV’ for "resign" state., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo e036fed 096/357: [gnugo] Fix bug: On load, follow mainline through subtrees., Stefan Monnier, 2020/11/29
- [elpa] externals/gnugo eaaa7c8 102/357: [gnugo int] Invert gametree IR to hang by the leaves., Stefan Monnier, 2020/11/29