changeset 99748:cea0d38a2587

(Buffer-menu-buffer+size, list-buffers-noselect): Pay attention to char widths when computing string sizes.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 20 Nov 2008 15:22:16 +0000
parents 51f96d4c63b0
children b491431b74c8
files lisp/ChangeLog lisp/buff-menu.el
diffstat 2 files changed, 27 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- 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  <t_tuneyosi@hotmail.com>
+
+	* buff-menu.el (Buffer-menu-buffer+size, list-buffers-noselect):
+	Pay attention to char widths when computing string sizes.
+
 2008-11-20  Juanma Barranquero  <lekktu@gmail.com>
 
 	* emacs-lisp/bytecomp.el (byte-compile-dynamic-docstrings)
--- 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