diff options
| author | Chong Yidong | 2011-08-18 11:53:29 -0400 |
|---|---|---|
| committer | Chong Yidong | 2011-08-18 11:53:29 -0400 |
| commit | f635daa1e056a564d13b4ef1ea8d1a4ff5b7401c (patch) | |
| tree | 6b6f721809174e63545eccd2ff502ff67356c9fa | |
| parent | 156bffbe26748a0e60ec7125da4b960a0b6b455f (diff) | |
| download | emacs-f635daa1e056a564d13b4ef1ea8d1a4ff5b7401c.tar.gz emacs-f635daa1e056a564d13b4ef1ea8d1a4ff5b7401c.zip | |
Add L and R categories to standard category table, and use them.
* lisp/international/characters.el: Add L and R categories.
* lisp/subr.el (bidi-string-mark-left-to-right): Rename from
string-mark-left-to-right. Use category search.
* lisp/buff-menu.el (Buffer-menu-buffer+size): Callers changed.
| -rw-r--r-- | etc/NEWS | 13 | ||||
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/buff-menu.el | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 2 | ||||
| -rw-r--r-- | lisp/international/characters.el | 20 | ||||
| -rw-r--r-- | lisp/subr.el | 31 |
6 files changed, 51 insertions, 28 deletions
| @@ -1047,15 +1047,16 @@ of function value which looks like (closure ENV ARGS &rest BODY). | |||
| 1047 | declared as dynamically bound. | 1047 | declared as dynamically bound. |
| 1048 | 1048 | ||
| 1049 | +++ | 1049 | +++ |
| 1050 | ** New function `string-mark-left-to-right'. | 1050 | ** New function `bidi-string-mark-left-to-right'. |
| 1051 | Given a string containing right-to-left (RTL) script, this function | 1051 | Given a string containing right-to-left (RTL) script, this function |
| 1052 | returns another string with a terminating LRM (left-to-right mark) | 1052 | returns another string which can be safely inserted into a buffer as a |
| 1053 | character. If this string is inserted into a buffer, Emacs treats the | 1053 | distinct RTL "segment", without causing any following text to be |
| 1054 | LRM as the end of an RTL segment and displays following text as LTR. | 1054 | displayed as RTL. (This is done by appending a Unicode "left-to-right |
| 1055 | mark" character.) | ||
| 1055 | 1056 | ||
| 1056 | This is useful when the buffer has overall left-to-right (LTR) | 1057 | This is useful when the buffer has overall left-to-right (LTR) |
| 1057 | paragraph direction and you need to insert a string whose contents | 1058 | paragraph direction and you need to insert a string whose contents and |
| 1058 | (and hence directionality) are not known in advance. | 1059 | directionality are not known in advance. |
| 1059 | 1060 | ||
| 1060 | ** pre/post-command-hook are not reset to nil upon error. | 1061 | ** pre/post-command-hook are not reset to nil upon error. |
| 1061 | Instead, the offending function is removed. | 1062 | Instead, the offending function is removed. |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4f0e832bc67..38c536af62c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2011-08-18 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * international/characters.el: Add L and R categories. | ||
| 4 | |||
| 5 | * subr.el (bidi-string-mark-left-to-right): Rename from | ||
| 6 | string-mark-left-to-right. Use category search. | ||
| 7 | |||
| 8 | * buff-menu.el (Buffer-menu-buffer+size): Callers changed. | ||
| 9 | |||
| 1 | 2011-08-18 Juri Linkov <juri@jurta.org> | 10 | 2011-08-18 Juri Linkov <juri@jurta.org> |
| 2 | 11 | ||
| 3 | * faces.el (error, warning, success): New faces with definitions | 12 | * faces.el (error, warning, success): New faces with definitions |
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el index a5b45921d28..2eac33d8157 100644 --- a/lisp/buff-menu.el +++ b/lisp/buff-menu.el | |||
| @@ -681,9 +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 | (string-mark-left-to-right tail)))) | 684 | (bidi-string-mark-left-to-right tail)))) |
| 685 | ;; Don't put properties on (buffer-name). | 685 | ;; Don't put properties on (buffer-name). |
| 686 | (setq name (string-mark-left-to-right name))) | 686 | (setq name (bidi-string-mark-left-to-right name))) |
| 687 | (add-text-properties 0 (length name) name-props name) | 687 | (add-text-properties 0 (length name) name-props name) |
| 688 | (add-text-properties 0 (length size) size-props size) | 688 | (add-text-properties 0 (length size) size-props size) |
| 689 | (let ((name+space-width (- Buffer-menu-buffer+size-width | 689 | (let ((name+space-width (- Buffer-menu-buffer+size-width |
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 9b485b58608..75c9a01323d 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el | |||
| @@ -283,7 +283,7 @@ of column descriptors." | |||
| 283 | (> (length label) width) | 283 | (> (length label) width) |
| 284 | (setq label (concat (substring label 0 (- width 3)) | 284 | (setq label (concat (substring label 0 (- width 3)) |
| 285 | "..."))) | 285 | "..."))) |
| 286 | (setq label (string-mark-left-to-right label)) | 286 | (setq label (bidi-string-mark-left-to-right label)) |
| 287 | (if (stringp desc) | 287 | (if (stringp desc) |
| 288 | (insert (propertize label 'help-echo help-echo)) | 288 | (insert (propertize label 'help-echo help-echo)) |
| 289 | (apply 'insert-text-button label (cdr desc))) | 289 | (apply 'insert-text-button label (cdr desc))) |
diff --git a/lisp/international/characters.el b/lisp/international/characters.el index a9657c17b9f..47426784e51 100644 --- a/lisp/international/characters.el +++ b/lisp/international/characters.el | |||
| @@ -114,6 +114,16 @@ A character which can't be placed at end of line.") | |||
| 114 | Base characters (Unicode General Category L,N,P,S,Zs)") | 114 | Base characters (Unicode General Category L,N,P,S,Zs)") |
| 115 | (define-category ?^ "Combining | 115 | (define-category ?^ "Combining |
| 116 | Combining diacritic or mark (Unicode General Category M)") | 116 | Combining diacritic or mark (Unicode General Category M)") |
| 117 | |||
| 118 | ;; bidi types | ||
| 119 | (define-category ?R "Right-to-left (strong) | ||
| 120 | Characters with \"strong\" right-to-left directionality, i.e. | ||
| 121 | with R, AL, RLE, or RLO Unicode bidi character type.") | ||
| 122 | |||
| 123 | (define-category ?L "Left-to-right (strong) | ||
| 124 | Characters with \"strong\" left-to-right directionality, i.e. | ||
| 125 | with L, LRE, or LRO Unicode bidi character type.") | ||
| 126 | |||
| 117 | 127 | ||
| 118 | ;;; Setting syntax and category. | 128 | ;;; Setting syntax and category. |
| 119 | 129 | ||
| @@ -478,6 +488,16 @@ Combining diacritic or mark (Unicode General Category M)") | |||
| 478 | (modify-category-entry x category)) | 488 | (modify-category-entry x category)) |
| 479 | chars))))) | 489 | chars))))) |
| 480 | 490 | ||
| 491 | ;; Bidi categories | ||
| 492 | |||
| 493 | (map-char-table (lambda (key val) | ||
| 494 | (cond | ||
| 495 | ((memq val '(R AL RLO RLE)) | ||
| 496 | (modify-category-entry key ?R)) | ||
| 497 | ((memq val '(L LRE LRO)) | ||
| 498 | (modify-category-entry key ?L)))) | ||
| 499 | (unicode-property-table-internal 'bidi-class)) | ||
| 500 | |||
| 481 | ;; Latin | 501 | ;; Latin |
| 482 | 502 | ||
| 483 | (modify-category-entry '(#x80 . #x024F) ?l) | 503 | (modify-category-entry '(#x80 . #x024F) ?l) |
diff --git a/lisp/subr.el b/lisp/subr.el index a4251b6fee6..9aa895b0e94 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -3539,30 +3539,23 @@ to 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 | 3541 | ||
| 3542 | (defun string-mark-left-to-right (str) | 3542 | (defun bidi-string-mark-left-to-right (str) |
| 3543 | "Return a string that can be safely inserted in left-to-right text. | 3543 | "Return a string that can be safely inserted in left-to-right text. |
| 3544 | If STR contains right-to-left (RTL) script, return a string | ||
| 3545 | consisting of STR followed by a terminating invisible | ||
| 3546 | left-to-right mark (LRM) character. | ||
| 3547 | 3544 | ||
| 3548 | The LRM character marks the end of an RTL segment, and resets the | 3545 | Normally, inserting a string with right-to-left (RTL) script into |
| 3549 | display direction of any subsequent text to left-to-right. | 3546 | a buffer may cause some subsequent text to be displayed as part |
| 3550 | \(Otherwise, some of that text might be displayed as part of the | 3547 | of the RTL segment (usually this affects punctuation characters). |
| 3551 | RTL segment, based on the bidirectional display algorithm.) | 3548 | This function returns a string which displays as STR but forces |
| 3549 | subsequent text to be displayed as left-to-right. | ||
| 3552 | 3550 | ||
| 3553 | If STR contains no RTL characters, return STR." | 3551 | If STR contains any RTL character, this function returns a string |
| 3552 | consisting of STR followed by an invisible left-to-right mark | ||
| 3553 | \(LRM) character. Otherwise, it returns STR." | ||
| 3554 | (unless (stringp str) | 3554 | (unless (stringp str) |
| 3555 | (signal 'wrong-type-argument (list 'stringp str))) | 3555 | (signal 'wrong-type-argument (list 'stringp str))) |
| 3556 | (let ((len (length str)) | 3556 | (if (string-match "\\cR" str) |
| 3557 | (n 0) | 3557 | (concat str (propertize (string ?\x200e) 'invisible t)) |
| 3558 | rtl-found) | 3558 | str)) |
| 3559 | (while (and (not rtl-found) (< n len)) | ||
| 3560 | (setq rtl-found (memq (get-char-code-property | ||
| 3561 | (aref str n) 'bidi-class) '(R AL RLO)) | ||
| 3562 | n (1+ n))) | ||
| 3563 | (if rtl-found | ||
| 3564 | (concat str (propertize (string ?\x200e) 'invisible t)) | ||
| 3565 | str))) | ||
| 3566 | 3559 | ||
| 3567 | ;;;; invisibility specs | 3560 | ;;;; invisibility specs |
| 3568 | 3561 | ||