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
string-mark-left-to-right.
(tabulated-list-print): Recenter after moving point.
parent ac8cf6e6
...@@ -1038,6 +1038,12 @@ of function value which looks like (closure ENV ARGS &rest BODY). ...@@ -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 *** New function `special-variable-p' to check whether a variable is
declared as dynamically bound. 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. ** pre/post-command-hook are not reset to nil upon error.
Instead, the offending function is removed. Instead, the offending function is removed.
......
2011-08-10 Chong Yidong <cyd@stupidchicken.com>
* 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
string-mark-left-to-right.
(tabulated-list-print): Recenter after moving point.
2011-08-10 Juri Linkov <juri@jurta.org> 2011-08-10 Juri Linkov <juri@jurta.org>
* progmodes/grep.el (rgrep): Don't bind `process-connection-type'. * progmodes/grep.el (rgrep): Don't bind `process-connection-type'.
......
...@@ -666,7 +666,7 @@ For more information, see the function `buffer-menu'." ...@@ -666,7 +666,7 @@ For more information, see the function `buffer-menu'."
":" ;; (if (char-displayable-p ?…) "…" ":") ":" ;; (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) (if (> (+ (string-width name) (string-width size) 2)
Buffer-menu-buffer+size-width) Buffer-menu-buffer+size-width)
(setq name (setq name
...@@ -681,17 +681,9 @@ For more information, see the function `buffer-menu'." ...@@ -681,17 +681,9 @@ For more information, see the function `buffer-menu'."
(string-width tail) (string-width tail)
2)) 2))
Buffer-menu-short-ellipsis Buffer-menu-short-ellipsis
tail (string-mark-left-to-right 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). ;; Don't put properties on (buffer-name).
(setq name (concat (copy-sequence name) (setq name (string-mark-left-to-right name)))
(if lrm
(propertize (string ?\x200e) 'invisible t)
""))))
(add-text-properties 0 (length name) name-props name) (add-text-properties 0 (length name) name-props name)
(add-text-properties 0 (length size) size-props size) (add-text-properties 0 (length size) size-props size)
(let ((name+space-width (- Buffer-menu-buffer+size-width (let ((name+space-width (- Buffer-menu-buffer+size-width
...@@ -929,8 +921,7 @@ For more information, see the function `buffer-menu'." ...@@ -929,8 +921,7 @@ For more information, see the function `buffer-menu'."
(max (length size) 3) (max (length size) 3)
2)) 2))
name name
"mouse-2: select this buffer")) "mouse-2: select this buffer"))))
nil t))
" " " "
(if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width) (if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width)
(truncate-string-to-width (nth 4 buffer) (truncate-string-to-width (nth 4 buffer)
......
...@@ -258,7 +258,8 @@ to the entry with the same ID element as the current line." ...@@ -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 REMEMBER-POS was specified, move to the "old" location.
(if saved-pt (if saved-pt
(progn (goto-char saved-pt) (progn (goto-char saved-pt)
(move-to-column saved-col)) (move-to-column saved-col)
(recenter))
(goto-char (point-min))))) (goto-char (point-min)))))
(defun tabulated-list-print-entry (id cols) (defun tabulated-list-print-entry (id cols)
...@@ -282,6 +283,7 @@ of column descriptors." ...@@ -282,6 +283,7 @@ of column descriptors."
(> (length label) width) (> (length label) width)
(setq label (concat (substring label 0 (- width 3)) (setq label (concat (substring label 0 (- width 3))
"..."))) "...")))
(setq label (string-mark-left-to-right label))
(if (stringp desc) (if (stringp desc)
(insert (propertize label 'help-echo help-echo)) (insert (propertize label 'help-echo help-echo))
(apply 'insert-text-button label (cdr desc))) (apply 'insert-text-button label (cdr desc)))
......
...@@ -3538,6 +3538,20 @@ If IGNORE-CASE is non-nil, the comparison is done without paying attention ...@@ -3538,6 +3538,20 @@ If IGNORE-CASE is non-nil, the comparison is done without paying attention
to case differences." to case differences."
(eq t (compare-strings str1 nil nil (eq t (compare-strings str1 nil nil
str2 0 (length str1) ignore-case))) 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)))
'bidi-class)
'R))
(concat str (propertize (string ?\x200e) 'invisible t))
str))
;;;; invisibility specs ;;;; 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