[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r105429: New function `string-mark-le
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r105429: New function `string-mark-left-to-right' for handling LRMs. |
Date: |
Wed, 10 Aug 2011 15:03:56 -0400 |
User-agent: |
Bazaar (2.3.1) |
------------------------------------------------------------
revno: 105429
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Wed 2011-08-10 15:03:56 -0400
message:
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.
modified:
etc/NEWS
lisp/ChangeLog
lisp/buff-menu.el
lisp/emacs-lisp/tabulated-list.el
lisp/subr.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS 2011-07-28 20:23:19 +0000
+++ b/etc/NEWS 2011-08-10 19:03:56 +0000
@@ -1038,6 +1038,12 @@
*** 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.
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2011-08-10 18:29:31 +0000
+++ b/lisp/ChangeLog 2011-08-10 19:03:56 +0000
@@ -1,3 +1,15 @@
+2011-08-10 Chong Yidong <address@hidden>
+
+ * 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 <address@hidden>
* progmodes/grep.el (rgrep): Don't bind `process-connection-type'.
=== modified file 'lisp/buff-menu.el'
--- a/lisp/buff-menu.el 2011-07-14 17:28:42 +0000
+++ b/lisp/buff-menu.el 2011-08-10 19:03:56 +0000
@@ -666,7 +666,7 @@
":" ;; (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)
Buffer-menu-buffer+size-width)
(setq name
@@ -681,17 +681,9 @@
(string-width tail)
2))
Buffer-menu-short-ellipsis
- 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 @@
(max (length size) 3)
2))
name
- "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)
=== modified file 'lisp/emacs-lisp/tabulated-list.el'
--- a/lisp/emacs-lisp/tabulated-list.el 2011-04-18 23:21:31 +0000
+++ b/lisp/emacs-lisp/tabulated-list.el 2011-08-10 19:03:56 +0000
@@ -258,7 +258,8 @@
;; 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)
+ (recenter))
(goto-char (point-min)))))
(defun tabulated-list-print-entry (id cols)
@@ -282,6 +283,7 @@
(> (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)))
=== modified file 'lisp/subr.el'
--- a/lisp/subr.el 2011-08-03 21:40:06 +0000
+++ b/lisp/subr.el 2011-08-10 19:03:56 +0000
@@ -3538,6 +3538,20 @@
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)))
+ 'bidi-class)
+ 'R))
+ (concat str (propertize (string ?\x200e) 'invisible t))
+ str))
;;;; invisibility specs
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r105429: New function `string-mark-left-to-right' for handling LRMs.,
Chong Yidong <=