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

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

[elpa] 01/01: [gnugo int] Decorate w/ plist instead of alist.


From: Thien-Thi Nguyen
Subject: [elpa] 01/01: [gnugo int] Decorate w/ plist instead of alist.
Date: Thu, 24 Apr 2014 22:13:30 +0000

ttn pushed a commit to branch master
in repository elpa.

commit fd1ea1172b34787aa244e7a167e6ce70f69bce2a
Author: Thien-Thi Nguyen <address@hidden>
Date:   Fri Apr 25 00:03:22 2014 +0200

    [gnugo int] Decorate w/ plist instead of alist.
    
    * packages/gnugo/gnugo.el (gnugo--decorate):
    Rewrite; convert from defsubst to defun.
    (gnugo-display-final-score, gnugo-comment)
    (gnugo r!): Update accordingly.
---
 packages/gnugo/gnugo.el |   25 +++++++++++++------------
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el
index 92ccf0b..6a7cf6c 100644
--- a/packages/gnugo/gnugo.el
+++ b/packages/gnugo/gnugo.el
@@ -1226,9 +1226,15 @@ This fails if the monkey is on the current branch
                                  (substring pos 1))))))
         (format "%c%c" one two)))))
 
-(defsubst gnugo--decorate (node alist)
-  ;; NB: ALIST should not have :B or :W keys.
-  (setcdr (last node) alist))
+(defun gnugo--decorate (node &rest plist)
+  (loop with tp = (last node)
+        while plist
+        do (setf
+            fruit (list (cons           ; DWR: LtR OoE assumed.
+                         (pop plist)
+                         (pop plist)))
+            (cdr tp) fruit
+            tp       fruit)))
 
 (defun gnugo-close-game (end-time resign)
   (gnugo-put :game-end-time end-time)
@@ -2190,6 +2196,7 @@ to the last move, as a comment."
       (let ((node (car (aref (gnugo-get :monkey) 0))))
         (gnugo--decorate
          (delq (assq :C node) node)
+         :C
          (with-temp-buffer              ; lame
            (insert blurb)
            (when (search-backward "\n\nGame start:" nil t)
@@ -2202,7 +2209,7 @@ to the last move, as a comment."
              (rep "territory" "T")
              (rep "captures"  "C")
              (rep "komi"      "K"))
-           `((:C . ,(buffer-string)))))))
+           (buffer-string)))))
     (switch-to-buffer (format "%s*GNUGO Final Score*" (gnugo-get :diamond)))
     (erase-buffer)
     (insert blurb)))
@@ -2281,7 +2288,7 @@ If COMMENT is nil or the empty string, remove the 
property entirely."
                         (cdr (assq :C node))))))
   (setq node (delq (assq :C node) node))
   (unless (zerop (length comment))
-    (gnugo--decorate node `((:C . ,comment)))))
+    (gnugo--decorate node :C comment)))
 
 (defun gnugo-toggle-abdication ()
   "Toggle abdication, i.e., letting GNU Go play for you.
@@ -2503,13 +2510,7 @@ See `gnugo-board-mode' for a full list of commands."
         (if filename
             (gnugo-read-sgf-file (expand-file-name filename))
           (cl-flet
-              ((r! (&rest plist)
-                   (gnugo--decorate
-                    root (loop          ; hmm, available elsewhere?
-                          while plist
-                          collect (let* ((k (pop plist))
-                                         (v (pop plist)))
-                                    (cons k v))))))
+              ((r! (&rest plist) (apply 'gnugo--decorate root plist)))
             (gnugo--SZ!
              (setq root (gnugo--root-node
                          (gnugo--plant-and-climb



reply via email to

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