20442
|
1 ;;; korea-util.el --- utilities for Korean
|
|
2
|
106815
|
3 ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
74544
|
4 ;; Free Software Foundation, Inc.
|
79711
|
5 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
106815
|
6 ;; 2007, 2008, 2009, 2010
|
62396
|
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
|
|
8 ;; Registration Number H14PRO021
|
20442
|
9
|
|
10 ;; Keywords: mule, multilingual, Korean
|
|
11
|
|
12 ;; This file is part of GNU Emacs.
|
|
13
|
94665
|
14 ;; GNU Emacs is free software: you can redistribute it and/or modify
|
20442
|
15 ;; it under the terms of the GNU General Public License as published by
|
94665
|
16 ;; the Free Software Foundation, either version 3 of the License, or
|
|
17 ;; (at your option) any later version.
|
20442
|
18
|
|
19 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22 ;; GNU General Public License for more details.
|
|
23
|
|
24 ;; You should have received a copy of the GNU General Public License
|
94665
|
25 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
20442
|
26
|
38414
|
27 ;;; Commentary:
|
|
28
|
20442
|
29 ;;; Code:
|
|
30
|
|
31 ;;;###autoload
|
25599
|
32 (defvar default-korean-keyboard
|
105957
|
33 (purecopy (if (string-match "3" (or (getenv "HANGUL_KEYBOARD_TYPE") ""))
|
25599
|
34 "3"
|
105957
|
35 ""))
|
20442
|
36 "*The kind of Korean keyboard for Korean input method.
|
|
37 \"\" for 2, \"3\" for 3.")
|
|
38
|
|
39 ;; functions useful for Korean text input
|
|
40
|
|
41 (defun toggle-korean-input-method ()
|
|
42 "Turn on or off a Korean text input method for the current buffer."
|
|
43 (interactive)
|
|
44 (if current-input-method
|
|
45 (inactivate-input-method)
|
|
46 (activate-input-method
|
|
47 (concat "korean-hangul" default-korean-keyboard))))
|
|
48
|
|
49 (defun quail-hangul-switch-symbol-ksc (&rest ignore)
|
|
50 "Swith to/from Korean symbol package."
|
|
51 (interactive "i")
|
|
52 (and current-input-method
|
|
53 (if (string-equal current-input-method "korean-symbol")
|
|
54 (activate-input-method (concat "korean-hangul"
|
|
55 default-korean-keyboard))
|
|
56 (activate-input-method "korean-symbol"))))
|
|
57
|
|
58 (defun quail-hangul-switch-hanja (&rest ignore)
|
|
59 "Swith to/from Korean hanja package."
|
|
60 (interactive "i")
|
|
61 (and current-input-method
|
|
62 (if (string-match "korean-hanja" current-input-method)
|
|
63 (activate-input-method (concat "korean-hangul"
|
|
64 default-korean-keyboard))
|
|
65 (activate-input-method (concat "korean-hanja"
|
|
66 default-korean-keyboard)))))
|
|
67
|
22617
|
68 ;; The following three commands are set in isearch-mode-map.
|
|
69
|
|
70 (defun isearch-toggle-korean-input-method ()
|
|
71 (interactive)
|
|
72 (let ((overriding-terminal-local-map nil))
|
|
73 (toggle-korean-input-method))
|
24717
|
74 (setq isearch-input-method-function input-method-function
|
|
75 isearch-input-method-local-p t)
|
|
76 (setq input-method-function nil)
|
22617
|
77 (isearch-update))
|
|
78
|
|
79 (defun isearch-hangul-switch-symbol-ksc ()
|
|
80 (interactive)
|
|
81 (let ((overriding-terminal-local-map nil))
|
|
82 (quail-hangul-switch-symbol-ksc))
|
24717
|
83 (setq isearch-input-method-function input-method-function
|
|
84 isearch-input-method-local-p t)
|
|
85 (setq input-method-function nil)
|
22617
|
86 (isearch-update))
|
|
87
|
|
88 (defun isearch-hangul-switch-hanja ()
|
|
89 (interactive)
|
|
90 (let ((overriding-terminal-local-map nil))
|
|
91 (quail-hangul-switch-hanja))
|
24717
|
92 (setq isearch-input-method-function input-method-function
|
|
93 isearch-input-method-local-p t)
|
|
94 (setq input-method-function nil)
|
22617
|
95 (isearch-update))
|
|
96
|
|
97 ;; Information for setting and exiting Korean environment.
|
|
98 (defvar korean-key-bindings
|
|
99 `((global [?\S- ] toggle-korean-input-method nil)
|
103466
|
100 (global [Hangul] toggle-korean-input-method nil)
|
22617
|
101 (global [C-f9] quail-hangul-switch-symbol-ksc nil)
|
103538
|
102 (global [f9] hangul-to-hanja-conversion nil)
|
|
103 (global [Hangul_Hanja] hangul-to-hanja-conversion nil)
|
22617
|
104 (,isearch-mode-map [?\S- ] isearch-toggle-korean-input-method nil)
|
103466
|
105 (,isearch-mode-map [Hangul] isearch-toggle-korean-input-method nil)
|
22617
|
106 (,isearch-mode-map [C-f9] isearch-hangul-switch-symbol-ksc nil)
|
|
107 (,isearch-mode-map [f9] isearch-hangul-switch-hanja nil)))
|
20442
|
108
|
|
109 ;;;###autoload
|
22987
|
110 (defun setup-korean-environment-internal ()
|
103632
|
111 (use-cjk-char-width-table 'ko_KR)
|
22617
|
112 (let ((key-bindings korean-key-bindings))
|
20442
|
113 (while key-bindings
|
22617
|
114 (let* ((this (car key-bindings))
|
|
115 (key (nth 1 this))
|
|
116 (new-def (nth 2 this))
|
|
117 old-def)
|
|
118 (if (eq (car this) 'global)
|
|
119 (progn
|
|
120 (setq old-def (global-key-binding key))
|
|
121 (global-set-key key new-def))
|
|
122 (setq old-def (lookup-key (car this) key))
|
|
123 (define-key (car this) key new-def))
|
|
124 (setcar (nthcdr 3 this) old-def))
|
103471
fb1ed86c4fa8
(setup-korean-environment-internal, exit-korean-environment): Cancel
Kenichi Handa <handa@m17n.org>
diff
changeset
|
125 (setq key-bindings (cdr key-bindings)))))
|
20442
|
126
|
|
127 (defun exit-korean-environment ()
|
|
128 "Exit Korean language environment."
|
103632
|
129 (use-default-char-width-table)
|
22617
|
130 (let ((key-bindings korean-key-bindings))
|
|
131 (while key-bindings
|
|
132 (let* ((this (car key-bindings))
|
|
133 (key (nth 1 this))
|
|
134 (new-def (nth 2 this))
|
|
135 (old-def (nth 3 this)))
|
|
136 (if (eq (car this) 'global)
|
|
137 (if (eq (global-key-binding key) new-def)
|
|
138 (global-set-key key old-def))
|
|
139 (if (eq (lookup-key (car this) key) new-def)
|
|
140 (define-key (car this) key old-def))))
|
103471
fb1ed86c4fa8
(setup-korean-environment-internal, exit-korean-environment): Cancel
Kenichi Handa <handa@m17n.org>
diff
changeset
|
141 (setq key-bindings (cdr key-bindings)))))
|
20442
|
142
|
|
143 ;;
|
|
144 (provide 'korea-util)
|
|
145
|
93975
|
146 ;; arch-tag: b17d0981-05da-4577-99f8-1db87fff8b44
|
38414
|
147 ;;; korea-util.el ends here
|