annotate lisp/language/japan-util.el @ 111299:d1cffc3c49f5

Fix some declarations. * lisp/gnus/nnimap.el (gnutls-negotiate): * lisp/gnus/nntp.el (netrc-parse): Fix declarations. * lisp/faces.el (xw-defined-colors, x-setup-function-keys): * lisp/mouse-sel.el (x-select-text): * lisp/term/w32console.el (x-setup-function-keys): Update declarations.
author Glenn Morris <rgm@gnu.org>
date Sun, 31 Oct 2010 23:13:43 -0700
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37913
diff changeset
1 ;;; japan-util.el --- utilities for Japanese -*- coding: iso-2022-7bit; -*-
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105971
diff changeset
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
74544
43cc94d955c2 Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 64085
diff changeset
4 ;; Free Software Foundation, Inc.
74605
6ee41fdd69ff Update AIST copyright years.
Kenichi Handa <handa@m17n.org>
parents: 74544
diff changeset
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105971
diff changeset
6 ;; 2005, 2006, 2007, 2008, 2009, 2010
62396
197607499a29 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
197607499a29 Fix copyrights.
Kenichi Handa <handa@m17n.org>
parents: 52401
diff changeset
8 ;; Registration Number H14PRO021
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
9
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; Keywords: mule, multilingual, Japanese
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
11
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13
94665
55b7f25d920a Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
94665
55b7f25d920a Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
16 ;; the Free Software Foundation, either version 3 of the License, or
55b7f25d920a Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
17 ;; (at your option) any later version.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 ;; GNU General Public License for more details.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
94665
55b7f25d920a Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37913
diff changeset
27 ;;; Commentary:
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37913
diff changeset
28
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
29 ;;; Code:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30
17993
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
31 ;;;###autoload
22987
708271862495 (setup-XXX-environment): Just call set-language-environment. If
Kenichi Handa <handa@m17n.org>
parents: 22776
diff changeset
32 (defun setup-japanese-environment-internal ()
50089
f302927f8302 (setup-japanese-environment-internal):
Kenichi Handa <handa@m17n.org>
parents: 50007
diff changeset
33 ;; By default, we use 'japanese-iso-8bit for file names. But, the
f302927f8302 (setup-japanese-environment-internal):
Kenichi Handa <handa@m17n.org>
parents: 50007
diff changeset
34 ;; following prefer-coding-system will override it.
50091
e43f492e9944 (setup-japanese-environment-internal): Prefer japanese-shift-jis on
Kenichi Handa <handa@m17n.org>
parents: 50089
diff changeset
35 (if (memq system-type '(windows-nt ms-dos cygwin))
50334
04c0558bea4f If system-type is not for Windows, prefer japanese-iso-8bit.
Kenichi Handa <handa@m17n.org>
parents: 50091
diff changeset
36 (prefer-coding-system 'japanese-shift-jis)
91935
0e222c52ad00 (setup-japanese-environment-internal):
Kenichi Handa <handa@m17n.org>
parents: 79711
diff changeset
37 (prefer-coding-system 'japanese-iso-8bit))
103630
a706fbab4da9 (setup-japanese-environment-internal):
Kenichi Handa <handa@m17n.org>
parents: 100908
diff changeset
38 (use-cjk-char-width-table 'ja_JP))
17993
73869115ae0a Most of setup-LANGUAGE-environment functions are
Kenichi Handa <handa@m17n.org>
parents: 17315
diff changeset
39
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 (defconst japanese-kana-table
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 '((?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 (?$B$d(B ?$B%d(B ?(IT(B) (?$B$f(B ?$B%f(B ?(IU(B) (?$B$h(B ?$B%h(B ?(IV(B)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 (?$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)
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
50 (?$B$o(B ?$B%o(B ?(I\(B) (?$B$p(B ?$B%p(B "(I2(B") (?$B$q(B ?$B%q(B "(I4(B") (?$B$r(B ?$B%r(B ?(I&(B)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 (?$B$s(B ?$B%s(B ?(I](B)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 (?$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")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 (?$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")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 (?$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")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55 (?$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")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 (?$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")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
57 (?$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)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 (?$B$C(B ?$B%C(B ?(I/(B)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 (?$B$c(B ?$B%c(B ?(I,(B) (?$B$e(B ?$B%e(B ?(I-(B) (?$B$g(B ?$B%g(B ?(I.(B)
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
60 (?$B$n(B ?$B%n(B "(I\(B")
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
61 ("$B$&!+(B" ?$B%t(B "(I3^(B") (nil ?$B%u(B "(I6(B") (nil ?$B%v(B "(I9(B"))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 "Japanese JISX0208 Kana character table.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 Each element is of the form (HIRAGANA KATAKANA HANKAKU-KATAKANA), where
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 HIRAGANA and KATAKANA belong to `japanese-jisx0208',
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 HANKAKU-KATAKANA belongs to `japanese-jisx0201-kana'.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
67 ;; Put properties 'katakana, 'hiragana, and 'jix0201 to each Japanese
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 ;; kana characters for conversion among them.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 (let ((l japanese-kana-table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 slot hiragana katakana jisx0201)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 (while l
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 (setq slot (car l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 hiragana (car slot) katakana (nth 1 slot) jisx0201 (nth 2 slot)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 l (cdr l))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 (if hiragana
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
76 (if (stringp hiragana)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
77 (if (> (length hiragana) 1)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
78 (let ((hira (aref hiragana 0)))
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
79 (put-char-code-property
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
80 hira 'kana-composition
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
81 (cons (cons (aref hiragana 1) katakana)
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
82 (get-char-code-property hira 'kana-composition)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 (put-char-code-property hiragana 'katakana katakana)
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
84 (put-char-code-property hiragana 'jisx0201 jisx0201)))
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
85 (when (integerp katakana)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
86 (put-char-code-property katakana 'hiragana hiragana)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
87 (put-char-code-property katakana 'jisx0201 jisx0201))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 (if jisx0201
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
89 (if (stringp jisx0201)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
90 (if (> (length jisx0201) 1)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
91 (let ((kana (aref jisx0201 0)))
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
92 (put-char-code-property
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
93 kana 'kana-composition
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
94 (cons (cons (aref jisx0201 1) katakana)
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
95 (get-char-code-property kana 'kana-composition)))))
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
96 (put-char-code-property jisx0201 'hiragana hiragana)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
97 (put-char-code-property jisx0201 'katakana katakana)
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
98 (put-char-code-property jisx0201 'jisx0208 katakana)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 (defconst japanese-symbol-table
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
101 '((?\$B!!(B ?\ ) (?$B!$(B ?, ?(I$(B) (?$B!%(B ?. ?(I!(B) (?$B!"(B ?, ?(I$(B) (?$B!#(B ?. ?(I!(B) (?$B!&(B nil ?(I%(B)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 (?$B!'(B ?:) (?$B!((B ?\;) (?$B!)(B ??) (?$B!*(B ?!) (?$B!+(B nil ?(I^(B) (?$B!,(B nil ?(I_(B)
37871
dfd29e68d398 (japanese-symbol-table): Fix handling of
Gerd Moellmann <gerd@gnu.org>
parents: 36683
diff changeset
103 (?$B!-(B ?') (?$B!.(B ?`) (?$B!0(B ?^) (?$B!2(B ?_) (?$B!<(B ?- ?(I0(B) (?$B!=(B ?-) (?$B!>(B ?-)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 (?$B!?(B ?/) (?$B!@(B ?\\) (?$B!A(B ?~) (?$B!C(B ?|) (?$B!F(B ?`) (?$B!G(B ?') (?$B!H(B ?\") (?$B!I(B ?\")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 (?\$B!J(B ?\() (?\$B!K(B ?\)) (?\$B!N(B ?[) (?\$B!O(B ?]) (?\$B!P(B ?{) (?\$B!Q(B ?})
50007
10bcbf340393 (japanese-symbol-table): Add two entries to make it complete.
Kenichi Handa <handa@m17n.org>
parents: 49947
diff changeset
106 (?$B!R(B ?<) (?$B!S(B ?>) (?\$B!V(B nil ?\(I"(B) (?\$B!W(B nil ?\(I#(B)
10bcbf340393 (japanese-symbol-table): Add two entries to make it complete.
Kenichi Handa <handa@m17n.org>
parents: 49947
diff changeset
107 (?$B!\(B ?+) (?$B!](B ?-) (?$B!a(B ?=) (?$B!c(B ?<) (?$B!d(B ?>)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
108 (?$B!l(B ?') (?$B!m(B ?\") (?$B!o(B ?\\) (?$B!p(B ?$) (?$B!s(B ?%) (?$B!t(B ?#) (?$B!u(B ?&) (?$B!v(B ?*)
104633
1f5c70ceb22b (japanese-symbol-table): Add entries for cp932-2-byte.
Kenichi Handa <handa@m17n.org>
parents: 103630
diff changeset
109 (?$B!w(B ?@)
1f5c70ceb22b (japanese-symbol-table): Add entries for cp932-2-byte.
Kenichi Handa <handa@m17n.org>
parents: 103630
diff changeset
110 ;; cp932-2-byte
1f5c70ceb22b (japanese-symbol-table): Add entries for cp932-2-byte.
Kenichi Handa <handa@m17n.org>
parents: 103630
diff changeset
111 (#x2015 ?-) (#xFF5E ?~) (#xFF0D ?-))
105971
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
112 "Japanese JISX0208 and CP932 symbol character table.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113 Each element is of the form (SYMBOL ASCII HANKAKU), where SYMBOL
105971
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
114 belongs to `japanese-jisx0208' or `cp932', ASCII belongs to `ascii',
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
115 and HANKAKU belongs to `japanese-jisx0201-kana'.")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 ;; Put properties 'jisx0208, 'jisx0201, and 'ascii to each Japanese
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 ;; symbol and ASCII characters for conversion among them.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 (let ((l japanese-symbol-table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 slot jisx0208 ascii jisx0201)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 (while l
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122 (setq slot (car l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
123 jisx0208 (car slot) ascii (nth 1 slot) jisx0201 (nth 2 slot)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
124 l (cdr l))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
125 (if ascii
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 (put-char-code-property jisx0208 'ascii ascii)
105971
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
128 (if (encode-char jisx0208 'japanese-jisx0208)
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
129 (put-char-code-property ascii 'jisx0208 jisx0208))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 (if jisx0201
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 (progn
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 (put-char-code-property jisx0208 'jisx0201 jisx0201)
105971
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
133 (if (encode-char jisx0208 'japanese-jisx0208)
6b2352662a3f Make sure that the value of jisx0208 property is jisx0208 character.
Kenichi Handa <handa@m17n.org>
parents: 105813
diff changeset
134 (put-char-code-property jisx0201 'jisx0208 jisx0208))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 (defconst japanese-alpha-numeric-table
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 '((?$B#0(B . ?0) (?$B#1(B . ?1) (?$B#2(B . ?2) (?$B#3(B . ?3) (?$B#4(B . ?4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 (?$B#5(B . ?5) (?$B#6(B . ?6) (?$B#7(B . ?7) (?$B#8(B . ?8) (?$B#9(B . ?9)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38414
diff changeset
139 (?$B#A(B . ?A) (?$B#B(B . ?B) (?$B#C(B . ?C) (?$B#D(B . ?D) (?$B#E(B . ?E)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140 (?$B#F(B . ?F) (?$B#G(B . ?G) (?$B#H(B . ?H) (?$B#I(B . ?I) (?$B#J(B . ?J)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 (?$B#K(B . ?K) (?$B#L(B . ?L) (?$B#M(B . ?M) (?$B#N(B . ?N) (?$B#O(B . ?O)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 (?$B#P(B . ?P) (?$B#Q(B . ?Q) (?$B#R(B . ?R) (?$B#S(B . ?S) (?$B#T(B . ?T)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 (?$B#U(B . ?U) (?$B#V(B . ?V) (?$B#W(B . ?W) (?$B#X(B . ?X) (?$B#Y(B . ?Y) (?$B#Z(B . ?Z)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
144 (?$B#a(B . ?a) (?$B#b(B . ?b) (?$B#c(B . ?c) (?$B#d(B . ?d) (?$B#e(B . ?e)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 (?$B#f(B . ?f) (?$B#g(B . ?g) (?$B#h(B . ?h) (?$B#i(B . ?i) (?$B#j(B . ?j)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 (?$B#k(B . ?k) (?$B#l(B . ?l) (?$B#m(B . ?m) (?$B#n(B . ?n) (?$B#o(B . ?o)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147 (?$B#p(B . ?p) (?$B#q(B . ?q) (?$B#r(B . ?r) (?$B#s(B . ?s) (?$B#t(B . ?t)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
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))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 "Japanese JISX0208 alpha numeric character table.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150 Each element is of the form (ALPHA-NUMERIC ASCII), where ALPHA-NUMERIC
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 belongs to `japanese-jisx0208', ASCII belongs to `ascii'.")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153 ;; Put properties 'jisx0208 and 'ascii to each Japanese alpha numeric
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 ;; and ASCII characters for conversion between them.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 (let ((l japanese-alpha-numeric-table)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 slot jisx0208 ascii)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 (while l
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158 (setq slot (car l)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 jisx0208 (car slot) ascii (cdr slot)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160 l (cdr l))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 (put-char-code-property jisx0208 'ascii ascii)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 (put-char-code-property ascii 'jisx0208 jisx0208)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 ;; Convert string STR by FUNC and return a resulting string.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 (defun japanese-string-conversion (str func &rest args)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 (let ((buf (get-buffer-create " *Japanese work*")))
105813
df4934f25eef * textmodes/two-column.el (2C-split):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104633
diff changeset
167 (with-current-buffer buf
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 (erase-buffer)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 (insert str)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 (apply func 1 (point) args)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 (buffer-string))))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 (defun japanese-katakana (obj &optional hankaku)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 "Convert argument to Katakana and return that.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 The argument may be a character or string. The result has the same type.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 The argument object is not altered--the value is a copy.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 Optional argument HANKAKU t means to convert to `hankaku' Katakana
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 \(`japanese-jisx0201-kana'), in which case return value
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180 may be a string even if OBJ is a character if two Katakanas are
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 necessary to represent OBJ."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182 (if (stringp obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 (japanese-string-conversion obj 'japanese-katakana-region hankaku)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 (or (get-char-code-property obj (if hankaku 'jisx0201 'katakana))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 obj)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 (defun japanese-hiragana (obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 "Convert argument to Hiragana and return that.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 The argument may be a character or string. The result has the same type.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 The argument object is not altered--the value is a copy."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192 (if (stringp obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 (japanese-string-conversion obj 'japanese-hiragana-region)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 (or (get-char-code-property obj 'hiragana)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 obj)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 (defun japanese-hankaku (obj &optional ascii-only)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 "Convert argument to `hankaku' and return that.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 The argument may be a character or string. The result has the same type.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 The argument object is not altered--the value is a copy.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 Optional argument ASCII-ONLY non-nil means to return only ASCII character."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
203 (if (stringp obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204 (japanese-string-conversion obj 'japanese-hankaku-region ascii-only)
37913
49a0ec256ceb (japanese-hankaku): Prefer the charset
Gerd Moellmann <gerd@gnu.org>
parents: 37871
diff changeset
205 (or (and (not ascii-only)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 (get-char-code-property obj 'jisx0201))
37913
49a0ec256ceb (japanese-hankaku): Prefer the charset
Gerd Moellmann <gerd@gnu.org>
parents: 37871
diff changeset
207 (get-char-code-property obj 'ascii)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 obj)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
209
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 (defun japanese-zenkaku (obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 "Convert argument to `zenkaku' and return that.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 The argument may be a character or string. The result has the same type.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 The argument object is not altered--the value is a copy."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 (if (stringp obj)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 (japanese-string-conversion obj 'japanese-zenkaku-region)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 (or (get-char-code-property obj 'jisx0208)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 obj)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
220 (defun japanese-replace-region (from to string)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
221 "Replace the region specified by FROM and TO to STRING."
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
222 (goto-char from)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
223 (insert string)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
224 (delete-char (- to from)))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
225
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 (defun japanese-katakana-region (from to &optional hankaku)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 "Convert Japanese `hiragana' chars in the region to `katakana' chars.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 Optional argument HANKAKU t means to convert to `hankaku katakana' character
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230 of which charset is `japanese-jisx0201-kana'."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 (interactive "r\nP")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232 (save-restriction
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233 (narrow-to-region from to)
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
234 (save-excursion
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
235 (goto-char (point-min))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
236 (while (re-search-forward "\\cH\\|\\cK" nil t)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
237 (let* ((kana (preceding-char))
30451
153802156ca9 (japanese-katakana-region): Fix handling HANKAKU argument.
Kenichi Handa <handa@m17n.org>
parents: 28906
diff changeset
238 (composition
153802156ca9 (japanese-katakana-region): Fix handling HANKAKU argument.
Kenichi Handa <handa@m17n.org>
parents: 28906
diff changeset
239 (and (not hankaku)
153802156ca9 (japanese-katakana-region): Fix handling HANKAKU argument.
Kenichi Handa <handa@m17n.org>
parents: 28906
diff changeset
240 (get-char-code-property kana 'kana-composition)))
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
241 next slot)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
242 (if (and composition (setq slot (assq (following-char) composition)))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
243 (japanese-replace-region (match-beginning 0) (1+ (point))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
244 (cdr slot))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
245 (let ((kata (get-char-code-property
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
246 kana (if hankaku 'jisx0201 'katakana))))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
247 (if kata
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
248 (japanese-replace-region (match-beginning 0) (point)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
249 kata)))))))))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
250
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253 (defun japanese-hiragana-region (from to)
22548
b054cd9f66df Introduce new character code property
Kenichi Handa <handa@m17n.org>
parents: 21376
diff changeset
254 "Convert Japanese `katakana' chars in the region to `hiragana' chars."
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255 (interactive "r")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256 (save-restriction
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 (narrow-to-region from to)
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
258 (save-excursion
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
259 (goto-char (point-min))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
260 (while (re-search-forward "\\cK\\|\\ck" nil t)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
261 (let* ((kata (preceding-char))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
262 (composition (get-char-code-property kata 'kana-composition))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
263 next slot)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
264 (if (and composition (setq slot (assq (following-char) composition)))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
265 (japanese-replace-region (match-beginning 0) (1+ (point))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
266 (get-char-code-property
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
267 (cdr slot) 'hiragana))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
268 (let ((hira (get-char-code-property kata 'hiragana)))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
269 (if hira
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
270 (japanese-replace-region (match-beginning 0) (point)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
271 hira)))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 (defun japanese-hankaku-region (from to &optional ascii-only)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 "Convert Japanese `zenkaku' chars in the region to `hankaku' chars.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 `Zenkaku' chars belong to `japanese-jisx0208'
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277 `Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 Optional argument ASCII-ONLY non-nil means to convert only to ASCII char."
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 (interactive "r\nP")
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 (save-restriction
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 (narrow-to-region from to)
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
282 (save-excursion
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
283 (goto-char (point-min))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
284 (while (re-search-forward "\\cj" nil t)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
285 (let* ((zenkaku (preceding-char))
37913
49a0ec256ceb (japanese-hankaku): Prefer the charset
Gerd Moellmann <gerd@gnu.org>
parents: 37871
diff changeset
286 (hankaku (or (and (not ascii-only)
49a0ec256ceb (japanese-hankaku): Prefer the charset
Gerd Moellmann <gerd@gnu.org>
parents: 37871
diff changeset
287 (get-char-code-property zenkaku 'jisx0201))
49a0ec256ceb (japanese-hankaku): Prefer the charset
Gerd Moellmann <gerd@gnu.org>
parents: 37871
diff changeset
288 (get-char-code-property zenkaku 'ascii))))
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
289 (if hankaku
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
290 (japanese-replace-region (match-beginning 0) (match-end 0)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
291 hankaku)))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 ;;;###autoload
23722
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
294 (defun japanese-zenkaku-region (from to &optional katakana-only)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 "Convert hankaku' chars in the region to Japanese `zenkaku' chars.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 `Zenkaku' chars belong to `japanese-jisx0208'
23722
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
297 `Hankaku' chars belong to `ascii' or `japanese-jisx0201-kana'.
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
298 Optional argument KATAKANA-ONLY non-nil means to convert only KATAKANA char."
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
299 (interactive "r\nP")
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 (save-restriction
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 (narrow-to-region from to)
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
302 (save-excursion
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
303 (goto-char (point-min))
23722
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
304 (while (or (and katakana-only
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
305 (re-search-forward "\\ck" nil t))
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
306 (and (not katakana-only)
b0c66c87b29b (japanese-zenkaku-region): New optional arg KATAKANA-ONLY.
Kenichi Handa <handa@m17n.org>
parents: 22987
diff changeset
307 (re-search-forward "\\ca\\|\\ck" nil t)))
22776
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
308 (let* ((hankaku (preceding-char))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
309 (composition (get-char-code-property hankaku 'kana-composition))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
310 next slot)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
311 (if (and composition (setq slot (assq (following-char) composition)))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
312 (japanese-replace-region (match-beginning 0) (1+ (point))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
313 (cdr slot))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
314 (let ((zenkaku (japanese-zenkaku hankaku)))
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
315 (if zenkaku
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
316 (japanese-replace-region (match-beginning 0) (match-end 0)
1e2bf1acab23 (japanese-replace-region): New function.
Kenichi Handa <handa@m17n.org>
parents: 22548
diff changeset
317 zenkaku)))))))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 ;;;###autoload
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 (defun read-hiragana-string (prompt &optional initial-input)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321 "Read a Hiragana string from the minibuffer, prompting with string PROMPT.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 If non-nil, second arg INITIAL-INPUT is a string to insert before reading."
19854
c6f58c509273 (setup-japanese-environment): Give
Kenichi Handa <handa@m17n.org>
parents: 19764
diff changeset
323 (read-multilingual-string prompt initial-input "japanese-hiragana"))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325 ;;
18309
bd8b521f5218 Provide XXX-util instead of
Kenichi Handa <handa@m17n.org>
parents: 18203
diff changeset
326 (provide 'japan-util)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 91935
diff changeset
328 ;; arch-tag: b579595c-c9ad-4b57-9314-98cd8b214f89
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329 ;;; japan-util.el ends here