# HG changeset patch # User Stefan Monnier # Date 1227194536 0 # Node ID cea0d38a258797320a21e48f517fd640d422ad9a # Parent 51f96d4c63b0e8bba94c490acedccefb8ed55809 (Buffer-menu-buffer+size, list-buffers-noselect): Pay attention to char widths when computing string sizes. diff -r 51f96d4c63b0 -r cea0d38a2587 lisp/ChangeLog --- a/lisp/ChangeLog Thu Nov 20 12:13:49 2008 +0000 +++ b/lisp/ChangeLog Thu Nov 20 15:22:16 2008 +0000 @@ -1,3 +1,8 @@ +2008-11-20 Toru TSUNEYOSHI + + * buff-menu.el (Buffer-menu-buffer+size, list-buffers-noselect): + Pay attention to char widths when computing string sizes. + 2008-11-20 Juanma Barranquero * emacs-lisp/bytecomp.el (byte-compile-dynamic-docstrings) diff -r 51f96d4c63b0 -r cea0d38a2587 lisp/buff-menu.el --- a/lisp/buff-menu.el Thu Nov 20 12:13:49 2008 +0000 +++ b/lisp/buff-menu.el Thu Nov 20 15:22:16 2008 +0000 @@ -597,21 +597,24 @@ (display-buffer (list-buffers-noselect files-only))) (defun Buffer-menu-buffer+size (name size &optional name-props size-props) - (if (> (+ (length name) (length size) 2) Buffer-menu-buffer+size-width) + (if (> (+ (string-width name) (string-width size) 2) Buffer-menu-buffer+size-width) (setq name (if (string-match "<[0-9]+>$" name) - (concat (substring name 0 - (- Buffer-menu-buffer+size-width - (max (length size) 3) - (match-end 0) - (- (match-beginning 0)) - 2)) + (concat (truncate-string-to-width name + (- Buffer-menu-buffer+size-width + (max (string-width size) 3) + (string-width (match-string 0)) + 2) + 0 + ?\s) ":" ; narrow ellipsis (match-string 0 name)) - (concat (substring name 0 - (- Buffer-menu-buffer+size-width - (max (length size) 3) - 2)) + (concat (truncate-string-to-width name + (- Buffer-menu-buffer+size-width + (max (string-width size) 3) + 2) + 0 + ?\s) ":"))) ; narrow ellipsis ;; Don't put properties on (buffer-name). (setq name (copy-sequence name))) @@ -619,8 +622,8 @@ (add-text-properties 0 (length size) size-props size) (concat name (make-string (- Buffer-menu-buffer+size-width - (length name) - (length size)) + (string-width name) + (string-width size)) ?\s) size)) @@ -840,9 +843,12 @@ 2)) name "mouse-2: select this buffer")))) - " " - (if (> (length (nth 4 buffer)) Buffer-menu-mode-width) - (substring (nth 4 buffer) 0 Buffer-menu-mode-width) + " " + (if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width) + (truncate-string-to-width (nth 4 buffer) + Buffer-menu-mode-width + 0 + ?\s) (nth 4 buffer))) (when (nth 5 buffer) (indent-to (+ Buffer-menu-buffer-column Buffer-menu-buffer+size-width