emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnugo a44da1b 073/357: [gnugo sgf int] Add abstractions


From: Stefan Monnier
Subject: [elpa] externals/gnugo a44da1b 073/357: [gnugo sgf int] Add abstractions: >>prop, >>node, >>tree
Date: Sun, 29 Nov 2020 14:50:52 -0500 (EST)

branch: externals/gnugo
commit a44da1bf8bb827d302ee10cbe3fc54c67771ce7c
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo sgf int] Add abstractions: >>prop, >>node, >>tree
    
    * packages/gnugo/gnugo.el (gnugo/sgf-write-file):
    ...here, as internal funcs via ‘cl-labels’.
---
 gnugo.el | 57 +++++++++++++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 24 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 7b8b829..af71c59 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -2191,32 +2191,41 @@ starting a new one.  See `gnugo-board-mode' 
documentation for more info."
                         ((< 60 (current-column))
                          (save-excursion
                            (goto-char p)
-                           (insert "\n"))))))
+                           (insert "\n")))))
+         (>>prop (prop)
+                 (setq p (point)
+                       name (car prop)
+                       v (cdr prop))
+                 (insert (substring (symbol-name name) 1))
+                 (cond ((not v))
+                       ((and (consp v)
+                             (setq spec (cdr (assq name specs)))
+                             (memq (car spec)
+                                   '(list elist)))
+                        (>>nl)
+                        (let ((>> (if (consp (cadr spec))
+                                      #'>>two
+                                    #'>>one)))
+                          (dolist (little-v v)
+                            (setq p (point))
+                            (funcall >> little-v)
+                            (>>nl))))
+                       ((consp v)
+                        (>>two v) (>>nl))
+                       (t
+                        (>>one v) (>>nl))))
+         (>>node (node)
+                 (loop initially (insert ";")
+                       for prop in node
+                       do (>>prop prop)))
+         (>>tree (tree)
+                 (insert "(")
+                 (dolist (node tree)
+                   (>>node node))
+                 (insert ")\n")))
       (with-temp-buffer
         (dolist (tree collection)
-          (insert "(")
-          (dolist (node tree)
-            (insert ";")
-            (dolist (prop node)
-              (setq p (point)
-                    name (car prop)
-                    v (cdr prop))
-              (insert (substring (symbol-name name) 1))
-              (cond ((not v))
-                    ((and (consp v)
-                          (memq (car (setq spec (cdr (assq name specs))))
-                                '(list elist)))
-                     (>>nl)
-                     (let ((>> (if (consp (cadr spec))
-                                   #'>>two
-                                 #'>>one)))
-                       (dolist (little-v v)
-                         (setq p (point)) (funcall >> little-v) (>>nl))))
-                    ((consp v)
-                     (>>two v) (>>nl))
-                    (t
-                     (>>one v) (>>nl)))))
-          (insert ")\n"))
+          (>>tree tree))
         (write-file filename)))))
 
 ;;; gnugo.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]