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