emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r105429: New function `string-mar


From: Kenichi Handa
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r105429: New function `string-mark-left-to-right' for handling LRMs.
Date: Sat, 13 Aug 2011 16:00:40 +0900

In article <address@hidden>, Eli Zaretskii <address@hidden> writes:
> Btw, is there a way to regex-search for a character by its bidi
> category?  That would make the code more elegant, and probably quite
> faster as well.

You can do that as follows:

(1) Generate a special category table.

(defvar special-category-table-for-bidi
  (let ((category-table (make-category-table))
        (uniprop-table (unicode-property-table-internal 'bidi-class)))
    (define-category ?r "Bidi class R, AL, or RL" category-table)
    (map-char-table
     #'(lambda (key val)
         (if (memq val '(R AL RL))
             (modify-category-entry key ?r category-table)))
     uniprop-table)
    category-table))

(2) Check if a string or buffer contains a special bidi-related charaters.

;; For string...
(defun check-special-bidi-character (str)
  (with-category-table special-category-table-for-bidi
    (string-match "\\cr" str)))

(check-special-bidi-character "abc") => nil
(check-special-bidi-character "abc א") => 4

---
Kenichi Handa
address@hidden



reply via email to

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