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

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

[elpa] 92/255: worked around stupid bug in mapconcat


From: Eric Schulte
Subject: [elpa] 92/255: worked around stupid bug in mapconcat
Date: Sun, 16 Mar 2014 01:02:26 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 442283be81fe3631750425f35ba9fae4a39ac6d6
Author: Eric Schulte <address@hidden>
Date:   Thu May 24 20:38:29 2012 -0600

    worked around stupid bug in mapconcat
    
    Specifically mapconcat will conflate the text properties of the strings
    returned by the function passed as its first argument.  See below,
    
        (defun propertized-string (length)
          (mapconcat (lambda (n)
                       (let ((str (return-a-point)))
                         (put-text-property 0 (length str) :number n str)
                         str))
                     (range length) " "))
    
        (insert (format "%S" (propertized-string 4)))
    
        ;; yields the following which all have the same :number property
        #(". . . ." 0 1 (:number 3) 2 3 (:number 3) 4 5 (:number 3) 6 7 
(:number 3))
---
 sgf-board.el |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sgf-board.el b/sgf-board.el
index 6fe9bd7..08e9394 100644
--- a/sgf-board.el
+++ b/sgf-board.el
@@ -163,11 +163,13 @@
 (defun board-row-to-string (board row)
   (let* ((size (board-size board))
          (label (format "%3d" (1+ row)))
-         (row-body (mapconcat
-                    (lambda (n)
-                      (board-pos-to-string board (cons row n)))
-                    (range size) " ")))
-    (concat label " " row-body label)))
+         (row-body ""))
+    (dotimes (n size)
+      (setq row-body
+            (concat row-body
+                    (board-pos-to-string board (cons row n))
+                    " ")))
+    (concat label " " (substring row-body 0 (1- (length row-body))) label)))
 
 (defun board-body-to-string (board)
   (let ((board (transpose-array board)))



reply via email to

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