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