aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/ChangeLog12
-rw-r--r--doc/lispref/display.texi104
-rw-r--r--doc/lispref/nonascii.texi7
-rw-r--r--etc/NEWS1
4 files changed, 107 insertions, 17 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 56175a34eee..03a20ba5830 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,15 @@
12011-08-18 Eli Zaretskii <eliz@gnu.org>
2
3 * nonascii.texi (Character Properties): Document use of
4 `bidi-class' and `mirroring' properties as part of reordering.
5 Provide cross-references to "Bidirectional Display".
6
7 * display.texi (Bidirectional Display): Document the pitfalls of
8 concatenating strings with bidirectional content, with possible
9 solutions. Document string-mark-left-to-right. Mention paragraph
10 direction in modes that inherit from prog-mode. Document use of
11 `bidi-class' and `mirroring' properties as part of reordering.
12
12011-08-16 Eli Zaretskii <eliz@gnu.org> 132011-08-16 Eli Zaretskii <eliz@gnu.org>
2 14
3 * modes.texi (Major Mode Conventions): Improve the documentation 15 * modes.texi (Major Mode Conventions): Improve the documentation
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 64a9054f596..7e7851452d8 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5992,6 +5992,7 @@ left-to-right and right-to-left characters.
5992for editing and displaying bidirectional text. 5992for editing and displaying bidirectional text.
5993 5993
5994@cindex logical order 5994@cindex logical order
5995@cindex reading order
5995@cindex visual order 5996@cindex visual order
5996@cindex unicode bidirectional algorithm 5997@cindex unicode bidirectional algorithm
5997 Emacs stores right-to-left and bidirectional text in the so-called 5998 Emacs stores right-to-left and bidirectional text in the so-called
@@ -6006,17 +6007,16 @@ for display. Reordering of bidirectional text for display in Emacs is
6006a ``Full bidirectionality'' class implementation of the @acronym{UBA}. 6007a ``Full bidirectionality'' class implementation of the @acronym{UBA}.
6007 6008
6008@defvar bidi-display-reordering 6009@defvar bidi-display-reordering
6009 The buffer-local variable @code{bidi-display-reordering} controls 6010 This buffer-local variable controls whether text in the buffer is
6010whether text in the buffer is reordered for display. If its value is 6011reordered for display. If its value is non-@code{nil}, Emacs reorders
6011non-@code{nil}, Emacs reorders characters that have right-to-left 6012characters that have right-to-left directionality when they are
6012directionality when they are displayed. The default value is 6013displayed. The default value is @code{t}. Text in overlay strings
6013@code{t}. Text in overlay strings (@pxref{Overlay 6014(@pxref{Overlay Properties,,before-string}), display strings
6014Properties,,before-string}), display strings (@pxref{Overlay 6015(@pxref{Overlay Properties,,display}), and @code{display} text
6015Properties,,display}), and @code{display} text properties 6016properties (@pxref{Display Property}) is also reordered for display if
6016(@pxref{Display Property}) is also reordered if the buffer whose text 6017the buffer whose text includes these strings is reordered. Turning
6017includes these strings is reordered for display. Turning off 6018off @code{bidi-display-reordering} for a buffer turns off reordering
6018@code{bidi-display-reordering} for a buffer turns off reordering of 6019of all the overlay and display strings in that buffer.
6019all the overlay and display strings in that buffer.
6020 6020
6021 Reordering of strings that are unrelated to any buffer, such as text 6021 Reordering of strings that are unrelated to any buffer, such as text
6022displayed on the mode line (@pxref{Mode Line Format}) or header line 6022displayed on the mode line (@pxref{Mode Line Format}) or header line
@@ -6056,7 +6056,7 @@ it is reordered for display. That is, the entire chunk of text
6056covered by these properties is reordered together. Moreover, the 6056covered by these properties is reordered together. Moreover, the
6057bidirectional properties of the characters in this chunk of text are 6057bidirectional properties of the characters in this chunk of text are
6058ignored, and Emacs reorders them as if they were replaced with a 6058ignored, and Emacs reorders them as if they were replaced with a
6059single character @code{u+FFFC}, known as the @dfn{Object Replacement 6059single character @code{U+FFFC}, known as the @dfn{Object Replacement
6060Character}. This means that placing a display property over a portion 6060Character}. This means that placing a display property over a portion
6061of text may change the way that the surrounding text is reordered for 6061of text may change the way that the surrounding text is reordered for
6062display. To prevent this unexpected effect, always place such 6062display. To prevent this unexpected effect, always place such
@@ -6073,9 +6073,9 @@ begins at the right margin and is continued or truncated at the left
6073margin. 6073margin.
6074 6074
6075@defvar bidi-paragraph-direction 6075@defvar bidi-paragraph-direction
6076 Emacs determines the base direction of each paragraph dynamically, 6076 By default, Emacs determines the base direction of each paragraph
6077based on the text at the beginning of the paragraph. The precise 6077dynamically, based on the text at the beginning of the paragraph. The
6078method of determining the base direction is specified by the 6078precise method of determining the base direction is specified by the
6079@acronym{UBA}; in a nutshell, the first character in a paragraph that 6079@acronym{UBA}; in a nutshell, the first character in a paragraph that
6080has an explicit directionality determines the base direction of the 6080has an explicit directionality determines the base direction of the
6081paragraph. However, sometimes a buffer may need to force a certain 6081paragraph. However, sometimes a buffer may need to force a certain
@@ -6087,6 +6087,13 @@ dynamic determination of the base direction, and instead forces all
6087paragraphs in the buffer to have the direction specified by its 6087paragraphs in the buffer to have the direction specified by its
6088buffer-local value. The value can be either @code{right-to-left} or 6088buffer-local value. The value can be either @code{right-to-left} or
6089@code{left-to-right}. Any other value is interpreted as @code{nil}. 6089@code{left-to-right}. Any other value is interpreted as @code{nil}.
6090The default is @code{nil}.
6091
6092@cindex @code{prog-mode}, and @code{bidi-paragraph-direction}
6093Modes that are meant to display program source code should force a
6094@code{left-to-right} paragraph direction. The easiest way of doing so
6095is to derive the mode from Prog Mode, which already sets
6096@code{bidi-paragraph-direction} to that value.
6090@end defvar 6097@end defvar
6091 6098
6092@defun current-bidi-paragraph-direction &optional buffer 6099@defun current-bidi-paragraph-direction &optional buffer
@@ -6099,3 +6106,70 @@ non-@code{nil}, the returned value will be identical to that value;
6099otherwise, the returned value reflects the paragraph direction 6106otherwise, the returned value reflects the paragraph direction
6100determined dynamically by Emacs. 6107determined dynamically by Emacs.
6101@end defun 6108@end defun
6109
6110@cindex layout on display, and bidirectional text
6111@cindex jumbled display of bidirectional text
6112@cindex concatenating bidirectional strings
6113 Reordering of bidirectional text for display can have surprising and
6114unpleasant effects when two strings with bidirectional content are
6115juxtaposed in a buffer, or otherwise programmatically concatenated
6116into a string of text. A typical example is a buffer whose lines are
6117actually sequences of items, or fields, separated by whitespace or
6118punctuation characters. This is used in specialized modes such as
6119Buffer-menu Mode or various email summary modes, like Rmail Summary
6120Mode. Because these separator characters are @dfn{weak}, i.e.@: have
6121no strong directionality, they take on the directionality of
6122surrounding text. As result, a numeric field that follows a field
6123with bidirectional content can be displayed @emph{to the left} of the
6124preceding field, producing a jumbled display and messing up the
6125expected layout.
6126
6127 To countermand this, you can use one of the following techniques for
6128forcing correct order of fields on display:
6129
6130@itemize @minus
6131@item
6132Append the special character @code{U+200E}, LEFT-TO-RIGHT MARK, or
6133@acronym{LRM}, to the end of each field that may have bidirectional
6134content, or prepend it to the beginning of the following field. The
6135function @code{string-mark-left-to-right}, described below, comes in
6136handy for this purpose. (In a right-to-left paragraph, use
6137@code{U+200F}, RIGHT-TO-LEFT MARK, or @acronym{RLM}, instead.) This
6138is one of the solutions recommended by
6139@uref{http://www.unicode.org/reports/tr9/#Separators, the
6140@acronym{UBA}}.
6141
6142@item
6143Include the tab character in the field separator. The tab character
6144plays the role of @dfn{segment separator} in the @acronym{UBA}
6145reordering, whose effect is to make each field a separate segment, and
6146thus reorder them separately.
6147@end itemize
6148
6149@defun string-mark-left-to-right string
6150This subroutine returns its argument @var{string}, possibly modified,
6151such that the result can be safely concatenated with another string,
6152or juxtaposed with another string in a buffer, without disrupting the
6153relative layout of this string and the next one on display. If the
6154string returned by this function is displayed as part of a
6155left-to-right paragraph, it will always appear on display to the left
6156of the text that follows it. The function works by examining the
6157characters of its argument, and if any of those characters could cause
6158reordering on display, the function appends the @acronym{LRM}
6159character to the string. The appended @acronym{LRM} character is made
6160@emph{invisible} (@pxref{Invisible Text}), to hide it on display.
6161@end defun
6162
6163 The reordering algorithm uses the bidirectional properties of the
6164characters stored as their @code{bidi-class} property
6165(@pxref{Character Properties}). Lisp programs can change these
6166properties by calling the @code{put-char-code-property} function.
6167However, doing this requires a thorough understanding of the
6168@acronym{UBA}, and is therefore not recommended. Any changes to the
6169bidirectional properties of a character have global effect: they
6170affect all Emacs frames and windows.
6171
6172 Similarly, the @code{mirroring} property is used to display the
6173appropriate mirrored character in the reordered text. Lisp programs
6174can affect the mirrored display by changing this property. Again, any
6175such changes affect all of Emacs display.
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 83f9f424834..7b6d665b2ac 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -392,7 +392,8 @@ The value is an integer number.
392@item bidi-class 392@item bidi-class
393Corresponds to the Unicode @code{Bidi_Class} property. The value is a 393Corresponds to the Unicode @code{Bidi_Class} property. The value is a
394symbol whose name is the Unicode @dfn{directional type} of the 394symbol whose name is the Unicode @dfn{directional type} of the
395character. 395character. Emacs uses this property when it reorders bidirectional
396text for display (@pxref{Bidirectional Display}).
396 397
397@item decomposition 398@item decomposition
398Corresponds to the Unicode @code{Decomposition_Type} and 399Corresponds to the Unicode @code{Decomposition_Type} and
@@ -440,7 +441,9 @@ defined mirroring glyph. All the characters whose @code{mirrored}
440property is @code{N} have @code{nil} as their @code{mirroring} 441property is @code{N} have @code{nil} as their @code{mirroring}
441property; however, some characters whose @code{mirrored} property is 442property; however, some characters whose @code{mirrored} property is
442@code{Y} also have @code{nil} for @code{mirroring}, because no 443@code{Y} also have @code{nil} for @code{mirroring}, because no
443appropriate characters exist with mirrored glyphs. 444appropriate characters exist with mirrored glyphs. Emacs uses this
445property to display mirror images of characters when appropriate
446(@pxref{Bidirectional Display}).
444 447
445@item old-name 448@item old-name
446Corresponds to the Unicode @code{Unicode_1_Name} property. The value 449Corresponds to the Unicode @code{Unicode_1_Name} property. The value
diff --git a/etc/NEWS b/etc/NEWS
index 8707a8b0adc..ed472a5668a 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1043,6 +1043,7 @@ of function value which looks like (closure ENV ARGS &rest BODY).
1043*** New function `special-variable-p' to check whether a variable is 1043*** New function `special-variable-p' to check whether a variable is
1044declared as dynamically bound. 1044declared as dynamically bound.
1045 1045
1046+++
1046** New function `string-mark-left-to-right'. 1047** New function `string-mark-left-to-right'.
1047Given a string containing right-to-left (RTL) script, this function 1048Given a string containing right-to-left (RTL) script, this function
1048returns another string with a terminating LRM (left-to-right mark) 1049returns another string with a terminating LRM (left-to-right mark)