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

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

[elpa] externals/gnugo 64bd753 327/357: [gnugo int] Simplify SGF-write s


From: Stefan Monnier
Subject: [elpa] externals/gnugo 64bd753 327/357: [gnugo int] Simplify SGF-write subroutine.
Date: Sun, 29 Nov 2020 14:51:50 -0500 (EST)

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

    [gnugo int] Simplify SGF-write subroutine.
    
    * packages/gnugo/gnugo.el (gnugo/sgf-write-file esc):
    Drop 2nd arg FMT; rename remaining 2nd arg from ARG to VAL;
    don't bother w/ ‘list-to-string’; if ARG is already a
    string, use it directly; otherwise ‘format "%s"’ as before.
    (gnugo/sgf-write-file >>one): Update call to ‘esc’.
    (gnugo/sgf-write-file >>two): Likewise.
---
 gnugo.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 7245a3d..ddfc953 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -2680,7 +2680,7 @@ A collection is a list of gametrees, each a vector of 
four elements:
                        gnugo/sgf-*r4-properties*))
         p name v spec)
     (cl-labels
-        ((esc (composed fmt arg)
+        ((esc (composed val)
               (mapconcat (lambda (c)
                            (cl-case c
                              ;; ‘?\[’ is not strictly required
@@ -2688,13 +2688,15 @@ A collection is a list of gametrees, each a vector of 
four elements:
                              ((?\[ ?\] ?\\) (format "\\%c" c))
                              (?: (concat (if composed "\\" "") ":"))
                              (t (string c))))
-                         (string-to-list (format fmt arg))
+                         ;; ‘list-to-string’ unnecessary; ‘mapconcat’ DTRT
+                         (if (stringp val)
+                             val
+                           (format "%s" val))
                          ""))
-         (>>one (v) (insert "[" (esc nil "%s" v) "]"))
-         (>>two (v) (insert "["
-                            (esc t "%s" (car v))
-                            ":"
-                            (esc t "%s" (cdr v))
+         (>>one (v) (insert "[" (esc nil v)
+                            "]"))
+         (>>two (v) (insert "[" (esc t (car v))
+                            ":" (esc t (cdr v))
                             "]"))
          (>>nl () (cond ((memq name aft-newline-appreciated)
                          (insert "\n"))



reply via email to

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