unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1369: string-width problem in buff-menu.el
@ 2008-11-18 15:48 ` Toru TSUNEYOSHI
  2008-11-20 15:30   ` bug#1369: marked as done (string-width problem in buff-menu.el) Emacs bug Tracking System
  0 siblings, 1 reply; 2+ messages in thread
From: Toru TSUNEYOSHI @ 2008-11-18 15:48 UTC (permalink / raw)
  To: bug-gnu-emacs

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#1369: marked as done (string-width problem in buff-menu.el)
  2008-11-18 15:48 ` bug#1369: string-width problem in buff-menu.el Toru TSUNEYOSHI
@ 2008-11-20 15:30   ` Emacs bug Tracking System
  0 siblings, 0 replies; 2+ messages in thread
From: Emacs bug Tracking System @ 2008-11-20 15:30 UTC (permalink / raw)
  To: Stefan Monnier

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


Your message dated Thu, 20 Nov 2008 10:22:35 -0500
with message-id <jwviqqipgm1.fsf-monnier+emacsbugreports@gnu.org>
and subject line Re: bug#1369: string-width problem in buff-menu.el
has caused the Emacs bug report #1369,
regarding string-width problem in buff-menu.el
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)


-- 
1369: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1369
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 6067 bytes --]

[-- Attachment #2.1.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.1.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

[-- Attachment #3: Type: message/rfc822, Size: 1879 bytes --]

From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Toru TSUNEYOSHI <t_tuneyosi@hotmail.com>
Cc: 1369-done@emacsbugs.donarmstrong.com
Subject: Re: bug#1369: string-width problem in buff-menu.el
Date: Thu, 20 Nov 2008 10:22:35 -0500
Message-ID: <jwviqqipgm1.fsf-monnier+emacsbugreports@gnu.org>

> 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.

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

Thank you, applied,


        Stefan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-20 15:30 UTC | newest]

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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).