Commit 3e26a4a2 authored by Chong Yidong's avatar Chong Yidong
Browse files

New function `string-mark-left-to-right' for handling LRMs.

* lisp/subr.el (string-mark-left-to-right): New function.

* lisp/buff-menu.el (Buffer-menu-buffer+size): Remove LRM argument.
Use string-mark-left-to-right.
(list-buffers-noselect): Caller changed.

* lisp/emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
(tabulated-list-print): Recenter after moving point.
parent ac8cf6e6
......@@ -1038,6 +1038,12 @@ of function value which looks like (closure ENV ARGS &rest BODY).
*** New function `special-variable-p' to check whether a variable is
declared as dynamically bound.
** New function `string-mark-left-to-right' appends a Unicode LRM
(left-to-right mark) character to a string if it terminates in
right-to-left script. This is useful when the buffer has overall
left-to-right paragraph direction and you need to insert a string
whose contents (and directionality) are not known in advance.
** pre/post-command-hook are not reset to nil upon error.
Instead, the offending function is removed.
2011-08-10 Chong Yidong <>
* subr.el (string-mark-left-to-right): New function.
* buff-menu.el (Buffer-menu-buffer+size): Remove LRM argument.
Use string-mark-left-to-right.
(list-buffers-noselect): Caller changed.
* emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
(tabulated-list-print): Recenter after moving point.
2011-08-10 Juri Linkov <>
* progmodes/grep.el (rgrep): Don't bind `process-connection-type'.
......@@ -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 lrm)
(defun Buffer-menu-buffer+size (name size &optional name-props size-props)
(if (> (+ (string-width name) (string-width size) 2)
(setq name
......@@ -681,17 +681,9 @@ For more information, see the function `buffer-menu'."
(string-width 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) ""))))
(string-mark-left-to-right tail))))
;; Don't put properties on (buffer-name).
(setq name (concat (copy-sequence name)
(if lrm
(propertize (string ?\x200e) 'invisible t)
(setq name (string-mark-left-to-right name)))
(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
......@@ -929,8 +921,7 @@ For more information, see the function `buffer-menu'."
(max (length size) 3)
"mouse-2: select this buffer"))
nil t))
"mouse-2: select this buffer"))))
" "
(if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width)
(truncate-string-to-width (nth 4 buffer)
......@@ -258,7 +258,8 @@ to the entry with the same ID element as the current line."
;; If REMEMBER-POS was specified, move to the "old" location.
(if saved-pt
(progn (goto-char saved-pt)
(move-to-column saved-col))
(move-to-column saved-col)
(goto-char (point-min)))))
(defun tabulated-list-print-entry (id cols)
......@@ -282,6 +283,7 @@ of column descriptors."
(> (length label) width)
(setq label (concat (substring label 0 (- width 3))
(setq label (string-mark-left-to-right label))
(if (stringp desc)
(insert (propertize label 'help-echo help-echo))
(apply 'insert-text-button label (cdr desc)))
......@@ -3538,6 +3538,20 @@ If IGNORE-CASE is non-nil, the comparison is done without paying attention
to case differences."
(eq t (compare-strings str1 nil nil
str2 0 (length str1) ignore-case)))
(defun string-mark-left-to-right (str)
"Return a string that can be safely embedded in left-to-right text.
If STR ends in right-to-left (RTL) script, return a string
consisting of STR followed by an invisible left-to-right
mark (LRM) character. Otherwise, return STR."
(unless (stringp str)
(signal 'wrong-type-argument (list 'stringp str)))
(if (and (> (length str) 0)
(eq (get-char-code-property (aref str (1- (length str)))
(concat str (propertize (string ?\x200e) 'invisible t))
;;;; invisibility specs
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment