make thread_check_current_buffer return bool
[emacs.git] / lisp / language / korea-util.el
blob1a74926246a28f96d59b02e5fafb6acdc1857793
1 ;;; korea-util.el --- utilities for Korean
3 ;; Copyright (C) 1997, 1999, 2001-2013 Free Software Foundation, Inc.
4 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
5 ;; 2007, 2008, 2009, 2010, 2011
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 of the License, or
16 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
26 ;;; Commentary:
28 ;;; Code:
30 ;;;###autoload
31 (defvar default-korean-keyboard
32 (purecopy (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.")
38 ;; functions useful for Korean text input
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 (deactivate-input-method)
45 (activate-input-method
46 (concat "korean-hangul" default-korean-keyboard))))
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"))))
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)))))
67 ;; The following three commands are set in isearch-mode-map.
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))
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))
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))
96 ;; Information for setting and exiting Korean environment.
97 (defvar korean-key-bindings
98 `((global [?\S- ] toggle-korean-input-method nil)
99 (global [Hangul] toggle-korean-input-method nil)
100 (global [C-f9] quail-hangul-switch-symbol-ksc nil)
101 (global [f9] hangul-to-hanja-conversion nil)
102 (global [Hangul_Hanja] hangul-to-hanja-conversion nil)
103 (,isearch-mode-map [?\S- ] isearch-toggle-korean-input-method nil)
104 (,isearch-mode-map [Hangul] 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)))
108 ;;;###autoload
109 (defun setup-korean-environment-internal ()
110 (use-cjk-char-width-table 'ko_KR)
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)))))
126 (defun exit-korean-environment ()
127 "Exit Korean language environment."
128 (use-default-char-width-table)
129 (let ((key-bindings korean-key-bindings))
130 (while key-bindings
131 (let* ((this (car key-bindings))
132 (key (nth 1 this))
133 (new-def (nth 2 this))
134 (old-def (nth 3 this)))
135 (if (eq (car this) 'global)
136 (if (eq (global-key-binding key) new-def)
137 (global-set-key key old-def))
138 (if (eq (lookup-key (car this) key) new-def)
139 (define-key (car this) key old-def))))
140 (setq key-bindings (cdr key-bindings)))))
143 (provide 'korea-util)
145 ;;; korea-util.el ends here