emacs-bidi
[Top][All Lists]
Advanced

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

Re: [emacs-bidi] mirroring of glyphs


From: Alex Schroeder
Subject: Re: [emacs-bidi] mirroring of glyphs
Date: Mon, 19 Nov 2001 17:12:02 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu)

Eli Zaretskii <address@hidden> writes:

>> (bidi-visual-to-logical-test "abc ECNO abc ~~~23%%% TSET" 'R2L 'string)
>> "   a   b   c       E   C   N   O       a   b   c       ~   ~   ~   2   3   
>> %   %   %       T   S   E   T"
>
> I don't understand: you should have reversed this first, since it's an 
> R2L context, but it looks like you didn't?  (The same is true for the 
> first example, which worked.)

I wrote bidi-visual-to-logical-test so that I can easily modify it and
get debugging info from it.  So when I use bidi-visual-to-logical-test
the input is reversed and the output is reversed again.

It's an ugly defun now, because I pulled the various components into
one single defun.

(defun bidi-visual-to-logical-test (str context &optional debug)
  "FIXME"
  (when (eq context 'R2L)
    (setq str (string-reverse str)))
  (let* ((paragraph-level (if (eq context 'R2L) 1 0))
         (e (if (eq context 'R2L) bidi-category-r bidi-category-l))
         (sor e)
         (eor e)
         (types (bidi-get-types str))
         (resolved-types (bidi-apply-n2 e
                          (bidi-apply-n1 sor eor
                           (bidi-apply-w7 sor
                            (bidi-apply-w6
                             (bidi-apply-w5
                              (bidi-apply-w4
                               (bidi-apply-w3
                                (bidi-apply-w2 sor
                                 (bidi-apply-w1 sor
                                  (bidi-get-types str)))))))))))
         (levels (bidi-resolve-implicit-levels
                  resolved-types
                  (make-list (length str) paragraph-level))))
    (when (eq context 'R2L)
      (setq levels (nreverse levels)
            types (nreverse types)
            resolved-types (nreverse resolved-types)
            str (string-reverse str)))
    (cond ((eq debug 'levels)
           (bidi-pretty-print levels))
          ((eq debug 'resolved-types)
           (bidi-pretty-print (bidi-get-mnemonics resolved-types)))
          ((eq debug 'types)
           (bidi-pretty-print (bidi-get-mnemonics types)))
          ((eq debug 'string)
           (bidi-pretty-print str))
          (t
           (bidi-reorder-string str levels)))))
;; (defalias 'bidi-visual-to-logical 'bidi-visual-to-logical-test)

Alex.
-- 
http://www.emacswiki.org/



reply via email to

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