aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorEli Zaretskii2014-12-04 11:31:33 +0200
committerEli Zaretskii2014-12-04 11:31:33 +0200
commitf1827846d715cfef05afe52ad2a9df2289df6952 (patch)
tree048ee9690b7bcc87353137fe72031fe083908371 /doc/lispref
parent2bef807c322b44cf63db85e4b60001a76cbe3d9f (diff)
downloademacs-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/ChangeLog8
-rw-r--r--doc/lispref/display.texi24
-rw-r--r--doc/lispref/text.texi6
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 @@
12014-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
12014-12-02 Eli Zaretskii <eliz@gnu.org> 92014-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
6854might change the result of the function if some text in the buffer is 6854might change the result of the function if some text in the buffer is
6855covered by overlays. 6855covered 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
6861characters and bidirectional controls is copied into a different
6862location, it can change its visual appearance, and also can affect the
6863visual appearance of the surrounding text at destination. This is
6864because reordering of bidirectional text specified by the
6865@acronym{UBA} has non-trivial context-dependent effects both on the
6866copied 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
6869appearance of the copied text at destination, and of the text that
6870surrounds the copy. Lisp programs can use the following function to
6871achieve that effect.
6872
6873@defun buffer-substring-with-bidi-context start end &optional no-properties
6874This function works similar to @code{buffer-substring} (@pxref{Buffer
6875Contents}), but it prepends and appends to the copied text bidi
6876directional control characters necessary to preserve the visual
6877appearance of the text when it is inserted at another place. Optional
6878argument @var{no-properties}, if non-@code{nil}, means remove the text
6879properties 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
219the current buffer, as a string. 219the 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
223different location, will not change its visual appearance due to
224reordering 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
223This function filters the buffer text between @var{start} and @var{end} 229This function filters the buffer text between @var{start} and @var{end}
224using a function specified by the variable 230using a function specified by the variable