Fix display of R2L buffer names in Buffer-menu.
authorEli Zaretskii <eliz@gnu.org>
Sun, 19 Jun 2011 18:27:03 +0000 (21:27 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 19 Jun 2011 18:27:03 +0000 (21:27 +0300)
 lisp/buff-menu.el (Buffer-menu-buffer+size): Accept an additional
 argument LRM; if non-nil, append an invisible LRM character to the
 buffer name.
 (list-buffers-noselect): Call Buffer-menu-buffer+size with the
 last argument non-nil, when formatting buffer names.

lisp/ChangeLog
lisp/buff-menu.el

index ccfff54..9a4468d 100644 (file)
@@ -1,3 +1,11 @@
+2011-06-19  Eli Zaretskii  <eliz@gnu.org>
+
+       * buff-menu.el (Buffer-menu-buffer+size): Accept an additional
+       argument LRM; if non-nil, append an invisible LRM character to the
+       buffer name.
+       (list-buffers-noselect): Call Buffer-menu-buffer+size with the
+       last argument non-nil, when formatting buffer names.
+
 2011-06-18  Eli Zaretskii  <eliz@gnu.org>
 
        * buff-menu.el (Buffer-menu-mode, list-buffers-noselect): Force
index cd1c8d7..00340e5 100644 (file)
@@ -666,7 +666,7 @@ For more information, see the function `buffer-menu'."
   ":" ;; (if (char-displayable-p ?…) "…" ":")
   )
 
-(defun Buffer-menu-buffer+size (name size &optional name-props size-props)
+(defun Buffer-menu-buffer+size (name size &optional name-props size-props lrm)
   (if (> (+ (string-width name) (string-width size) 2)
          Buffer-menu-buffer+size-width)
       (setq name
@@ -681,9 +681,17 @@ For more information, see the function `buffer-menu'."
                           (string-width tail)
                           2))
                       Buffer-menu-short-ellipsis
-                      tail)))
+                      tail
+                     ;; Append an invisible LRM character to the
+                     ;; buffer's name to avoid ugly display with the
+                     ;; buffer size to the left of the name, when the
+                     ;; name begins with R2L character.
+                     (if lrm (propertize (string ?\x200e) 'invisible t) ""))))
     ;; Don't put properties on (buffer-name).
-    (setq name (copy-sequence name)))
+    (setq name (concat (copy-sequence name)
+                      (if lrm
+                          (propertize (string ?\x200e) 'invisible t)
+                        ""))))
   (add-text-properties 0 (length name) name-props name)
   (add-text-properties 0 (length size) size-props size)
   (let ((name+space-width (- Buffer-menu-buffer+size-width
@@ -913,7 +921,8 @@ For more information, see the function `buffer-menu'."
                                                   (max (length size) 3)
                                                   2))
                                            name
-                                         "mouse-2: select this buffer"))))
+                                         "mouse-2: select this buffer"))
+                        nil t))
                "  "
                (if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width)
                    (truncate-string-to-width (nth 4 buffer)