]> code.delx.au - gnu-emacs/commitdiff
Improve column width calculation in tabulated-list.el.
authorChong Yidong <cyd@gnu.org>
Tue, 20 Mar 2012 15:44:45 +0000 (23:44 +0800)
committerChong Yidong <cyd@gnu.org>
Tue, 20 Mar 2012 15:44:45 +0000 (23:44 +0800)
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
string-width and truncate-string-width to handle arbitrary
characters.

lisp/ChangeLog
lisp/emacs-lisp/tabulated-list.el

index 731a443390c28ca73a9eda6eb1f89da8861569f5..ed5dc39021bb2646087a0b4a5ef7ea400af1c798 100644 (file)
@@ -1,3 +1,9 @@
+2012-03-20  Chong Yidong  <cyd@gnu.org>
+
+       * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
+       string-width and truncate-string-width to handle arbitrary
+       characters.
+
 2012-03-20  Tassilo Horn  <tassilo@member.fsf.org>
 
        * textmodes/artist.el (artist-menu-map): Bind Rectangle menu item
index 8fe514ab551ab16ab57c2ef641a908b1f6712b2e..f17b12da6a0dbdc0a54595be36857dda03b3db71 100644 (file)
@@ -278,11 +278,10 @@ of column descriptors."
             (width  (nth 1 format))
             (label  (if (stringp desc) desc (car desc)))
             (help-echo (concat (car format) ": " label)))
-       ;; Truncate labels if necessary.
-       (and (> width 6)
-            (> (length label) width)
-            (setq label (concat (substring label 0 (- width 3))
-                                "...")))
+       ;; Truncate labels if necessary (except last column).
+       (and (< (1+ n) len)
+            (> (string-width label) width)
+            (setq label (truncate-string-to-width label width nil nil t)))
        (setq label (bidi-string-mark-left-to-right label))
        (if (stringp desc)
            (insert (propertize label 'help-echo help-echo))