[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-bidi] reordering based on implicit levels
From: |
Alex Schroeder |
Subject: |
Re: [emacs-bidi] reordering based on implicit levels |
Date: |
Mon, 12 Nov 2001 03:24:08 +0100 |
User-agent: |
Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu) |
"Eli Zaretskii" <address@hidden> writes:
> I'd prefer to get the code you have to work on paragraphs, because
> that's by far the most frequent use it will get (I think).
Will do.
> Note that UAX#9 rules that every line is a separate paragraph (because
> \n is defined as a NEUTRAL_B character), but Emacs cannot behave like
> this because we use newlines for filling text. This is not much of a
> complication for you, and perhaps you could even ignore that subtlety
> altogether, since visual order doesn't have embedding levels, but
> please be aware of this, just in case.
Hm. Here's what happens if I don't do anything. It seems to work...
(let ((str "this is a normal paragraph containing some
words in ARAB and HEBREW. these strings need to be
reverted. numbers like 123 should work, even when
ENCLOSED IN ARAB TEXT SUCH AS 4567.89 IS ON THIS LINE."))
(bidi-reorder-string
str
(bidi-resolve-implicit-levels
(bidi-resolve-weak-types
(bidi-get-types str)))))
=>
"this is a normal paragraph containing some
words in BARA and WERBEH. these strings need to be
reverted. numbers like 123 should work, even when
ENIL SIHT NO SI 4567.89 SA HCUS TXET BARA NI DESOLCNE."
I therefore assume that the following will work as expected.
(defun bidi-reorder-region (start end)
"Reorder the region between START and END."
(interactive "r")
(let ((str (buffer-substring start end)))
(delete-region start end)
(goto-char start)
(insert
(bidi-reorder-string
str
(bidi-resolve-implicit-levels
(bidi-resolve-weak-types
(bidi-get-types str)))))))
(defun bidi-reorder-paragraph ()
"Reorder the current paragraph."
(interactive)
(let ((start (save-excursion
(backward-paragraph)
(point)))
(end (save-excursion
(forward-paragraph)
(point))))
(bidi-reorder-region start end)))
;; The functions above should work for the following paragraph as well:
;; this is a normal paragraph containing some
;; words in ARAB and HEBREW. these strings need to be
;; reverted. numbers like 123 should work, even when
;; ENCLOSED IN ARAB TEXT SUCH AS 4567.89 IS ON THIS LINE.
Alex.
--
http://www.emacswiki.org/
- Re: [emacs-bidi] reordering based on implicit levels, (continued)
Re: [emacs-bidi] reordering based on implicit levels, Alex Schroeder, 2001/11/11
[emacs-bidi] explicit formatting codes in visual-order text, Alex Schroeder, 2001/11/11
Re: [emacs-bidi] reordering based on implicit levels,
Alex Schroeder <=