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

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

[elpa] externals/ftable 9f75340 08/14: Make ftable work with CJK charact


From: Stefan Monnier
Subject: [elpa] externals/ftable 9f75340 08/14: Make ftable work with CJK characters
Date: Mon, 2 Aug 2021 18:27:32 -0400 (EDT)

branch: externals/ftable
commit 9f7534079c60c62a9e7256faf9a6726202404982
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Make ftable work with CJK characters
    
    * ftable.el (ftable--parse-to, ftable--max-line-width,
    ftable--pad-to): Replace 'length' with 'string-width'.
---
 ftable.el | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/ftable.el b/ftable.el
index ca418b3..5af7eda 100644
--- a/ftable.el
+++ b/ftable.el
@@ -189,7 +189,7 @@ It defaults to the first charset."
     (make-ftable
      :column-width-list
      (mapcar (lambda (column)
-               (apply #'max (mapcar #'length column)))
+               (apply #'max (mapcar #'string-width column)))
              (cl-loop for n from 0 to (1- (length (car matrix)))
                       collect (ftable--nth-column n matrix)))
      :min-width-list
@@ -264,7 +264,6 @@ Assumes each line in LINE-LIST has the same length."
             (cl-loop for col from 0 to (1- (length (car matrix)))
                      collect (ftable--nth-column col matrix)))))
 
-
 ;;; Fill
 
 (cl-defmethod ftable--fill ((table ftable) table-max-width)
@@ -365,7 +364,7 @@ Return a new table with shrinked column."
 (defun ftable--max-line-width ()
   "Return the maximum line width in buffer."
   (apply #'max
-         (mapcar #'length
+         (mapcar #'string-width
                  (split-string (buffer-string) "\n"))))
 
 ;;; Unparse
@@ -485,8 +484,8 @@ which corresponds to
 (defun ftable--pad-to (text width)
   "Append padding to TEXT until it is WIDTH characters long.
 Return a new string."
-  (if (< (length text) width)
-      (concat text (make-vector (- width (length text)) ?\s))
+  (if (< (string-width text) width)
+      (concat text (make-vector (- width (string-width text)) ?\s))
     text))
 
 ;;; Convenience



reply via email to

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