aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2011-07-23 18:36:52 +0300
committerEli Zaretskii2011-07-23 18:36:52 +0300
commit5deb92fd9f7c5fece8ce5e4f3377d8b69f376fd6 (patch)
tree6777d89e625df7d6ea2e964ba82a0bc7cc266f2d
parentbe18c5a51f9a87f9842ac1a65004c9e44a9d6fd4 (diff)
downloademacs-5deb92fd9f7c5fece8ce5e4f3377d8b69f376fd6.tar.gz
emacs-5deb92fd9f7c5fece8ce5e4f3377d8b69f376fd6.zip
doc/lispref/display.texi (Bidirectional Display): New section.
-rw-r--r--doc/lispref/ChangeLog4
-rw-r--r--doc/lispref/display.texi130
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 @@
12011-07-23 Eli Zaretskii <eliz@gnu.org>
2
3 * display.texi (Bidirectional Display): New section.
4
12011-07-16 Lars Magne Ingebrigtsen <larsi@gnus.org> 52011-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
5966the window system, and creating the initial window. Users should not 5968the window system, and creating the initial window. Users should not
5967interfere with it. 5969interfere 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,
5978and Hebrew, whose natural ordering of horizontal text for display is
5979from right to left. However, digits and Latin text embedded in these
5980scripts are still displayed left to right. It is also not uncommon to
5981have small portions of text in Arabic or Hebrew embedded in otherwise
5982Latin document, e.g., as comments and strings in a program source
5983file. Likewise, small portions of Latin text can be embedded in an
5984Arabic or Farsi document. For these reasons, text that uses these
5985scripts is actually @dfn{bidirectional}: a mixture of runs of
5986left-to-right and right-to-left characters.
5987
5988 This section describes the facilities and options provided by Emacs
5989for 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
5996of the first character you read precedes that of the next character.
5997Reordering of bidirectional text into the @dfn{visual} order happens
5998at display time. As result, character positions no longer increase
5999monotonically with their positions on display. Emacs implements the
6000Unicode Bidirectional Algorithm (a.k.a.@: @acronym{UBA}) described in
6001the Unicode Standard Annex #9, for reordering of bidirectional text
6002for display. Reordering of bidirectional text for display in Emacs is
6003a ``Full bidirectionality'' class implementation of the @acronym{UBA}.
6004
6005@defvar bidi-display-reordering
6006 The buffer-local variable @code{bidi-display-reordering} controls
6007whether text in the buffer is reordered for display. If its value is
6008non-@code{nil}, Emacs reorders characters that have right-to-left
6009directionality when they are displayed. The default value is
6010@code{nil}. Text in overlay strings (@pxref{Overlay
6011Properties,,before-string}), display strings (@pxref{Overlay
6012Properties,,display}), and @code{display} text properties
6013(@pxref{Display Property}) is also reordered if the buffer whose text
6014includes these strings is reordered for display. Turning off
6015@code{bidi-display-reordering} for a buffer turns off reordering of
6016all the overlay and display strings in that buffer.
6017
6018 Reordering of strings that are unrelated to any buffer, such as text
6019displayed 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.
6027This is because unibyte buffers contain raw bytes, not characters, and
6028thus don't have bidirectional properties defined for them which are
6029required for correct reordering. Therefore, to test whether text in a
6030buffer will be reordered for display, it is not enough to test the
6031value of @code{bidi-display-reordering} alone. The correct test is
6032this:
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
6043because plain-@sc{ascii} strings are stored by Emacs as unibyte
6044strings. If a unibyte display or overlay string includes
6045non-@sc{ascii} characters, these characters are assumed to have
6046left-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
6051properties that replace buffer text, is treated as a single unit when
6052it is reordered for display. That is, the entire chunk of text
6053covered by these properties is reordered together. Moreover, the
6054bidirectional properties of the characters in this chunk of text are
6055ignored, and Emacs reorders them as if they were replaced with a
6056single character @code{u+FFFC}, known as the @dfn{Object Replacement
6057Character}. This means that placing a display property over a portion
6058of text may change the way that the surrounding text is reordered for
6059display. To prevent this unexpected effect, always place such
6060properties on text whose directionality is identical with text that
6061surrounds it.
6062
6063@cindex base direction of a paragraph
6064 Each paragraph of bidirectional text can have its own @dfn{base
6065direction}, either right-to-left or left-to-right. Text in
6066left-to-right paragraphs is displayed beginning at the left margin of
6067the window and is truncated or continued when it reaches the right
6068margin. By contrast, display of text in right-to-left paragraphs
6069begins at the right margin and is continued or truncated at the left
6070margin.
6071
6072@defvar bidi-paragraph-direction
6073 Emacs determines the base direction of each paragraph dynamically,
6074based on the text at the beginning of the paragraph. The precise
6075method of determining the base direction is specified by the
6076@acronym{UBA}; in a nutshell, the first character in a paragraph that
6077has an explicit directionality determines the base direction of the
6078paragraph. However, sometimes a buffer may need to force a certain
6079base direction for its paragraphs. For example, a buffer that visits
6080a source code of a program should force all its paragraphs to be
6081displayed left to right. The variable
6082@code{bidi-paragraph-direction}, if non-@code{nil}, disables the
6083dynamic determination of the base direction, and instead forces all
6084paragraphs in the buffer to have the direction specified by its
6085buffer-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
6090This 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
6093omitted or @code{nil}, it defaults to the current buffer. If the
6094buffer-local value of the variable @code{bidi-paragraph-direction} is
6095non-@code{nil}, the returned value will be identical to that value;
6096otherwise, the returned value reflects the paragraph direction
6097determined dynamically by Emacs.
6098@end defun