771
|
1 ;;; korea-util.el --- utilities for Korean -*- coding: iso-2022-7bit; -*-
|
|
2
|
|
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Keywords: mule, multilingual, Korean
|
|
6
|
|
7 ;; This file is part of XEmacs.
|
|
8
|
|
9 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
10 ;; 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.
|
|
13
|
|
14 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17 ;; General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
21 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
22 ;; 02111-1307, USA.
|
|
23
|
778
|
24 ;;; Synched up with: Emacs 21.1 (language/korea-util.el).
|
|
25
|
|
26 ;;; Commentary:
|
771
|
27
|
|
28 ;;; Code:
|
|
29
|
788
|
30 (globally-declare-boundp '(input-method-function
|
|
31 isearch-input-method-function
|
|
32 isearch-input-method-local-p))
|
|
33
|
771
|
34 ;;;###autoload
|
|
35 (defvar default-korean-keyboard
|
|
36 (if (string-match "3" (or (getenv "HANGUL_KEYBOARD_TYPE") ""))
|
|
37 "3"
|
|
38 "")
|
|
39 "*The kind of Korean keyboard for Korean input method.
|
|
40 \"\" for 2, \"3\" for 3.")
|
|
41
|
|
42 ;; functions useful for Korean text input
|
|
43
|
|
44 (defun toggle-korean-input-method ()
|
|
45 "Turn on or off a Korean text input method for the current buffer."
|
|
46 (interactive)
|
|
47 (if current-input-method
|
|
48 (inactivate-input-method)
|
|
49 (activate-input-method
|
|
50 (concat "korean-hangul" default-korean-keyboard))))
|
|
51
|
|
52 (defun quail-hangul-switch-symbol-ksc (&rest ignore)
|
|
53 "Swith to/from Korean symbol package."
|
|
54 (interactive "i")
|
|
55 (and current-input-method
|
|
56 (if (string-equal current-input-method "korean-symbol")
|
|
57 (activate-input-method (concat "korean-hangul"
|
|
58 default-korean-keyboard))
|
|
59 (activate-input-method "korean-symbol"))))
|
|
60
|
|
61 (defun quail-hangul-switch-hanja (&rest ignore)
|
|
62 "Swith to/from Korean hanja package."
|
|
63 (interactive "i")
|
|
64 (and current-input-method
|
|
65 (if (string-match "korean-hanja" current-input-method)
|
|
66 (activate-input-method (concat "korean-hangul"
|
|
67 default-korean-keyboard))
|
|
68 (activate-input-method (concat "korean-hanja"
|
|
69 default-korean-keyboard)))))
|
|
70
|
|
71 ;; The following three commands are set in isearch-mode-map.
|
|
72
|
|
73 (defun isearch-toggle-korean-input-method ()
|
|
74 (interactive)
|
|
75 (let ((overriding-terminal-local-map nil))
|
|
76 (toggle-korean-input-method))
|
|
77 (setq isearch-input-method-function input-method-function
|
|
78 isearch-input-method-local-p t)
|
|
79 (setq input-method-function nil)
|
|
80 (isearch-update))
|
|
81
|
|
82 (defun isearch-hangul-switch-symbol-ksc ()
|
|
83 (interactive)
|
|
84 (let ((overriding-terminal-local-map nil))
|
|
85 (quail-hangul-switch-symbol-ksc))
|
|
86 (setq isearch-input-method-function input-method-function
|
|
87 isearch-input-method-local-p t)
|
|
88 (setq input-method-function nil)
|
|
89 (isearch-update))
|
|
90
|
|
91 (defun isearch-hangul-switch-hanja ()
|
|
92 (interactive)
|
|
93 (let ((overriding-terminal-local-map nil))
|
|
94 (quail-hangul-switch-hanja))
|
|
95 (setq isearch-input-method-function input-method-function
|
|
96 isearch-input-method-local-p t)
|
|
97 (setq input-method-function nil)
|
|
98 (isearch-update))
|
|
99
|
|
100 ;; Information for setting and exiting Korean environment.
|
|
101 (defvar korean-key-bindings
|
|
102 `((global [?\S- ] toggle-korean-input-method nil)
|
|
103 (global [C-f9] quail-hangul-switch-symbol-ksc nil)
|
|
104 (global [f9] quail-hangul-switch-hanja nil)
|
|
105 (,isearch-mode-map [?\S- ] isearch-toggle-korean-input-method nil)
|
|
106 (,isearch-mode-map [C-f9] isearch-hangul-switch-symbol-ksc nil)
|
|
107 (,isearch-mode-map [f9] isearch-hangul-switch-hanja nil)))
|
|
108
|
|
109 ;;;###autoload
|
|
110 (defun setup-korean-environment-internal ()
|
|
111 (let ((key-bindings korean-key-bindings))
|
|
112 (while key-bindings
|
|
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))
|
|
124 (setq key-bindings (cdr key-bindings)))))
|
|
125
|
|
126 (defun exit-korean-environment ()
|
|
127 "Exit Korean language environment."
|
|
128 (let ((key-bindings korean-key-bindings))
|
|
129 (while key-bindings
|
|
130 (let* ((this (car key-bindings))
|
|
131 (key (nth 1 this))
|
|
132 (new-def (nth 2 this))
|
|
133 (old-def (nth 3 this)))
|
|
134 (if (eq (car this) 'global)
|
|
135 (if (eq (global-key-binding key) new-def)
|
|
136 (global-set-key key old-def))
|
|
137 (if (eq (lookup-key (car this) key) new-def)
|
|
138 (define-key (car this) key old-def))))
|
|
139 (setq key-bindings (cdr key-bindings)))))
|
|
140
|
|
141 ;;
|
|
142 (provide 'korea-util)
|
|
143
|
778
|
144 ;;; korea-util.el ends here
|