1 ;;; korea-util.el --- utilities for Korean
3 ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 ;; Free Software Foundation, Inc.
5 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
8 ;; Registration Number H14PRO021
10 ;; Keywords: mule, multilingual, Korean
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 3, or (at your option)
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.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 ;; Boston, MA 02110-1301, USA.
34 (defvar default-korean-keyboard
35 (if (string-match "3" (or (getenv "HANGUL_KEYBOARD_TYPE") ""))
38 "*The kind of Korean keyboard for Korean input method.
39 \"\" for 2, \"3\" for 3.")
41 ;; functions useful for Korean text input
43 (defun toggle-korean-input-method ()
44 "Turn on or off a Korean text input method for the current buffer."
46 (if current-input-method
47 (inactivate-input-method)
48 (activate-input-method
49 (concat "korean-hangul" default-korean-keyboard
))))
51 (defun quail-hangul-switch-symbol-ksc (&rest ignore
)
52 "Swith to/from Korean symbol package."
54 (and current-input-method
55 (if (string-equal current-input-method
"korean-symbol")
56 (activate-input-method (concat "korean-hangul"
57 default-korean-keyboard
))
58 (activate-input-method "korean-symbol"))))
60 (defun quail-hangul-switch-hanja (&rest ignore
)
61 "Swith to/from Korean hanja package."
63 (and current-input-method
64 (if (string-match "korean-hanja" current-input-method
)
65 (activate-input-method (concat "korean-hangul"
66 default-korean-keyboard
))
67 (activate-input-method (concat "korean-hanja"
68 default-korean-keyboard
)))))
70 ;; The following three commands are set in isearch-mode-map.
72 (defun isearch-toggle-korean-input-method ()
74 (let ((overriding-terminal-local-map nil
))
75 (toggle-korean-input-method))
76 (setq isearch-input-method-function input-method-function
77 isearch-input-method-local-p t
)
78 (setq input-method-function nil
)
81 (defun isearch-hangul-switch-symbol-ksc ()
83 (let ((overriding-terminal-local-map nil
))
84 (quail-hangul-switch-symbol-ksc))
85 (setq isearch-input-method-function input-method-function
86 isearch-input-method-local-p t
)
87 (setq input-method-function nil
)
90 (defun isearch-hangul-switch-hanja ()
92 (let ((overriding-terminal-local-map nil
))
93 (quail-hangul-switch-hanja))
94 (setq isearch-input-method-function input-method-function
95 isearch-input-method-local-p t
)
96 (setq input-method-function nil
)
99 ;; Information for setting and exiting Korean environment.
100 (defvar korean-key-bindings
101 `((global [?\S-
] toggle-korean-input-method nil
)
102 (global [C-f9
] quail-hangul-switch-symbol-ksc nil
)
103 (global [f9] quail-hangul-switch-hanja nil)
104 (,isearch-mode-map [?\S- ] isearch-toggle-korean-input-method nil)
105 (,isearch-mode-map [C-f9] isearch-hangul-switch-symbol-ksc nil)
106 (,isearch-mode-map [f9] isearch-hangul-switch-hanja nil
)))
109 (defun setup-korean-environment-internal ()
110 (let ((key-bindings korean-key-bindings
))
112 (let* ((this (car key-bindings
))
114 (new-def (nth 2 this
))
116 (if (eq (car this
) 'global
)
118 (setq old-def
(global-key-binding key
))
119 (global-set-key key new-def
))
120 (setq old-def
(lookup-key (car this
) key
))
121 (define-key (car this
) key new-def
))
122 (setcar (nthcdr 3 this
) old-def
))
123 (setq key-bindings
(cdr key-bindings
)))))
125 (defun exit-korean-environment ()
126 "Exit Korean language environment."
127 (let ((key-bindings korean-key-bindings
))
129 (let* ((this (car key-bindings
))
131 (new-def (nth 2 this
))
132 (old-def (nth 3 this
)))
133 (if (eq (car this
) 'global
)
134 (if (eq (global-key-binding key
) new-def
)
135 (global-set-key key old-def
))
136 (if (eq (lookup-key (car this
) key
) new-def
)
137 (define-key (car this
) key old-def
))))
138 (setq key-bindings
(cdr key-bindings
)))))
141 (provide 'korea-util
)
143 ;;; arch-tag: b17d0981-05da-4577-99f8-1db87fff8b44
144 ;;; korea-util.el ends here