aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-08-10 15:03:56 -0400
committerChong Yidong2011-08-10 15:03:56 -0400
commit3e26a4a28c6ad382f3bea07a1a6e0175ed8acdc6 (patch)
treee5b61892f81417d3af99a4b28e2153e55b0f8b7d
parentac8cf6e698c4612dc3ed195dbf1348db67f59fe5 (diff)
downloademacs-3e26a4a28c6ad382f3bea07a1a6e0175ed8acdc6.tar.gz
emacs-3e26a4a28c6ad382f3bea07a1a6e0175ed8acdc6.zip
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.
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/buff-menu.el17
-rw-r--r--lisp/emacs-lisp/tabulated-list.el4
-rw-r--r--lisp/subr.el14
5 files changed, 39 insertions, 14 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 6a1bb6c1c5e..6f8c125f7f9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1038,6 +1038,12 @@ of function value which looks like (closure ENV ARGS &rest BODY).
1038*** New function `special-variable-p' to check whether a variable is 1038*** New function `special-variable-p' to check whether a variable is
1039declared as dynamically bound. 1039declared as dynamically bound.
1040 1040
1041** New function `string-mark-left-to-right' appends a Unicode LRM
1042(left-to-right mark) character to a string if it terminates in
1043right-to-left script. This is useful when the buffer has overall
1044left-to-right paragraph direction and you need to insert a string
1045whose contents (and directionality) are not known in advance.
1046
1041** pre/post-command-hook are not reset to nil upon error. 1047** pre/post-command-hook are not reset to nil upon error.
1042Instead, the offending function is removed. 1048Instead, the offending function is removed.
1043 1049
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 780ea61a7ac..ad300b10f47 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12011-08-10 Chong Yidong <cyd@stupidchicken.com>
2
3 * subr.el (string-mark-left-to-right): New function.
4
5 * buff-menu.el (Buffer-menu-buffer+size): Remove LRM argument.
6 Use string-mark-left-to-right.
7 (list-buffers-noselect): Caller changed.
8
9 * emacs-lisp/tabulated-list.el (tabulated-list-print-entry): Use
10 string-mark-left-to-right.
11 (tabulated-list-print): Recenter after moving point.
12
12011-08-10 Juri Linkov <juri@jurta.org> 132011-08-10 Juri Linkov <juri@jurta.org>
2 14
3 * progmodes/grep.el (rgrep): Don't bind `process-connection-type'. 15 * progmodes/grep.el (rgrep): Don't bind `process-connection-type'.
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index f0a44747378..a5b45921d28 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -666,7 +666,7 @@ For more information, see the function `buffer-menu'."
666 ":" ;; (if (char-displayable-p ?…) "…" ":") 666 ":" ;; (if (char-displayable-p ?…) "…" ":")
667 ) 667 )
668 668
669(defun Buffer-menu-buffer+size (name size &optional name-props size-props lrm) 669(defun Buffer-menu-buffer+size (name size &optional name-props size-props)
670 (if (> (+ (string-width name) (string-width size) 2) 670 (if (> (+ (string-width name) (string-width size) 2)
671 Buffer-menu-buffer+size-width) 671 Buffer-menu-buffer+size-width)
672 (setq name 672 (setq name
@@ -681,17 +681,9 @@ For more information, see the function `buffer-menu'."
681 (string-width tail) 681 (string-width tail)
682 2)) 682 2))
683 Buffer-menu-short-ellipsis 683 Buffer-menu-short-ellipsis
684 tail 684 (string-mark-left-to-right tail))))
685 ;; Append an invisible LRM character to the
686 ;; buffer's name to avoid ugly display with the
687 ;; buffer size to the left of the name, when the
688 ;; name begins with R2L character.
689 (if lrm (propertize (string ?\x200e) 'invisible t) ""))))
690 ;; Don't put properties on (buffer-name). 685 ;; Don't put properties on (buffer-name).
691 (setq name (concat (copy-sequence name) 686 (setq name (string-mark-left-to-right name)))
692 (if lrm
693 (propertize (string ?\x200e) 'invisible t)
694 ""))))
695 (add-text-properties 0 (length name) name-props name) 687 (add-text-properties 0 (length name) name-props name)
696 (add-text-properties 0 (length size) size-props size) 688 (add-text-properties 0 (length size) size-props size)
697 (let ((name+space-width (- Buffer-menu-buffer+size-width 689 (let ((name+space-width (- Buffer-menu-buffer+size-width
@@ -929,8 +921,7 @@ For more information, see the function `buffer-menu'."
929 (max (length size) 3) 921 (max (length size) 3)
930 2)) 922 2))
931 name 923 name
932 "mouse-2: select this buffer")) 924 "mouse-2: select this buffer"))))
933 nil t))
934 " " 925 " "
935 (if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width) 926 (if (> (string-width (nth 4 buffer)) Buffer-menu-mode-width)
936 (truncate-string-to-width (nth 4 buffer) 927 (truncate-string-to-width (nth 4 buffer)
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 2fdfa9525b1..9b485b58608 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -258,7 +258,8 @@ to the entry with the same ID element as the current line."
258 ;; If REMEMBER-POS was specified, move to the "old" location. 258 ;; If REMEMBER-POS was specified, move to the "old" location.
259 (if saved-pt 259 (if saved-pt
260 (progn (goto-char saved-pt) 260 (progn (goto-char saved-pt)
261 (move-to-column saved-col)) 261 (move-to-column saved-col)
262 (recenter))
262 (goto-char (point-min))))) 263 (goto-char (point-min)))))
263 264
264(defun tabulated-list-print-entry (id cols) 265(defun tabulated-list-print-entry (id cols)
@@ -282,6 +283,7 @@ of column descriptors."
282 (> (length label) width) 283 (> (length label) width)
283 (setq label (concat (substring label 0 (- width 3)) 284 (setq label (concat (substring label 0 (- width 3))
284 "..."))) 285 "...")))
286 (setq label (string-mark-left-to-right label))
285 (if (stringp desc) 287 (if (stringp desc)
286 (insert (propertize label 'help-echo help-echo)) 288 (insert (propertize label 'help-echo help-echo))
287 (apply 'insert-text-button label (cdr desc))) 289 (apply 'insert-text-button label (cdr desc)))
diff --git a/lisp/subr.el b/lisp/subr.el
index d57c507a548..a897da1d9ba 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -3538,6 +3538,20 @@ If IGNORE-CASE is non-nil, the comparison is done without paying attention
3538to case differences." 3538to case differences."
3539 (eq t (compare-strings str1 nil nil 3539 (eq t (compare-strings str1 nil nil
3540 str2 0 (length str1) ignore-case))) 3540 str2 0 (length str1) ignore-case)))
3541
3542(defun string-mark-left-to-right (str)
3543 "Return a string that can be safely embedded in left-to-right text.
3544If STR ends in right-to-left (RTL) script, return a string
3545consisting of STR followed by an invisible left-to-right
3546mark (LRM) character. Otherwise, return STR."
3547 (unless (stringp str)
3548 (signal 'wrong-type-argument (list 'stringp str)))
3549 (if (and (> (length str) 0)
3550 (eq (get-char-code-property (aref str (1- (length str)))
3551 'bidi-class)
3552 'R))
3553 (concat str (propertize (string ?\x200e) 'invisible t))
3554 str))
3541 3555
3542;;;; invisibility specs 3556;;;; invisibility specs
3543 3557