Mercurial > emacs
annotate lisp/language/japan-util.el @ 19026:db6728252ce2
(Fx_create_frame): Initialize fontset in output_data.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 28 Jul 1997 18:30:44 +0000 |
parents | 5b263fdf71a2 |
children | a162ad4fde2e |
rev | line source |
---|---|
17315
a3ca5e15c82a
Fix the format of the first line.
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
1 ;;; japan-util.el --- utilities for Japanese |
17052 | 2 |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
18377
8b4a66c66dd6
Change copyright notice.
Richard M. Stallman <rms@gnu.org>
parents:
18309
diff
changeset
|
4 ;; Licensed to the Free Software Foundation. |
17052 | 5 |
6 ;; Keywords: mule, multilingual, Japanese | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
17071 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
17052 | 24 |
25 ;;; Code: | |
26 | |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
27 ;;;###autoload |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
28 (defun setup-japanese-environment () |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
29 "Setup multilingual environment (MULE) for Japanese." |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
30 (interactive) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
31 (setup-english-environment) |
18203
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
32 (setq coding-category-iso-8-2 'japanese-iso-8bit) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
33 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
34 (set-coding-priority |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
35 '(coding-category-iso-7 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
36 coding-category-iso-8-2 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
37 coding-category-sjis |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
38 coding-category-iso-8-1 |
18790
5b263fdf71a2
(setup-japanese-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18415
diff
changeset
|
39 coding-category-iso-7-else |
5b263fdf71a2
(setup-japanese-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18415
diff
changeset
|
40 coding-category-iso-8-else |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
41 coding-category-emacs-mule)) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
42 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
43 (if (eq system-type 'ms-dos) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
44 (progn |
18203
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
45 (setq-default buffer-file-coding-system 'japanese-shift-jis) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
46 (set-terminal-coding-system-internal 'japanese-shift-jis) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
47 (set-keyboard-coding-system-internal 'japanese-shift-jis) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
48 (setq default-process-coding-system |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
49 '(japanese-shift-jis-dos . japanese-shift-jis-dos))) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
50 (setq-default buffer-file-coding-system 'iso-2022-7bit) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
51 (set-terminal-coding-system-internal 'iso-2022-7bit) |
0745f30aec66
Adjusted for coding system name change.
Kenichi Handa <handa@m17n.org>
parents:
17993
diff
changeset
|
52 (set-keyboard-coding-system-internal 'iso-2022-7bit)) |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
53 |
18790
5b263fdf71a2
(setup-japanese-environment): Adjusted for the change of coding
Kenichi Handa <handa@m17n.org>
parents:
18415
diff
changeset
|
54 (setq default-input-method "japanese") |
17993
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
55 |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
56 (setq sendmail-coding-system 'iso-2022-jp |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
57 rmail-file-coding-system 'iso-2022-jp) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
58 ) |
73869115ae0a
Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents:
17315
diff
changeset
|
59 |
17052 | 60 (defconst japanese-kana-table |
61 '((?$B$"(B ?$B%"(B ?(I1(B) (?$B$$(B ?$B%$(B ?(I2(B) (?$B$&(B ?$B%&(B ?(I3(B) (?$B$((B ?$B%((B ?(I4(B) (?$B$*(B ?$B%*(B ?(I5(B) | |
62 (?$B$+(B ?$B%+(B ?(I6(B) (?$B$-(B ?$B%-(B ?(I7(B) (?$B$/(B ?$B%/(B ?(I8(B) (?$B$1(B ?$B%1(B ?(I9(B) (?$B$3(B ?$B%3(B ?(I:(B) | |
63 (?$B$5(B ?$B%5(B ?(I;(B) (?$B$7(B ?$B%7(B ?(I<(B) (?$B$9(B ?$B%9(B ?(I=(B) (?$B$;(B ?$B%;(B ?(I>(B) (?$B$=(B ?$B%=(B ?(I?(B) | |
64 (?$B$?(B ?$B%?(B ?(I@(B) (?$B$A(B ?$B%A(B ?(IA(B) (?$B$D(B ?$B%D(B ?(IB(B) (?$B$F(B ?$B%F(B ?(IC(B) (?$B$H(B ?$B%H(B ?(ID(B) | |
65 (?$B$J(B ?$B%J(B ?(IE(B) (?$B$K(B ?$B%K(B ?(IF(B) (?$B$L(B ?$B%L(B ?(IG(B) (?$B$M(B ?$B%M(B ?(IH(B) (?$B$N(B ?$B%N(B ?(II(B) | |
66 (?$B$O(B ?$B%O(B ?(IJ(B) (?$B$R(B ?$B%R(B ?(IK(B) (?$B$U(B ?$B%U(B ?(IL(B) (?$B$X(B ?$B%X(B ?(IM(B) (?$B$[(B ?$B%[(B ?(IN(B) | |
67 (?$B$^(B ?$B%^(B ?(IO(B) (?$B$_(B ?$B%_(B ?(IP(B) (?$B$`(B ?$B%`(B ?(IQ(B) (?$B$a(B ?$B%a(B ?(IR(B) (?$B$b(B ?$B%b(B ?(IS(B) | |
68 (?$B$d(B ?$B%d(B ?(IT(B) (?$B$f(B ?$B%f(B ?(IU(B) (?$B$h(B ?$B%h(B ?(IV(B) | |
69 (?$B$i(B ?$B%i(B ?(IW(B) (?$B$j(B ?$B%j(B ?(IX(B) (?$B$k(B ?$B%k(B ?(IY(B) (?$B$l(B ?$B%l(B ?(IZ(B) (?$B$m(B ?$B%m(B ?(I[(B) | |
70 (?$B$o(B ?$B%o(B ?(I\(B) (?$B$p(B ?$B%p(B nil) (?$B$q(B ?$B%q(B nil) (?$B$r(B ?$B%r(B ?(I&(B) | |
71 (?$B$s(B ?$B%s(B ?(I](B) | |
72 (?$B$,(B ?$B%,(B "(I6^(B") (?$B$.(B ?$B%.(B "(I7^(B") (?$B$0(B ?$B%0(B "(I8^(B") (?$B$2(B ?$B%2(B "(I9^(B") (?$B$4(B ?$B%4(B "(I:^(B") | |
73 (?$B$6(B ?$B%6(B "(I;^(B") (?$B$8(B ?$B%8(B "(I<^(B") (?$B$:(B ?$B%:(B "(I=^(B") (?$B$<(B ?$B%<(B "(I>^(B") (?$B$>(B ?$B%>(B "(I?^(B") | |
74 (?$B$@(B ?$B%@(B "(I@^(B") (?$B$B(B ?$B%B(B "(IA^(B") (?$B$E(B ?$B%E(B "(IB^(B") (?$B$G(B ?$B%G(B "(IC^(B") (?$B$I(B ?$B%I(B "(ID^(B") | |
75 (?$B$P(B ?$B%P(B "(IJ^(B") (?$B$S(B ?$B%S(B "(IK^(B") (?$B$V(B ?$B%V(B "(IL^(B") (?$B$Y(B ?$B%Y(B "(IM^(B") (?$B$\(B ?$B%\(B "(IN^(B") | |
76 (?$B$Q(B ?$B%Q(B "(IJ_(B") (?$B$T(B ?$B%T(B "(IK_(B") (?$B$W(B ?$B%W(B "(IL_(B") (?$B$Z(B ?$B%Z(B "(IM_(B") (?$B$](B ?$B%](B "(IN_(B") | |
77 (?$B$!(B ?$B%!(B ?(I'(B) (?$B$#(B ?$B%#(B ?(I((B) (?$B$%(B ?$B%%(B ?(I)(B) (?$B$'(B ?$B%'(B ?(I*(B) (?$B$)(B ?$B%)(B ?(I+(B) | |
78 (?$B$C(B ?$B%C(B ?(I/(B) | |
79 (?$B$c(B ?$B%c(B ?(I,(B) (?$B$e(B ?$B%e(B ?(I-(B) (?$B$g(B ?$B%g(B ?(I.(B) | |
80 (?$B$n(B ?$B%n(B nil) | |
81 (nil ?$B%t(B "(I3^(B") (nil ?$B%u(B nil) (nil ?$B%v(B nil)) | |
82 "Japanese JISX0208 Kana character table. | |
83 Each element is of the form (HIRAGANA KATAKANA HANKAKU-KATAKANA), where | |
84 HIRAGANA and KATAKANA belong to `japanese-jisx0208', | |
85 HANKAKU-KATAKANA belongs to `japanese-jisx0201-kana'.") | |
86 | |
87 ;; Put properties 'katakana, 'hiragana, and 'jix0201 to each Japanese | |
88 ;; kana characters for conversion among them. | |
89 (let ((l japanese-kana-table) | |
90 slot hiragana katakana jisx0201) | |
91 (while l | |
92 (setq slot (car l) | |
93 hiragana (car slot) katakana (nth 1 slot) jisx0201 (nth 2 slot) | |
94 l (cdr l)) | |
95 (if hiragana | |
96 (progn | |
97 (put-char-code-property hiragana 'katakana katakana) | |
98 (put-char-code-property katakana 'hiragana hiragana) | |
99 (if jisx0201 | |
100 (progn | |
101 (put-char-code-property hiragana 'jisx0201 jisx0201) | |
102 (if (integerp jisx0201) | |
103 (put-char-code-property jisx0201 'hiragana hiragana)))))) | |
104 (if jisx0201 | |
105 (progn | |
106 (put-char-code-property katakana 'jisx0201 jisx0201) | |
107 (if (integerp jisx0201) | |
108 (put-char-code-property jisx0201 'katakana katakana)))))) | |
109 | |
110 (defconst japanese-symbol-table | |
111 '((?\$B!!(B ?\ ) (?$B!"(B ?, ?(I$(B) (?$B!#(B ?. ?(I!(B) (?$B!$(B ?, ?(I$(B) (?$B!%(B ?. ?(I!(B) (?$B!&(B nil ?(I%(B) | |
112 (?$B!'(B ?:) (?$B!((B ?\;) (?$B!)(B ??) (?$B!*(B ?!) (?$B!+(B nil ?(I^(B) (?$B!,(B nil ?(I_(B) | |
113 (?$B!-(B ?') (?$B!.(B ?`) (?$B!0(B ?^) (?$B!2(B ?_) (?$B!<(B ?-) (?$B!=(B ?-) (?$B!>(B ?-) | |
114 (?$B!?(B ?/) (?$B!@(B ?\\) (?$B!A(B ?~) (?$B!C(B ?|) (?$B!F(B ?`) (?$B!G(B ?') (?$B!H(B ?\") (?$B!I(B ?\") | |
115 (?\$B!J(B ?\() (?\$B!K(B ?\)) (?\$B!N(B ?[) (?\$B!O(B ?]) (?\$B!P(B ?{) (?\$B!Q(B ?}) | |
116 (?$B!R(B ?<) (?$B!S(B ?>) (?$B!\(B ?+) (?$B!](B ?-) (?$B!a(B ?=) (?$B!c(B ?<) (?$B!d(B ?>) | |
117 (?$B!l(B ?') (?$B!m(B ?\") (?$B!o(B ?\\) (?$B!p(B ?$) (?$B!s(B ?%) (?$B!t(B ?#) (?$B!u(B ?&) (?$B!v(B ?*) | |
118 (?$B!w(B ?@)) | |
119 "Japanese JISX0208 symbol character table. | |
120 Each element is of the form (SYMBOL ASCII HANKAKU), where SYMBOL | |
121 belongs to `japanese-jisx0208', ASCII belongs to `ascii', and HANKAKU | |
122 belongs to `japanese-jisx0201-kana'.") | |
123 | |
124 ;; Put properties 'jisx0208, 'jisx0201, and 'ascii to each Japanese | |
125 ;; symbol and ASCII characters for conversion among them. | |
126 (let ((l japanese-symbol-table) | |
127 slot jisx0208 ascii jisx0201) | |
128 (while l | |
129 (setq slot (car l) | |
130 jisx0208 (car slot) ascii (nth 1 slot) jisx0201 (nth 2 slot) | |
131 l (cdr l)) | |
132 (if ascii | |
133 (progn | |
134 (put-char-code-property jisx0208 'ascii ascii) | |
135 (put-char-code-property ascii 'jisx0208 jisx0208))) | |
136 (if jisx0201 | |
137 (progn | |
138 (put-char-code-property jisx0208 'jisx0201 jisx0201) | |
139 (put-char-code-property jisx0201 'jisx0208 jisx0208))))) | |
140 | |
141 (defconst japanese-alpha-numeric-table | |
142 '((?$B#0(B . ?0) (?$B#1(B . ?1) (?$B#2(B . ?2) (?$B#3(B . ?3) (?$B#4(B . ?4) | |
143 (?$B#5(B . ?5) (?$B#6(B . ?6) (?$B#7(B . ?7) (?$B#8(B . ?8) (?$B#9(B . ?9) | |
144 (?$B#A(B . ?A) (?$B#B(B . ?B) (?$B#C(B . ?C) (?$B#D(B . ?D) (?$B#E(B . ?E) | |
145 (?$B#F(B . ?F) (?$B#G(B . ?G) (?$B#H(B . ?H) (?$B#I(B . ?I) (?$B#J(B . ?J) | |
146 (?$B#K(B . ?K) (?$B#L(B . ?L) (?$B#M(B . ?M) (?$B#N(B . ?N) (?$B#O(B . ?O) | |
147 (?$B#P(B . ?P) (?$B#Q(B . ?Q) (?$B#R(B . ?R) (?$B#S(B . ?S) (?$B#T(B . ?T) | |
148 (?$B#U(B . ?U) (?$B#V(B . ?V) (?$B#W(B . ?W) (?$B#X(B . ?X) (?$B#Y(B . ?Y) (?$B#Z(B . ?Z) | |
149 (?$B#a(B . ?a) (?$B#b(B . ?b) (?$B#c(B . ?c) (?$B#d(B . ?d) (?$B#e(B . ?e) | |
150 (?$B#f(B . ?f) (?$B#g(B . ?g) (?$B#h(B . ?h) (?$B#i(B . ?i) (?$B#j(B . ?j) | |
151 (?$B#k(B . ?k) (?$B#l(B . ?l) (?$B#m(B . ?m) (?$B#n(B . ?n) (?$B#o(B . ?o) | |
152 (?$B#p(B . ?p) (?$B#q(B . ?q) (?$B#r(B . ?r) (?$B#s(B . ?s) (?$B#t(B . ?t) | |
153 (?$B#u(B . ?u) (?$B#v(B . ?v) (?$B#w(B . ?w) (?$B#x(B . ?x) (?$B#y(B . ?y) (?$B#z(B . ?z)) | |
154 "Japanese JISX0208 alpha numeric character table. | |
155 Each element is of the form (ALPHA-NUMERIC ASCII), where ALPHA-NUMERIC | |
156 belongs to `japanese-jisx0208', ASCII belongs to `ascii'.") | |
157 | |
158 ;; Put properties 'jisx0208 and 'ascii to each Japanese alpha numeric | |
159 ;; and ASCII characters for conversion between them. | |
160 (let ((l japanese-alpha-numeric-table) | |
161 slot jisx0208 ascii) | |
162 (while l | |
163 (setq slot (car l) | |
164 jisx0208 (car slot) ascii (cdr slot) | |
165 l (cdr l)) | |
166 (put-char-code-property jisx0208 'ascii ascii) | |
167 (put-char-code-property ascii 'jisx0208 jisx0208))) | |
168 | |
169 ;; Convert string STR by FUNC and return a resulting string. | |
170 (defun japanese-string-conversion (str func &rest args) | |
171 (let ((buf (get-buffer-create " *Japanese work*"))) | |
172 (save-excursion | |
173 (set-buffer buf) | |
174 (erase-buffer) | |
175 (insert str) | |
176 (apply func 1 (point) args) | |
177 (buffer-string)))) | |
178 | |
179 ;;;###autoload | |
180 (defun japanese-katakana (obj &optional hankaku) | |
181 "Convert argument to Katakana and return that. | |
182 The argument may be a character or string. The result has the same type. | |
183 The argument object is not altered--the value is a copy. | |
184 Optional argument HANKAKU t means to convert to `hankaku' Katakana | |
185 \(`japanese-jisx0201-kana'), in which case return value | |
186 may be a string even if OBJ is a character if two Katakanas are | |
187 necessary to represent OBJ." | |
188 (if (stringp obj) | |
189 (japanese-string-conversion obj 'japanese-katakana-region hankaku) | |
190 (or (get-char-code-property obj (if hankaku 'jisx0201 'katakana)) | |
191 obj))) | |
192 | |
193 ;;;###autoload | |
194 (defun japanese-hiragana (obj) | |
195 "Convert argument to Hiragana and return that. | |
196 The argument may be a character or string. The result has the same type. | |
197 The argument object is not altered--the value is a copy." | |
198 (if (stringp obj) | |
199 (japanese-string-conversion obj 'japanese-hiragana-region) | |
200 (or (get-char-code-property obj 'hiragana) | |
201 obj))) | |
202 | |
203 ;;;###autoload | |
204 (defun japanese-hankaku (obj &optional ascii-only) | |
205 "Convert argument to `hankaku' and return that. | |
206 The argument may be a character or string. The result has the same type. | |
207 The argument object is not altered--the value is a copy. | |
208 Optional argument ASCII-ONLY non-nil means to return only ASCII character." | |
209 (if (stringp obj) | |
210 (japanese-string-conversion obj 'japanese-hankaku-region ascii-only) | |
211 (or (get-char-code-property obj 'ascii) | |
212 (and (not ascii-only) | |
213 (get-char-code-property obj 'jisx0201)) | |
214 obj))) | |
215 | |
216 ;;;###autoload | |
217 (defun japanese-zenkaku (obj) | |
218 "Convert argument to `zenkaku' and return that. | |
219 The argument may be a character or string. The result has the same type. | |
220 The argument object is not altered--the value is a copy." | |
221 (if (stringp obj) | |
222 (japanese-string-conversion obj 'japanese-zenkaku-region) | |
223 (or (get-char-code-property obj 'jisx0208) | |
224 obj))) | |
225 | |
226 ;;;###autoload | |
227 (defun japanese-katakana-region (from to &optional hankaku) | |
228 "Convert Japanese `hiragana' chars in the region to `katakana' chars. | |
229 Optional argument HANKAKU t means to convert to `hankaku katakana' character | |
230 of which charset is `japanese-jisx0201-kana'." | |
231 (interactive "r\nP") | |
232 (save-restriction | |
233 (narrow-to-region from to) | |
234 (goto-char (point-min)) | |
235 (while (re-search-forward "\\cH\\|\\cK" nil t) | |
236 (let* ((hira (preceding-char)) | |
237 (kata (japanese-katakana hira hankaku))) | |
238 (if kata | |
239 (progn | |
240 (delete-region (match-beginning 0) (match-end 0)) | |
241 (insert kata))))))) | |
242 | |
243 ;;;###autoload | |
244 (defun japanese-hiragana-region (from to) | |
245 "Convert Japanese `katakana' chars in the region to `hiragana' chars." | |
246 (interactive "r") | |
247 (save-restriction | |
248 (narrow-to-region from to) | |
249 (goto-char (point-min)) | |
250 (while (re-search-forward "\\cK\\|\\ck" nil t) | |
251 (let* ((kata (preceding-char)) | |
252 (hira (japanese-hiragana kata))) | |
253 (if hira | |
254 (progn | |
255 (delete-region (match-beginning 0) (match-end 0)) | |
256 (insert hira))))))) | |
257 | |
258 ;;;###autoload | |
259 (defun japanese-hankaku-region (from to &optional ascii-only) | |
260 "Convert Japanese `zenkaku' chars in the region to `hankaku' chars. | |
261 `Zenkaku' chars belong to `japanese-jisx0208' | |
262 `Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'. | |
263 Optional argument ASCII-ONLY non-nil means to convert only to ASCII char." | |
264 (interactive "r\nP") | |
265 (save-restriction | |
266 (narrow-to-region from to) | |
267 (goto-char (point-min)) | |
268 (while (re-search-forward "\\cj" nil t) | |
269 (let* ((zenkaku (preceding-char)) | |
270 (hankaku (japanese-hankaku zenkaku ascii-only))) | |
271 (if hankaku | |
272 (progn | |
273 (delete-region (match-beginning 0) (match-end 0)) | |
274 (insert hankaku))))))) | |
275 | |
276 ;;;###autoload | |
277 (defun japanese-zenkaku-region (from to) | |
278 "Convert hankaku' chars in the region to Japanese `zenkaku' chars. | |
279 `Zenkaku' chars belong to `japanese-jisx0208' | |
280 `Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'." | |
281 (interactive "r") | |
282 (save-restriction | |
283 (narrow-to-region from to) | |
284 (goto-char (point-min)) | |
285 (while (re-search-forward "\\ca\\|\\ck" nil t) | |
286 (let* ((hankaku (preceding-char)) | |
287 (zenkaku (japanese-zenkaku hankaku))) | |
288 (if zenkaku | |
289 (progn | |
290 (delete-region (match-beginning 0) (match-end 0)) | |
291 (insert zenkaku))))))) | |
292 | |
293 ;;;###autoload | |
294 (defun read-hiragana-string (prompt &optional initial-input) | |
295 "Read a Hiragana string from the minibuffer, prompting with string PROMPT. | |
296 If non-nil, second arg INITIAL-INPUT is a string to insert before reading." | |
18415
1cf4e09c841d
(read-hiragana-string): Call read-multilingual-string correctly.
Richard M. Stallman <rms@gnu.org>
parents:
18377
diff
changeset
|
297 (read-multilingual-string prompt initial-input "quail-ja-hiragana")) |
17052 | 298 |
299 ;; | |
18309
bd8b521f5218
Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents:
18203
diff
changeset
|
300 (provide 'japan-util) |
17052 | 301 |
302 ;;; japan-util.el ends here |