Mercurial > hg > xemacs-beta
view lisp/mule/thai-util.el @ 4690:257b468bf2ca
Move the #'query-coding-region implementation to C.
This is necessary because there is no reasonable way to access the
corresponding mswindows-multibyte functionality from Lisp, and we need such
functionality if we're going to have a reliable and portable
#'query-coding-region implementation. However, this change doesn't yet
provide #'query-coding-region for the mswindow-multibyte coding systems,
there should be no functional differences between an XEmacs with this change
and one without it.
src/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
Move the #'query-coding-region implementation to C.
This is necessary because there is no reasonable way to access the
corresponding mswindows-multibyte functionality from Lisp, and we
need such functionality if we're going to have a reliable and
portable #'query-coding-region implementation. However, this
change doesn't yet provide #'query-coding-region for the
mswindow-multibyte coding systems, there should be no functional
differences between an XEmacs with this change and one without it.
* mule-coding.c (struct fixed_width_coding_system):
Add a new coding system type, fixed_width, and implement it. It
uses the CCL infrastructure but has a much simpler creation API,
and its own query_method, formerly in lisp/mule/mule-coding.el.
* unicode.c:
Move the Unicode query method implementation here from
unicode.el.
* lisp.h: Declare Fmake_coding_system_internal, Fcopy_range_table
here.
* intl-win32.c (complex_vars_of_intl_win32):
Use Fmake_coding_system_internal, not Fmake_coding_system.
* general-slots.h: Add Qsucceeded, Qunencodable, Qinvalid_sequence
here.
* file-coding.h (enum coding_system_variant):
Add fixed_width_coding_system here.
(struct coding_system_methods):
Add query_method and query_lstream_method to the coding system
methods.
Provide flags for the query methods.
Declare the default query method; initialise it correctly in
INITIALIZE_CODING_SYSTEM_TYPE.
* file-coding.c (default_query_method):
New function, the default query method for coding systems that do
not set it. Moved from coding.el.
(make_coding_system_1):
Accept new elements in PROPS in #'make-coding-system; aliases, a
list of aliases; safe-chars and safe-charsets (these were
previously accepted but not saved); and category.
(Fmake_coding_system_internal):
New function, what used to be #'make-coding-system--on Mule
builds, we've now moved some of the functionality of this to
Lisp.
(Fcoding_system_canonical_name_p):
Move this earlier in the file, since it's now called from within
make_coding_system_1.
(Fquery_coding_region):
Move the implementation of this here, from coding.el.
(complex_vars_of_file_coding):
Call Fmake_coding_system_internal, not Fmake_coding_system;
specify safe-charsets properties when we're a mule build.
* extents.h (mouse_highlight_priority, Fset_extent_priority,
Fset_extent_face, Fmap_extents):
Make these available to other C files.
lisp/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
Move the #'query-coding-region implementation to C.
* coding.el:
Consolidate code that depends on the presence or absence of Mule
at the end of this file.
(default-query-coding-region, query-coding-region):
Move these functions to C.
(default-query-coding-region-safe-charset-skip-chars-map):
Remove this variable, the corresponding C variable is
Vdefault_query_coding_region_chartab_cache in file-coding.c.
(query-coding-string): Update docstring to reflect actual multiple
values, be more careful about not modifying a range table that
we're currently mapping over.
(encode-coding-char): Make the implementation of this simpler.
(featurep 'mule): Autoload #'make-coding-system from
mule/make-coding-system.el if we're a mule build; provide an
appropriate compiler macro.
Do various non-mule compatibility things if we're not a mule
build.
* update-elc.el (additional-dump-dependencies):
Add mule/make-coding-system as a dump time dependency if we're a
mule build.
* unicode.el (ccl-encode-to-ucs-2):
(decode-char):
(encode-char):
Move these earlier in the file, for the sake of some byte compile
warnings.
(unicode-query-coding-region):
Move this to unicode.c
* mule/make-coding-system.el:
New file, not dumped. Contains the functionality to rework the
arguments necessary for fixed-width coding systems, and contains
the implementation of #'make-coding-system, which now calls
#'make-coding-system-internal.
* mule/vietnamese.el (viscii):
* mule/latin.el (iso-8859-2):
(windows-1250):
(iso-8859-3):
(iso-8859-4):
(iso-8859-14):
(iso-8859-15):
(iso-8859-16):
(iso-8859-9):
(macintosh):
(windows-1252):
* mule/hebrew.el (iso-8859-8):
* mule/greek.el (iso-8859-7):
(windows-1253):
* mule/cyrillic.el (iso-8859-5):
(koi8-r):
(koi8-u):
(windows-1251):
(alternativnyj):
(koi8-ru):
(koi8-t):
(koi8-c):
(koi8-o):
* mule/arabic.el (iso-8859-6):
(windows-1256):
Move all these coding systems to being of type fixed-width, not of
type CCL. This allows the distinct query-coding-region for them to
be in C, something which will eventually allow us to implement
query-coding-region for the mswindows-multibyte coding systems.
* mule/general-late.el (posix-charset-to-coding-system-hash):
Document why we're pre-emptively persuading the byte compiler that
the ELC for this file needs to be written using escape-quoted.
Call #'set-unicode-query-skip-chars-args, now the Unicode
query-coding-region implementation is in C.
* mule/thai-xtis.el (tis-620):
Don't bother checking whether we're XEmacs or not here.
* mule/mule-coding.el:
Move the eight bit fixed-width functionality from this file to
make-coding-system.el.
tests/ChangeLog addition:
2009-09-19 Aidan Kehoe <kehoea@parhasard.net>
* automated/mule-tests.el:
Check a coding system's type, not an 8-bit-fixed property, for
whether that coding system should be treated as a fixed-width
coding system.
* automated/query-coding-tests.el:
Don't test the query coding functionality for mswindows-multibyte
coding systems, it's not yet implemented.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 19 Sep 2009 22:53:13 +0100 |
parents | 2923009caf47 |
children | 3889ef128488 308d34e9f07d |
line wrap: on
line source
;;; thai-util.el --- utilities for Thai -*- coding: iso-2022-7bit; -*- ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. ;; Licensed to the Free Software Foundation. ;; Keywords: mule, multilingual, thai ;; This file is part of XEmacs. ;; XEmacs is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; XEmacs is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with XEmacs; see the file COPYING. If not, write to the Free ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ;; 02111-1307, USA. ;;; Synched up with: Emacs 21.1 (language/thai-util.el). ;;; Commentary: ;;; Code: ;; Setting information of Thai characters. (defconst thai-category-table (make-category-table)) (define-category ?c "Thai consonant" thai-category-table) (define-category ?v "Thai upper/lower vowel" thai-category-table) (define-category ?t "Thai tone" thai-category-table) ;; The general composing rules are as follows: ;; ;; T ;; V T V T ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C ;; v v ;; ;; where C: consonant, V: vowel upper, v: vowel lower, T: tone mark. (defvar thai-composition-pattern "\\cc\\(\\ct\\|\\cv\\ct?\\)" "Regular expression matching a Thai composite sequence.") (let ((l '((?,T!(B consonant "LETTER KO KAI") ; 0xA1 (?,T"(B consonant "LETTER KHO KHAI") ; 0xA2 (?,T#(B consonant "LETTER KHO KHUAT") ; 0xA3 (?,T$(B consonant "LETTER KHO KHWAI") ; 0xA4 (?,T%(B consonant "LETTER KHO KHON") ; 0xA5 (?,T&(B consonant "LETTER KHO RAKHANG") ; 0xA6 (?,T'(B consonant "LETTER NGO NGU") ; 0xA7 (?,T((B consonant "LETTER CHO CHAN") ; 0xA8 (?,T)(B consonant "LETTER CHO CHING") ; 0xA9 (?,T*(B consonant "LETTER CHO CHANG") ; 0xAA (?,T+(B consonant "LETTER SO SO") ; 0xAB (?,T,(B consonant "LETTER CHO CHOE") ; 0xAC (?,T-(B consonant "LETTER YO YING") ; 0xAD (?,T.(B consonant "LETTER DO CHADA") ; 0xAE (?,T/(B consonant "LETTER TO PATAK") ; 0xAF (?,T0(B consonant "LETTER THO THAN") ; 0xB0 (?,T1(B consonant "LETTER THO NANGMONTHO") ; 0xB1 (?,T2(B consonant "LETTER THO PHUTHAO") ; 0xB2 (?,T3(B consonant "LETTER NO NEN") ; 0xB3 (?,T4(B consonant "LETTER DO DEK") ; 0xB4 (?,T5(B consonant "LETTER TO TAO") ; 0xB5 (?,T6(B consonant "LETTER THO THUNG") ; 0xB6 (?,T7(B consonant "LETTER THO THAHAN") ; 0xB7 (?,T8(B consonant "LETTER THO THONG") ; 0xB8 (?,T9(B consonant "LETTER NO NU") ; 0xB9 (?,T:(B consonant "LETTER BO BAIMAI") ; 0xBA (?,T;(B consonant "LETTER PO PLA") ; 0xBB (?,T<(B consonant "LETTER PHO PHUNG") ; 0xBC (?,T=(B consonant "LETTER FO FA") ; 0xBD (?,T>(B consonant "LETTER PHO PHAN") ; 0xBE (?,T?(B consonant "LETTER FO FAN") ; 0xBF (?,T@(B consonant "LETTER PHO SAMPHAO") ; 0xC0 (?,TA(B consonant "LETTER MO MA") ; 0xC1 (?,TB(B consonant "LETTER YO YAK") ; 0xC2 (?,TC(B consonant "LETTER RO RUA") ; 0xC3 (?,TD(B vowel-base "LETTER RU (Pali vowel letter)") ; 0xC4 (?,TE(B consonant "LETTER LO LING") ; 0xC5 (?,TF(B vowel-base "LETTER LU (Pali vowel letter)") ; 0xC6 (?,TG(B consonant "LETTER WO WAEN") ; 0xC7 (?,TH(B consonant "LETTER SO SALA") ; 0xC8 (?,TI(B consonant "LETTER SO RUSI") ; 0xC9 (?,TJ(B consonant "LETTER SO SUA") ; 0xCA (?,TK(B consonant "LETTER HO HIP") ; 0xCB (?,TL(B consonant "LETTER LO CHULA") ; 0xCC (?,TM(B consonant "LETTER O ANG") ; 0xCD (?,TN(B consonant "LETTER HO NOK HUK") ; 0xCE (?,TO(B special "PAI YAN NOI (abbreviation)") ; 0xCF (?,TP(B vowel-base "VOWEL SIGN SARA A") ; 0xD0 (?,TQ(B vowel-upper "VOWEL SIGN MAI HAN-AKAT N/S-T") ; 0xD1 (?,TR(B vowel-base "VOWEL SIGN SARA AA") ; 0xD2 (?,TS(B vowel-base "VOWEL SIGN SARA AM") ; 0xD3 (?,TT(B vowel-upper "VOWEL SIGN SARA I N/S-T") ; 0xD4 (?,TU(B vowel-upper "VOWEL SIGN SARA II N/S-T") ; 0xD5 (?,TV(B vowel-upper "VOWEL SIGN SARA UE N/S-T") ; 0xD6 (?,TW(B vowel-upper "VOWEL SIGN SARA UEE N/S-T") ; 0xD7 (?,TX(B vowel-lower "VOWEL SIGN SARA U N/S-B") ; 0xD8 (?,TY(B vowel-lower "VOWEL SIGN SARA UU N/S-B") ; 0xD9 (?,TZ(B vowel-lower "VOWEL SIGN PHINTHU N/S-B (Pali virama)") ; 0xDA (?,T[(B invalid nil) ; 0xDA (?,T\(B invalid nil) ; 0xDC (?,T](B invalid nil) ; 0xDC (?,T^(B invalid nil) ; 0xDC (?,T_(B special "BAHT SIGN (currency symbol)") ; 0xDF (?,T`(B vowel-base "VOWEL SIGN SARA E") ; 0xE0 (?,Ta(B vowel-base "VOWEL SIGN SARA AE") ; 0xE1 (?,Tb(B vowel-base "VOWEL SIGN SARA O") ; 0xE2 (?,Tc(B vowel-base "VOWEL SIGN SARA MAI MUAN") ; 0xE3 (?,Td(B vowel-base "VOWEL SIGN SARA MAI MALAI") ; 0xE4 (?,Te(B vowel-base "LAK KHANG YAO") ; 0xE5 (?,Tf(B special "MAI YAMOK (repetion)") ; 0xE6 (?,Tg(B vowel-upper "VOWEL SIGN MAI TAI KHU N/S-T") ; 0xE7 (?,Th(B tone "TONE MAI EK N/S-T") ; 0xE8 (?,Ti(B tone "TONE MAI THO N/S-T") ; 0xE9 (?,Tj(B tone "TONE MAI TRI N/S-T") ; 0xEA (?,Tk(B tone "TONE MAI CHATTAWA N/S-T") ; 0xEB (?,Tl(B tone "THANTHAKHAT N/S-T (cancellation mark)") ; 0xEC (?,Tm(B tone "NIKKHAHIT N/S-T (final nasal)") ; 0xED (?,Tn(B vowel-upper "YAMAKKAN N/S-T") ; 0xEE (?,To(B special "FONRMAN") ; 0xEF (?,Tp(B special "DIGIT ZERO") ; 0xF0 (?,Tq(B special "DIGIT ONE") ; 0xF1 (?,Tr(B special "DIGIT TWO") ; 0xF2 (?,Ts(B special "DIGIT THREE") ; 0xF3 (?,Tt(B special "DIGIT FOUR") ; 0xF4 (?,Tu(B special "DIGIT FIVE") ; 0xF5 (?,Tv(B special "DIGIT SIX") ; 0xF6 (?,Tw(B special "DIGIT SEVEN") ; 0xF7 (?,Tx(B special "DIGIT EIGHT") ; 0xF8 (?,Ty(B special "DIGIT NINE") ; 0xF9 (?,Tz(B special "ANGKHANKHU (ellipsis)") ; 0xFA (?,T{(B special "KHOMUT (beginning of religious texts)") ; 0xFB (?,T|(B invalid nil) ; 0xFC (?,T}(B invalid nil) ; 0xFD (?,T~(B invalid nil) ; 0xFE )) elm) (while l (setq elm (car l) l (cdr l)) (let ((char (car elm)) (ptype (nth 1 elm))) (put-char-code-property char 'phonetic-type ptype) (cond ((eq ptype 'consonant) (modify-category-entry char ?c thai-category-table)) ((memq ptype '(vowel-upper vowel-lower)) (modify-category-entry char ?v thai-category-table)) ((eq ptype 'tone) (modify-category-entry char ?t thai-category-table))) (put-char-code-property char 'name (nth 2 elm))))) ;;;###autoload (defun thai-compose-region (beg end) "Compose Thai characters in the region. When called from a program, expects two arguments, positions (integers or markers) specifying the region." (interactive "r") (save-restriction (narrow-to-region beg end) (goto-char (point-min)) (with-category-table thai-category-table (while (re-search-forward thai-composition-pattern nil t) (compose-region (match-beginning 0) (match-end 0)))))) ;;;###autoload (defun thai-compose-string (string) "Compose Thai characters in STRING and return the resulting string." (with-category-table thai-category-table (let ((idx 0)) (while (setq idx (string-match thai-composition-pattern string idx)) (compose-string string idx (match-end 0)) (setq idx (match-end 0))))) string) ;;;###autoload (defun thai-compose-buffer () "Compose Thai characters in the current buffer." (interactive) (thai-compose-region (point-min) (point-max))) ;;;###autoload (defun thai-post-read-conversion (len) (thai-compose-region (point) (+ (point) len)) len) ;;;###autoload (defun thai-composition-function (from to pattern &optional string) "Compose Thai text in the region FROM and TO. The text matches the regular expression PATTERN. Optional 4th argument STRING, if non-nil, is a string containing text to compose. The return value is number of composed characters." (if (< (1+ from) to) (prog1 (- to from) (if string (compose-string string from to) (compose-region from to)) (- to from)))) ;; (provide 'thai-util) ;;; thai-util.el ends here