all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Toru TSUNEYOSHI" <t_tuneyosi@hotmail.com>
To: <bug-gnu-emacs@gnu.org>
Subject: bug#1369: string-width problem in buff-menu.el
Date: Wed, 19 Nov 2008 00:48:02 +0900	[thread overview]
Message-ID: <BAY121-DAV1198FA4A1B87BCA43F114BE2120@phx.gbl> (raw)

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

hello.

I found a problem in buff-menu.el.
(I use GNU Emacs 22.3.1 (i386-msvc-nt5.0.2195).)

`list-buffers' function can't deal with buffer name in multilingual environment.
it can't truncate buffer name properly.

example:
========================================================================
CRM Buffer                Size  Mode              File
.%  あいうえおかきくけこさしすせそ        271  Dired by name ~/temp/あいうえおかきくけこさしすせそ/
 %  あいう                    247  Dired by name  ~/temp/あいう/
 %  *GNU Emacs*            669  Fundamental
    *scratch*              191  Lisp Interaction
  * *Messages*             691  Fundamental
========================================================================

i made a patch for this problem. please check it. if ok, please apply.

[-- Attachment #2: buff-menu.el.diff --]
[-- Type: application/octet-stream, Size: 2182 bytes --]

--- buff-menu.el.original	2008-01-07 11:45:02.000000000 +0900
+++ buff-menu.el	2008-11-19 00:23:38.786576000 +0900
@@ -587,21 +587,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)))
@@ -609,8 +612,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))
 
@@ -825,8 +828,11 @@
 					   mouse-face highlight
 					   help-echo "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

             reply	other threads:[~2008-11-18 15:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <jwviqqipgm1.fsf-monnier+emacsbugreports@gnu.org>
2008-11-18 15:48 ` Toru TSUNEYOSHI [this message]
2008-11-20 15:30   ` bug#1369: marked as done (string-width problem in buff-menu.el) Emacs bug Tracking System

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY121-DAV1198FA4A1B87BCA43F114BE2120@phx.gbl \
    --to=t_tuneyosi@hotmail.com \
    --cc=1369@emacsbugs.donarmstrong.com \
    --cc=bug-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.