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
|
|
30 ;;;###autoload
|
|
31 (defvar default-korean-keyboard
|
|
32 (if (string-match "3" (or (getenv "HANGUL_KEYBOARD_TYPE") ""))
|
|
33 "3"
|
|
34 "")
|
|
35 "*The kind of Korean keyboard for Korean input method.
|
|
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
|
|
44 (inactivate-input-method)
|
|
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
|
|
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))
|
|
73 (setq isearch-input-method-function input-method-function
|
|
74 isearch-input-method-local-p t)
|
|
75 (setq input-method-function nil)
|
|
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))
|
|
82 (setq isearch-input-method-function input-method-function
|
|
83 isearch-input-method-local-p t)
|
|
84 (setq input-method-function nil)
|
|
85 (isearch-update))
|
|
86
|
|
87 (defun isearch-hangul-switch-hanja ()
|
|
88 (interactive)
|
|
89 (let ((overriding-terminal-local-map nil))
|
|
90 (quail-hangul-switch-hanja))
|
|
91 (setq isearch-input-method-function input-method-function
|
|
92 isearch-input-method-local-p t)
|
|
93 (setq input-method-function nil)
|
|
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)
|
|
99 (global [C-f9] quail-hangul-switch-symbol-ksc nil)
|
|
100 (global [f9] quail-hangul-switch-hanja nil)
|
|
101 (,isearch-mode-map [?\S- ] isearch-toggle-korean-input-method nil)
|
|
102 (,isearch-mode-map [C-f9] isearch-hangul-switch-symbol-ksc nil)
|
|
103 (,isearch-mode-map [f9] isearch-hangul-switch-hanja nil)))
|
|
104
|
|
105 ;;;###autoload
|
|
106 (defun setup-korean-environment-internal ()
|
|
107 (let ((key-bindings korean-key-bindings))
|
|
108 (while key-bindings
|
|
109 (let* ((this (car key-bindings))
|
|
110 (key (nth 1 this))
|
|
111 (new-def (nth 2 this))
|
|
112 old-def)
|
|
113 (if (eq (car this) 'global)
|
|
114 (progn
|
|
115 (setq old-def (global-key-binding key))
|
|
116 (global-set-key key new-def))
|
|
117 (setq old-def (lookup-key (car this) key))
|
|
118 (define-key (car this) key new-def))
|
|
119 (setcar (nthcdr 3 this) old-def))
|
|
120 (setq key-bindings (cdr key-bindings)))))
|
|
121
|
|
122 (defun exit-korean-environment ()
|
|
123 "Exit Korean language environment."
|
|
124 (let ((key-bindings korean-key-bindings))
|
|
125 (while key-bindings
|
|
126 (let* ((this (car key-bindings))
|
|
127 (key (nth 1 this))
|
|
128 (new-def (nth 2 this))
|
|
129 (old-def (nth 3 this)))
|
|
130 (if (eq (car this) 'global)
|
|
131 (if (eq (global-key-binding key) new-def)
|
|
132 (global-set-key key old-def))
|
|
133 (if (eq (lookup-key (car this) key) new-def)
|
|
134 (define-key (car this) key old-def))))
|
|
135 (setq key-bindings (cdr key-bindings)))))
|
|
136
|
|
137 ;;
|
|
138 (provide 'korea-util)
|
|
139
|
778
|
140 ;;; korea-util.el ends here
|