emacs-bidi
[Top][All Lists]
Advanced

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

[emacs-bidi] emacs-bidi summary for XEmacs people


From: Alex Schroeder
Subject: [emacs-bidi] emacs-bidi summary for XEmacs people
Date: Tue, 13 Nov 2001 01:37:49 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (i686-pc-linux-gnu)

Hi XEmacs people,

As to bidi, I have code now which more or less does the bidi algorithm
without explicit direction codes.  It is therefore not useful when
transforming logical to visual order.  It is, however, useful when
transforming visual to logical.  And since I think that adding the
explicit direction code treatment ought to be very easy, I may still
add it in the days to come.  All of this plus some testing of the
functions is in bidi.el.

The bidi code I use needs tables that classify characters according to
the bidi types used in the Unicode Tech Report, UAX#9.  These tables
use the bidi type classification from unicode.org, and it uses this
info for all the 8859 charsets.  This is in bidi-table.el -- about
500k.

I also have a test table which only sets bidi types for ASCII
characters and which uses the bidi type R (like Hebrew and Arabic) for
capital letters.  This is great when tinkering with the code and when
writing test cases in plain ASCII.  This is in bidi-table-test.el --
about 5k.

The classification of characters in Emacs relies on Category Tables.
In Emacs, these categories can be modified on the Lisp level.  Since I
didn't want to reserve any categories, I'm getting some unused
categories when bidi.el is loaded.  This seems not to work in XEmacs.

Here's the main setup:

(defun bidi-setup-categories ()
  "Create new categories for bidi according to UAX#9.
This sets all the categories defined in `bidi-categories'."
  (let ((table (standard-category-table)))
    (mapc (lambda (var)
              (let ((cat (get-unused-category table))
                    (doc (get var 'variable-documentation)))
                (when (symbol-value var)
                  (error "%S is already set" var))
                (unless cat
                  (error "No more unused categories available"))
                (set var cat)
                (define-category cat doc table)))
            bidi-categories)))

This uses the variables in the following lists:

(defvar bidi-categories
  '(bidi-category-l
    bidi-category-lre
    bidi-category-lro
    bidi-category-r
    bidi-category-al
    bidi-category-rle
    bidi-category-rlo
    bidi-category-pdf
    bidi-category-en
    bidi-category-es
    bidi-category-et
    bidi-category-an
    bidi-category-cs
    bidi-category-nsm
    bidi-category-bn
    bidi-category-b
    bidi-category-s
    bidi-category-ws
    bidi-category-on)
  "List of categories variables used by bidi algorithms.
Each category variable holds a character.  This character
identifies the category.")

After running bidi-setup-categories, the bidi-category-* variables all
hold a character, each used for a different category.  The tables then
use the categories thus defined.

One way to do this in XEmacs would be to add the categories at the C
level (the lispref didn't have much to say on categories), or to
create a new category table where our categories will not clash with
existing categories.  I don't know how much memory a new category
table would actually use, perhaps that would seem the best alternative.

Anyway, if you are interested in the code, send me mail.

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



reply via email to

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