]> git.eshelyaron.com Git - emacs.git/commitdiff
(Buffer-menu-buffer+size, list-buffers-noselect):
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 20 Nov 2008 15:22:16 +0000 (15:22 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Thu, 20 Nov 2008 15:22:16 +0000 (15:22 +0000)
Pay attention to char widths when computing string sizes.

lisp/ChangeLog
lisp/buff-menu.el

index e80c489c11e444924110c6066db4f7aacd4320f8..c892c6f30b0a0a3f372ace193bde98c0e7d1bbc5 100644 (file)
@@ -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)
index df8cd6ec3c234adfe673798c61cc6aeec588ddd0..7e94b8f0ac292467f7ecfadf656f7af46096f63a 100644 (file)
@@ -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