summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/tabulated-list.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@gnu.org>2012-03-20 23:44:45 +0800
committerChong Yidong <cyd@gnu.org>2012-03-20 23:44:45 +0800
commitf0bcceb9955d5aef6a131a86c4f74cc3e6e4c9ec (patch)
tree1dab38ca0fde3e8d687db038d8ff0f96bc68c24a /lisp/emacs-lisp/tabulated-list.el
parent025de85b0709596975ddcd0fa298f88d12493254 (diff)
downloademacs-f0bcceb9955d5aef6a131a86c4f74cc3e6e4c9ec.tar.gz
Improve column width calculation in tabulated-list.el.
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use string-width and truncate-string-width to handle arbitrary characters.
Diffstat (limited to 'lisp/emacs-lisp/tabulated-list.el')
-rw-r--r--lisp/emacs-lisp/tabulated-list.el9
1 files changed, 4 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 8fe514ab551..f17b12da6a0 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -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))