Hi
quite a while ago, I asked about the possibility of having TRUE R2L
(or BIDI) support for hebrew or any other R2L language with in
Mule. However it turned out that, while there will be or is a
rewritten display engine for GNU emacs (20.5), to rewrite the display
engine for xemacs is far more complicated and will not be done any
time soon.
Now I have a relatively simple question, which has nothing to do with
Mule, the iso-8859-8 is sufficient for my purpose: The basic primitive
idea is to write text with iso-885908 characters but L2R.
(The idea to have the cursor at the right and putting it to the left
visual mode) causes more problem than benefits)
However for TeX purpose the text has to be converted.
In the following sense:
Invert the order of words in a given
line and the order of the letter in a given word.: Example
Hello word.
gives
.drow olleH
For example the following will do it:
(defun ivrit-revers-region (arg)
"Does the same as ivrit-revers-buffer but only in marked regions"
(interactive "p")
(if (or (and
(boundp 'zmacs-region-active-p) zmacs-region-active-p)
(and (boundp 'transient-mark-mode) transient-mark-mode mark-active))
(save-restriction
(save-excursion
(narrow-to-region (point) (mark)) ;new finish here1
(goto-char (point-min))
(let ((begl 0)(endl 0)(not-end t))
(while not-end
(setq begl (point))
(end-of-line)
(setq endl (point))
(if (/= begl endl)
(let ((str (buffer-substring begl endl)))
(kill-region begl endl)
(insert (revers-string str))))
(setq not-end (eq (forward-line 1) 0))))))))
(defun revers-string (str)
(interactive)
(if (< (length str) 2)
str
(concat (revers-string (substring str 1)) (substring str 0 1))))
Or another possibility (given to me by Ehud Karni) is
(defun invert-line (&optional arg)
"Inverse line (right-left) if arg given, inverse arg chars"
(interactive "p")
(let* ((pos (point))
(eos (progn (if (< arg 2)
(end-of-line) (goto-col (1+ arg))) (point)))
(str (buffer-substring (progn (beginning-of-line) (point)) eos)))
(insert-string (invert-string str))
(delete-char (length str))
(goto-char pos)))
(defun invert-all-lines (&optional arg)
"Invert (right-left) all the lines in the buffer,
if arg given, inverse arg characters in each lines"
(interactive "p")
(goto-char (point-min))
(let* ((eol 0)
(bol 0)
(str ""))
(while (not (eobp))
(setq bol (point))
(end-of-line)
(if arg
(goto-col arg)
(end-of-line))
(setq eol (point))
(setq str (buffer-substring bol eol))
(delete-region bol eol)
(insert-string (invert-string str))
(forward-line 1))))
(defun invert-string (STR)
"Invert STRING (right-left) of any length"
(invert-sub-string 0 (length STR)) ;invert the whole string
STR)
Anyhow my question is simple but may be the answer is not so simple.
It is possible to modify these functions such that the only applies for
strings which have at least 2 characters however all the characters
have to be in the octal representation > 127. That would mean that
ASCII text remains unchanged but Hebrew text, > 127 will be changed.
The function iso-unaccentuate does precisely this, ie changes only
characters above 127. I tried to modify the reverse functions
mentioned above accordingly, but without success.
Does anybody has an idea?
Thanks in advance