annotate lisp/language/tv-util.el @ 91735:4240048b8e8d

EasyPG: Remove epg-package-info and epa-setup
author Michael Olson <mwolson@gnu.org>
date Mon, 11 Feb 2008 00:02:41 +0000
parents 0c76c1616cf9
children 55b7f25d920a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 ;;; tv-util.el --- support for Tai Viet -*- coding: utf-8 -*-
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2
91437
0c76c1616cf9 Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 91277
diff changeset
3 ;; Copyright (C) 2007, 2008
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 ;; National Institute of Advanced Industrial Science and Technology (AIST)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 ;; Registration Number H13PRO009
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7 ;; Keywords: multilingual, Tai Viet, i18n
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
91437
0c76c1616cf9 Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents: 91277
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14 ;; any later version.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 ;;; Code
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
28 ;; Regexp matching with a sequence of Tai Viet characters.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
29 (defconst tai-viet-re
91217
9cf3b1c148b9 (tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents: 90950
diff changeset
30 (format "[\xaa80-\xaac2\xaadb-\xaadf-]+"))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
31
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
32 ;; Char-table of information about glyph type of Tai Viet characters.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
33 (defconst tai-viet-glyph-info
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
34 (let ((table (make-char-table nil))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
35 (specials '((right-overhang . "ꪊꪋꪌꪍꪏꪓꪖꪜꪞꪡꪤꪨ")
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36 (left-overhang . "ꫂ")
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 (combining-vowel . "ꪴꪰꪲꪳꪷꪸꪾ")
91217
9cf3b1c148b9 (tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents: 90950
diff changeset
38 (combining-tone . "꪿꫁")
9cf3b1c148b9 (tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents: 90950
diff changeset
39 (misc . "-"))))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40 ;; Set all TaiViet characters to `t'.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
41 (set-char-table-range table (cons #xaa80 #xaac2) t)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 (set-char-table-range table (cons #xaadb #xaadf) t)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43 ;; Overwrite it for special characters.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
44 (dolist (elt specials)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 (let ((category (car elt))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46 (chars (cdr elt)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
47 (dotimes (i (length chars))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 (aset table (aref chars i) category))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 table))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 (defun tai-viet-compose-string (from to string)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 "Compose Tai Viet characters in STRING between indices FROM and TO."
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53 (let* ((ch (aref string from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
54 (info (aref tai-viet-glyph-info ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
55 prev-info)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
56 (if (eq info 'non-spacing)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
57 (compose-string string from (1+ from) (string ch ?\t)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
58 (setq from (1+ from) prev-info info)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 (while (and (< from to)
90949
bba587c2b334 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 90938
diff changeset
60 (>= #xaa80 (setq ch (aref string from)))
bba587c2b334 *** empty log message ***
Kenichi Handa <handa@m17n.org>
parents: 90938
diff changeset
61 (<= #xaaDF ch))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
62 (setq info (aref tai-viet-glyph-info ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
63 (if (and (eq info 'non-spacing)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
64 (eq prev-info 'non-spacing))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
65 (compose-string from (1+ from) (string ?\t ch)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
66 (setq from (1+ from) prev-info info))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
67 (if (eq info 'right-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
68 (compose-string string (1- from) from (string ch ?\t)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
71 (defun tai-viet-compose-region (from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 "Compose Tai Viet characters in the region between FROM and TO."
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73 (decompose-region from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
74 (let ((normal-rule '(Br . Bl))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 (tone-rule '(tr . bl))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76 (prev-viet nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 ch info pos components overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 (while (< from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79 (or ch
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 (setq ch (char-after from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 info (aref tai-viet-glyph-info ch)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82 (setq from (1+ from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
83 (if (not info)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
84 (setq prev-viet nil
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
85 ch nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86 (if (memq info '(combining-vowel combining-tone))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 (progn
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 ;; Display this as a spacing glyph.
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 (compose-region (1- from) from (string ?\t ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 (setq prev-viet t
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 ch nil))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92 (setq pos (1- from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 components ch
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 overhang (if (eq info 'right-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95 'right-overhang
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 (if (and (not prev-viet) (eq info 'left-overhang))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 'left-overhang))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98 prev-viet t
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 ch nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 (if (and (< from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 (setq ch (char-after from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 info (aref tai-viet-glyph-info ch)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103 (if (memq info '(combining-vowel combining-tone))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
104 (progn
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 (setq components
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 (list components normal-rule ch)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 from (1+ from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 ch nil)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 (if (and (< from to)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 (setq ch (char-after from)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 info (aref tai-viet-glyph-info ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112 (eq info 'combining-tone))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
113 (setq components (nconc components
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
114 (list tone-rule ch))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
115 from (1+ from)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116 (if (eq overhang 'left-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 (setq components (cons ?\t
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 (cons normal-rule components)))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 (if (and (eq overhang 'right-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 (>= from to))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 (setq components (nconc components
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 (list normal-rule ?\t)))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 (compose-region pos from components))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 (if (eq overhang 'left-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 (compose-region pos from (string ?\t components))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 (if (eq overhang 'left-overhang)
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 (compose-region pos from (string ?\t components))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128 (if (and (eq overhang 'right-overhang) (>= from to))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129 (compose-region pos from (string components ?\t))))))))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 from))
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
131
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
132
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
133 ;;;###autoload
91277
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
134 (defun tai-viet-composition-function (from to font-object string)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
135 (if string
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
136 (if (string-match tai-viet-re string from)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
137 (tai-viet-compose-string from (match-end 0) string))
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
138 (goto-char from)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
139 (if (looking-at tai-viet-re)
0dfd79b5e5c5 (tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents: 91217
diff changeset
140 (tai-viet-compose-region from (match-end 0)))))
90938
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
141
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
142 ;;
ab2b53b01252 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
143 (provide 'tai-viet-util)
90950
8568c29985a3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90949
diff changeset
144
8568c29985a3 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 90949
diff changeset
145 ;; arch-tag: a45ac3fc-07d0-44d5-8841-2ebea7e11f5b