diff options
| author | Eli Zaretskii | 2011-07-23 18:36:52 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-07-23 18:36:52 +0300 |
| commit | 5deb92fd9f7c5fece8ce5e4f3377d8b69f376fd6 (patch) | |
| tree | 6777d89e625df7d6ea2e964ba82a0bc7cc266f2d | |
| parent | be18c5a51f9a87f9842ac1a65004c9e44a9d6fd4 (diff) | |
| download | emacs-5deb92fd9f7c5fece8ce5e4f3377d8b69f376fd6.tar.gz emacs-5deb92fd9f7c5fece8ce5e4f3377d8b69f376fd6.zip | |
doc/lispref/display.texi (Bidirectional Display): New section.
| -rw-r--r-- | doc/lispref/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 130 |
2 files changed, 134 insertions, 0 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index 091a6ffda59..d59bbf87bce 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2011-07-23 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * display.texi (Bidirectional Display): New section. | ||
| 4 | |||
| 1 | 2011-07-16 Lars Magne Ingebrigtsen <larsi@gnus.org> | 5 | 2011-07-16 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | Tim Cross <theophilusx@gmail.com> (tiny change) | 6 | Tim Cross <theophilusx@gmail.com> (tiny change) |
| 3 | Glenn Morris <rgm@gnu.org> | 7 | Glenn Morris <rgm@gnu.org> |
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index d8be424a69f..903232bcbda 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -34,6 +34,8 @@ that Emacs presents to the user. | |||
| 34 | * Display Tables:: How to specify other conventions. | 34 | * Display Tables:: How to specify other conventions. |
| 35 | * Beeping:: Audible signal to the user. | 35 | * Beeping:: Audible signal to the user. |
| 36 | * Window Systems:: Which window system is being used. | 36 | * Window Systems:: Which window system is being used. |
| 37 | * Bidirectional Display:: Display of bidirectional scripts, such as | ||
| 38 | Arabic and Farsi. | ||
| 37 | @end menu | 39 | @end menu |
| 38 | 40 | ||
| 39 | @node Refresh Screen | 41 | @node Refresh Screen |
| @@ -5966,3 +5968,131 @@ This hook is used for internal purposes: setting up communication with | |||
| 5966 | the window system, and creating the initial window. Users should not | 5968 | the window system, and creating the initial window. Users should not |
| 5967 | interfere with it. | 5969 | interfere with it. |
| 5968 | @end defvar | 5970 | @end defvar |
| 5971 | |||
| 5972 | @node Bidirectional Display | ||
| 5973 | @section Bidirectional Display | ||
| 5974 | @cindex bidirectional display | ||
| 5975 | @cindex right-to-left text | ||
| 5976 | |||
| 5977 | Emacs can display text written in scripts, such as Arabic, Farsi, | ||
| 5978 | and Hebrew, whose natural ordering of horizontal text for display is | ||
| 5979 | from right to left. However, digits and Latin text embedded in these | ||
| 5980 | scripts are still displayed left to right. It is also not uncommon to | ||
| 5981 | have small portions of text in Arabic or Hebrew embedded in otherwise | ||
| 5982 | Latin document, e.g., as comments and strings in a program source | ||
| 5983 | file. Likewise, small portions of Latin text can be embedded in an | ||
| 5984 | Arabic or Farsi document. For these reasons, text that uses these | ||
| 5985 | scripts is actually @dfn{bidirectional}: a mixture of runs of | ||
| 5986 | left-to-right and right-to-left characters. | ||
| 5987 | |||
| 5988 | This section describes the facilities and options provided by Emacs | ||
| 5989 | for editing and displaying bidirectional text. | ||
| 5990 | |||
| 5991 | @cindex logical order | ||
| 5992 | @cindex visual order | ||
| 5993 | @cindex unicode bidirectional algorithm | ||
| 5994 | Emacs stores right-to-left and bidirectional text in the so-called | ||
| 5995 | @dfn{logical} (or @dfn{reading}) order: the buffer or string position | ||
| 5996 | of the first character you read precedes that of the next character. | ||
| 5997 | Reordering of bidirectional text into the @dfn{visual} order happens | ||
| 5998 | at display time. As result, character positions no longer increase | ||
| 5999 | monotonically with their positions on display. Emacs implements the | ||
| 6000 | Unicode Bidirectional Algorithm (a.k.a.@: @acronym{UBA}) described in | ||
| 6001 | the Unicode Standard Annex #9, for reordering of bidirectional text | ||
| 6002 | for display. Reordering of bidirectional text for display in Emacs is | ||
| 6003 | a ``Full bidirectionality'' class implementation of the @acronym{UBA}. | ||
| 6004 | |||
| 6005 | @defvar bidi-display-reordering | ||
| 6006 | The buffer-local variable @code{bidi-display-reordering} controls | ||
| 6007 | whether text in the buffer is reordered for display. If its value is | ||
| 6008 | non-@code{nil}, Emacs reorders characters that have right-to-left | ||
| 6009 | directionality when they are displayed. The default value is | ||
| 6010 | @code{nil}. Text in overlay strings (@pxref{Overlay | ||
| 6011 | Properties,,before-string}), display strings (@pxref{Overlay | ||
| 6012 | Properties,,display}), and @code{display} text properties | ||
| 6013 | (@pxref{Display Property}) is also reordered if the buffer whose text | ||
| 6014 | includes these strings is reordered for display. Turning off | ||
| 6015 | @code{bidi-display-reordering} for a buffer turns off reordering of | ||
| 6016 | all the overlay and display strings in that buffer. | ||
| 6017 | |||
| 6018 | Reordering of strings that are unrelated to any buffer, such as text | ||
| 6019 | displayed on the mode line (@pxref{Mode Line Format}) or header line | ||
| 6020 | (@pxref{Header Lines}), is controlled by the default value of | ||
| 6021 | @code{bidi-display-reordering}. | ||
| 6022 | @end defvar | ||
| 6023 | |||
| 6024 | @cindex unibyte buffers, and bidi reordering | ||
| 6025 | Emacs does not reorder text in unibyte buffers, even if | ||
| 6026 | @code{bidi-display-reordering} is non-@code{nil} in such a buffer. | ||
| 6027 | This is because unibyte buffers contain raw bytes, not characters, and | ||
| 6028 | thus don't have bidirectional properties defined for them which are | ||
| 6029 | required for correct reordering. Therefore, to test whether text in a | ||
| 6030 | buffer will be reordered for display, it is not enough to test the | ||
| 6031 | value of @code{bidi-display-reordering} alone. The correct test is | ||
| 6032 | this: | ||
| 6033 | |||
| 6034 | @example | ||
| 6035 | (if (and enable-multibyte-characters | ||
| 6036 | bidi-display-reordering) | ||
| 6037 | ;; Buffer is being reordered for display | ||
| 6038 | ) | ||
| 6039 | @end example | ||
| 6040 | |||
| 6041 | In contrast to unibyte buffers, unibyte display and overlay strings | ||
| 6042 | @emph{are} reordered, if their parent buffer is reordered. This is | ||
| 6043 | because plain-@sc{ascii} strings are stored by Emacs as unibyte | ||
| 6044 | strings. If a unibyte display or overlay string includes | ||
| 6045 | non-@sc{ascii} characters, these characters are assumed to have | ||
| 6046 | left-to-right direction. | ||
| 6047 | |||
| 6048 | @cindex display properties, and bidi reordering of text | ||
| 6049 | Text covered by @code{display} text properties, by overlays with | ||
| 6050 | @code{display} properties whose value is a string, and by any other | ||
| 6051 | properties that replace buffer text, is treated as a single unit when | ||
| 6052 | it is reordered for display. That is, the entire chunk of text | ||
| 6053 | covered by these properties is reordered together. Moreover, the | ||
| 6054 | bidirectional properties of the characters in this chunk of text are | ||
| 6055 | ignored, and Emacs reorders them as if they were replaced with a | ||
| 6056 | single character @code{u+FFFC}, known as the @dfn{Object Replacement | ||
| 6057 | Character}. This means that placing a display property over a portion | ||
| 6058 | of text may change the way that the surrounding text is reordered for | ||
| 6059 | display. To prevent this unexpected effect, always place such | ||
| 6060 | properties on text whose directionality is identical with text that | ||
| 6061 | surrounds it. | ||
| 6062 | |||
| 6063 | @cindex base direction of a paragraph | ||
| 6064 | Each paragraph of bidirectional text can have its own @dfn{base | ||
| 6065 | direction}, either right-to-left or left-to-right. Text in | ||
| 6066 | left-to-right paragraphs is displayed beginning at the left margin of | ||
| 6067 | the window and is truncated or continued when it reaches the right | ||
| 6068 | margin. By contrast, display of text in right-to-left paragraphs | ||
| 6069 | begins at the right margin and is continued or truncated at the left | ||
| 6070 | margin. | ||
| 6071 | |||
| 6072 | @defvar bidi-paragraph-direction | ||
| 6073 | Emacs determines the base direction of each paragraph dynamically, | ||
| 6074 | based on the text at the beginning of the paragraph. The precise | ||
| 6075 | method of determining the base direction is specified by the | ||
| 6076 | @acronym{UBA}; in a nutshell, the first character in a paragraph that | ||
| 6077 | has an explicit directionality determines the base direction of the | ||
| 6078 | paragraph. However, sometimes a buffer may need to force a certain | ||
| 6079 | base direction for its paragraphs. For example, a buffer that visits | ||
| 6080 | a source code of a program should force all its paragraphs to be | ||
| 6081 | displayed left to right. The variable | ||
| 6082 | @code{bidi-paragraph-direction}, if non-@code{nil}, disables the | ||
| 6083 | dynamic determination of the base direction, and instead forces all | ||
| 6084 | paragraphs in the buffer to have the direction specified by its | ||
| 6085 | buffer-local value. The value can be either @code{right-to-left} or | ||
| 6086 | @code{left-to-right}. Any other value is interpreted as @code{nil}. | ||
| 6087 | @end defvar | ||
| 6088 | |||
| 6089 | @defun current-bidi-paragraph-direction &optional buffer | ||
| 6090 | This function returns the paragraph direction at point in the named | ||
| 6091 | @var{buffer}. The returned value is a symbol, either | ||
| 6092 | @code{left-to-right} or @code{right-to-left}. If @var{buffer} is | ||
| 6093 | omitted or @code{nil}, it defaults to the current buffer. If the | ||
| 6094 | buffer-local value of the variable @code{bidi-paragraph-direction} is | ||
| 6095 | non-@code{nil}, the returned value will be identical to that value; | ||
| 6096 | otherwise, the returned value reflects the paragraph direction | ||
| 6097 | determined dynamically by Emacs. | ||
| 6098 | @end defun | ||