From: Stefan Monnier Date: Thu, 20 Nov 2008 15:22:16 +0000 (+0000) Subject: (Buffer-menu-buffer+size, list-buffers-noselect): X-Git-Tag: emacs-pretest-23.0.90~1677 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a3e5a6032aff3b93f31713d51351cda5a49f9bd3;p=emacs.git (Buffer-menu-buffer+size, list-buffers-noselect): Pay attention to char widths when computing string sizes. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e80c489c11e..c892c6f30b0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -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 --git a/lisp/buff-menu.el b/lisp/buff-menu.el index df8cd6ec3c2..7e94b8f0ac2 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el @@ -597,21 +597,24 @@ For more information, see the function `buffer-menu'." (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 @@ For more information, see the function `buffer-menu'." (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 @@ For more information, see the function `buffer-menu'." 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