Fix a typo.
[emacs.git] / lisp / language / korea-util.el
blob11438295a2e08cdab7ffe43c30e5976e52d06e51
1 ;;; korea-util.el --- utilities for Korean
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
5 ;; Keywords: mule, multilingual, Korean
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
24 ;;; Code:
26 ;;;###autoload
27 (defvar default-korean-keyboard
28 (if (string-match "3" (or (getenv "HANGUL_KEYBOARD_TYPE") ""))
29 "3"
30 "")
31 "*The kind of Korean keyboard for Korean input method.
32 \"\" for 2, \"3\" for 3.")
34 ;; functions useful for Korean text input
36 (defun toggle-korean-input-method ()
37 "Turn on or off a Korean text input method for the current buffer."
38 (interactive)
39 (if current-input-method
40 (inactivate-input-method)
41 (activate-input-method
42 (concat "korean-hangul" default-korean-keyboard))))
44 (defun quail-hangul-switch-symbol-ksc (&rest ignore)
45 "Swith to/from Korean symbol package."
46 (interactive "i")
47 (and current-input-method
48 (if (string-equal current-input-method "korean-symbol")
49 (activate-input-method (concat "korean-hangul"
50 default-korean-keyboard))
51 (activate-input-method "korean-symbol"))))
53 (defun quail-hangul-switch-hanja (&rest ignore)
54 "Swith to/from Korean hanja package."
55 (interactive "i")
56 (and current-input-method
57 (if (string-match "korean-hanja" current-input-method)
58 (activate-input-method (concat "korean-hangul"
59 default-korean-keyboard))
60 (activate-input-method (concat "korean-hanja"
61 default-korean-keyboard)))))
63 ;; The following three commands are set in isearch-mode-map.
65 (defun isearch-toggle-korean-input-method ()
66 (interactive)
67 (let ((overriding-terminal-local-map nil))
68 (toggle-korean-input-method))
69 (setq isearch-input-method-function input-method-function
70 isearch-input-method-local-p t)
71 (setq input-method-function nil)
72 (isearch-update))
74 (defun isearch-hangul-switch-symbol-ksc ()
75 (interactive)
76 (let ((overriding-terminal-local-map nil))
77 (quail-hangul-switch-symbol-ksc))
78 (setq isearch-input-method-function input-method-function
79 isearch-input-method-local-p t)
80 (setq input-method-function nil)
81 (isearch-update))
83 (defun isearch-hangul-switch-hanja ()
84 (interactive)
85 (let ((overriding-terminal-local-map nil))
86 (quail-hangul-switch-hanja))
87 (setq isearch-input-method-function input-method-function
88 isearch-input-method-local-p t)
89 (setq input-method-function nil)
90 (isearch-update))
92 ;; Information for setting and exiting Korean environment.
93 (defvar korean-key-bindings
94 `((global [?\S- ] toggle-korean-input-method nil)
95 (global [C-f9] quail-hangul-switch-symbol-ksc nil)
96 (global [f9] quail-hangul-switch-hanja nil)
97 (,isearch-mode-map [?\S- ] isearch-toggle-korean-input-method nil)
98 (,isearch-mode-map [C-f9] isearch-hangul-switch-symbol-ksc nil)
99 (,isearch-mode-map [f9] isearch-hangul-switch-hanja nil)))
101 ;;;###autoload
102 (defun setup-korean-environment-internal ()
103 (let ((key-bindings korean-key-bindings))
104 (while key-bindings
105 (let* ((this (car key-bindings))
106 (key (nth 1 this))
107 (new-def (nth 2 this))
108 old-def)
109 (if (eq (car this) 'global)
110 (progn
111 (setq old-def (global-key-binding key))
112 (global-set-key key new-def))
113 (setq old-def (lookup-key (car this) key))
114 (define-key (car this) key new-def))
115 (setcar (nthcdr 3 this) old-def))
116 (setq key-bindings (cdr key-bindings)))))
118 (defun exit-korean-environment ()
119 "Exit Korean language environment."
120 (let ((key-bindings korean-key-bindings))
121 (while key-bindings
122 (let* ((this (car key-bindings))
123 (key (nth 1 this))
124 (new-def (nth 2 this))
125 (old-def (nth 3 this)))
126 (if (eq (car this) 'global)
127 (if (eq (global-key-binding key) new-def)
128 (global-set-key key old-def))
129 (if (eq (lookup-key (car this) key) new-def)
130 (define-key (car this) key old-def))))
131 (setq key-bindings (cdr key-bindings)))))
134 (provide 'korea-util)
136 ;;; korean-util.el ends here