diff options
| author | Eli Zaretskii | 2014-12-04 11:31:33 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2014-12-04 11:31:33 +0200 |
| commit | f1827846d715cfef05afe52ad2a9df2289df6952 (patch) | |
| tree | 048ee9690b7bcc87353137fe72031fe083908371 /doc/lispref | |
| parent | 2bef807c322b44cf63db85e4b60001a76cbe3d9f (diff) | |
| download | emacs-f1827846d715cfef05afe52ad2a9df2289df6952.tar.gz emacs-f1827846d715cfef05afe52ad2a9df2289df6952.zip | |
Implement copying of a buffer portion while preserving visual order.
See http://lists.gnu.org/archive/html/emacs-devel/2014-11/msg02203.html
and http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg00063.html
for the rationale.
lisp/simple.el (bidi-directional-controls-chars)
(bidi-directional-non-controls-chars): New variables.
(squeeze-bidi-context-1, squeeze-bidi-context)
(line-substring-with-bidi-context)
(buffer-substring-with-bidi-context): New functions.
doc/lispref/display.texi (Bidirectional Display): Document
'buffer-substring-with-bidi-context'.
doc/lispref/text.texi (Buffer Contents): Mention
'buffer-substring-with-bidi-context' with a cross-reference.
etc/NEWS: Mention 'buffer-substring-with-bidi-context'.
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/ChangeLog | 8 | ||||
| -rw-r--r-- | doc/lispref/display.texi | 24 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 6 |
3 files changed, 38 insertions, 0 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index f98e457566e..d8215be6b15 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2014-12-04 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * display.texi (Bidirectional Display): Document | ||
| 4 | 'buffer-substring-with-bidi-context'. | ||
| 5 | |||
| 6 | * text.texi (Buffer Contents): Mention | ||
| 7 | 'buffer-substring-with-bidi-context' with a cross-reference. | ||
| 8 | |||
| 1 | 2014-12-02 Eli Zaretskii <eliz@gnu.org> | 9 | 2014-12-02 Eli Zaretskii <eliz@gnu.org> |
| 2 | 10 | ||
| 3 | * display.texi (Bidirectional Display): Document | 11 | * display.texi (Bidirectional Display): Document |
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 59f73223a1f..90aa9797a59 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi | |||
| @@ -6854,3 +6854,27 @@ allows it to correctly account for window-specific overlays, which | |||
| 6854 | might change the result of the function if some text in the buffer is | 6854 | might change the result of the function if some text in the buffer is |
| 6855 | covered by overlays. | 6855 | covered by overlays. |
| 6856 | @end defun | 6856 | @end defun |
| 6857 | |||
| 6858 | @cindex copying bidirectional text, preserve visual order | ||
| 6859 | @cindex visual order, preserve when copying bidirectional text | ||
| 6860 | When text that includes mixed right-to-left and left-to-right | ||
| 6861 | characters and bidirectional controls is copied into a different | ||
| 6862 | location, it can change its visual appearance, and also can affect the | ||
| 6863 | visual appearance of the surrounding text at destination. This is | ||
| 6864 | because reordering of bidirectional text specified by the | ||
| 6865 | @acronym{UBA} has non-trivial context-dependent effects both on the | ||
| 6866 | copied text and on the text at copy destination that will surround it. | ||
| 6867 | |||
| 6868 | Sometimes, a Lisp program may need to preserve the exact visual | ||
| 6869 | appearance of the copied text at destination, and of the text that | ||
| 6870 | surrounds the copy. Lisp programs can use the following function to | ||
| 6871 | achieve that effect. | ||
| 6872 | |||
| 6873 | @defun buffer-substring-with-bidi-context start end &optional no-properties | ||
| 6874 | This function works similar to @code{buffer-substring} (@pxref{Buffer | ||
| 6875 | Contents}), but it prepends and appends to the copied text bidi | ||
| 6876 | directional control characters necessary to preserve the visual | ||
| 6877 | appearance of the text when it is inserted at another place. Optional | ||
| 6878 | argument @var{no-properties}, if non-@code{nil}, means remove the text | ||
| 6879 | properties from the copy of the text. | ||
| 6880 | @end defun | ||
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index 9c878a00c94..720343cb17d 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -219,6 +219,12 @@ This function returns the contents of the entire accessible portion of | |||
| 219 | the current buffer, as a string. | 219 | the current buffer, as a string. |
| 220 | @end defun | 220 | @end defun |
| 221 | 221 | ||
| 222 | If you need to make sure the resulting string, when copied to a | ||
| 223 | different location, will not change its visual appearance due to | ||
| 224 | reordering of bidirectional text, use the | ||
| 225 | @code{buffer-substring-with-bidi-context} function | ||
| 226 | (@pxref{Bidirectional Display, buffer-substring-with-bidi-context}). | ||
| 227 | |||
| 222 | @defun filter-buffer-substring start end &optional delete | 228 | @defun filter-buffer-substring start end &optional delete |
| 223 | This function filters the buffer text between @var{start} and @var{end} | 229 | This function filters the buffer text between @var{start} and @var{end} |
| 224 | using a function specified by the variable | 230 | using a function specified by the variable |