emacs-bidi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [emacs-bidi] bidi algorithm based on UAX#9


From: Alex Schroeder
Subject: Re: [emacs-bidi] bidi algorithm based on UAX#9
Date: Sat, 10 Nov 2001 21:55:31 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu)

progress report time...  :)


"Eli Zaretskii" <address@hidden> writes:

> I think that if you implement only the In clauses of UAX#9 (which
> resolve the implicit levels), you will get what you want, since
> visual-order text doesn't have explicit marks.  It seems to me that
> the implicit reordering is reversible.

Maybe I did get it wrong and I'm wasting way to much energy.  At the
moment I think that I have to implement W1 to W7, N1 and N2, and I1
and I2 (plus the reordering).

I think I'm doing a pretty good job, I already implemented W1 to W7.
I've attached W1 so that you can get an idea of what the code (and the
tests) look like.  And then you can tell me wether I'm on the right
track or not.  :)

If you are interested, I have a very simple bidi-table-test.el which
sets up the bidi categories as in the 500k file I sent *blush* -- but
for ASCII only -- and capital letters have the R category.  I hope
this will be usefull when testing my code later.

Alex.


(defun bidi-apply-w1 (sor types)
  "Apply UAX#9 rule W1.
SOR is the start-of-run bidi type.
TYPES is a list of bidi types to operate on.
TYPES will be modified in place.

Examine each non-spacing mark (NSM) in the level run, and change the
type of the NSM to the type of the previous character. If the NSM is at
the start of the level run, it will get the type of sor."
  ;; Skip this if no NSM types are found.
  (if (null (memq bidi-category-nsm types))
      types
    (let ((previous-type sor)
          (lst types))
      (while lst
        (if (= (car lst) bidi-category-nsm)
            (setcar lst previous-type)
          (setq previous-type (car lst)))
        (setq lst (cdr lst)))
      types)))

(when bidi-testing
  (assert (eq (bidi-apply-w1 nil nil) nil))
  (assert (equal (bidi-apply-w1
                  nil
                  (list bidi-category-al
                        bidi-category-nsm
                        bidi-category-nsm))
                 (list bidi-category-al
                       bidi-category-al
                       bidi-category-al)))
  (assert (equal (bidi-apply-w1
                  bidi-category-r
                  (list bidi-category-nsm))
                 (list bidi-category-r))))


 ... lots of stuff deleted ...

(defun bidi-resolve-weak-types (types &optional left)
  "Resolve weak bidi types in TYPES, a list of bidi categories.
The resulting list will have the same number of elements and all weak
types will be replaced by strong types.  If the optional argument LEFT
is given, the default embedding type will be right-to-left.  If LEFT is
nil, a default embedding of left-to-right will be assumed."
  ;; FIXME: This is not finished, yet.
  (let ((sor (bidi-find-sor types)))
    (bidi-apply-w7 sor
     (bidi-apply-w6
      (bidi-apply-w5
       (bidi-apply-w4
        (bidi-apply-w3
         (bidi-apply-w2 sor
          (bidi-apply-w1 sor types)))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]