diff options
| author | Chong Yidong | 2012-03-20 23:44:45 +0800 |
|---|---|---|
| committer | Chong Yidong | 2012-03-20 23:44:45 +0800 |
| commit | f0bcceb9955d5aef6a131a86c4f74cc3e6e4c9ec (patch) | |
| tree | 1dab38ca0fde3e8d687db038d8ff0f96bc68c24a | |
| parent | 025de85b0709596975ddcd0fa298f88d12493254 (diff) | |
| download | emacs-f0bcceb9955d5aef6a131a86c4f74cc3e6e4c9ec.tar.gz emacs-f0bcceb9955d5aef6a131a86c4f74cc3e6e4c9ec.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 731a443390c..ed5dc39021b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-03-20 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use | ||
| 4 | string-width and truncate-string-width to handle arbitrary | ||
| 5 | characters. | ||
| 6 | |||
| 1 | 2012-03-20 Tassilo Horn <tassilo@member.fsf.org> | 7 | 2012-03-20 Tassilo Horn <tassilo@member.fsf.org> |
| 2 | 8 | ||
| 3 | * textmodes/artist.el (artist-menu-map): Bind Rectangle menu item | 9 | * textmodes/artist.el (artist-menu-map): Bind Rectangle menu item |
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." | |||
| 278 | (width (nth 1 format)) | 278 | (width (nth 1 format)) |
| 279 | (label (if (stringp desc) desc (car desc))) | 279 | (label (if (stringp desc) desc (car desc))) |
| 280 | (help-echo (concat (car format) ": " label))) | 280 | (help-echo (concat (car format) ": " label))) |
| 281 | ;; Truncate labels if necessary. | 281 | ;; Truncate labels if necessary (except last column). |
| 282 | (and (> width 6) | 282 | (and (< (1+ n) len) |
| 283 | (> (length label) width) | 283 | (> (string-width label) width) |
| 284 | (setq label (concat (substring label 0 (- width 3)) | 284 | (setq label (truncate-string-to-width label width nil nil t))) |
| 285 | "..."))) | ||
| 286 | (setq label (bidi-string-mark-left-to-right label)) | 285 | (setq label (bidi-string-mark-left-to-right label)) |
| 287 | (if (stringp desc) | 286 | (if (stringp desc) |
| 288 | (insert (propertize label 'help-echo help-echo)) | 287 | (insert (propertize label 'help-echo help-echo)) |