Replace version 24.2 with 24.3 where appropriate (hopefully)
[bpt/emacs.git] / leim / quail / hangul.el
index 76ce625..fd1dc0d 100644 (file)
@@ -1,5 +1,7 @@
 ;;; hangul.el --- Korean Hangul input method
 
+;; Copyright (C) 2008-2012  Free Software Foundation, Inc.
+
 ;; Author: Jihyun Cho <jihyun.jo@gmail.com>
 ;; Keywords: multilingual, input method, Korean, Hangul
 
@@ -28,7 +30,6 @@
 ;;; Code:
 
 (require 'quail)
-(require 'cl)
 (require 'hanja-util)
 
 ;; Hangul double Jamo table.
@@ -89,8 +90,9 @@
   (let ((map (make-sparse-keymap)))
     (define-key map "\d" 'hangul-delete-backward-char)
     (define-key map [f9] 'hangul-to-hanja-conversion)
+    (define-key map [Hangul_Hanja] 'hangul-to-hanja-conversion)
     map)
-  "Keymap for Hangul method.  It is used by all Hangul input method.")
+  "Keymap for Hangul method.  It is used by all Hangul input methods.")
 
 ;; Current input character buffer. Store separated hangul character.
 ;; The first and second are Choseong position.
 
 (defun hangul-character (cho jung jong)
   "Convert CHO, JUNG, JONG to the precomposed `Hangul Syllables' character.
-CHO, JUNG, JONG are relative indices in `Hangul Compatibility Jamo' of unicode.
+CHO, JUNG, JONG are relative indices in `Hangul Compatibility Jamo' of Unicode.
 Return a zero-length string if the conversion fails."
   (or
    (decode-char
@@ -136,8 +138,8 @@ Return a zero-length string if the conversion fails."
    ""))
 
 (defun hangul-insert-character (&rest queues)
-  "Insert characters generated from QUEUEs.
-Each QUEUE has the same form as `hangul-queue'.
+  "Insert characters generated from QUEUES.
+Each queue has the same form as `hangul-queue'.
 Setup `quail-overlay' to the last character."
   (if (and mark-active transient-mark-mode)
       (progn
@@ -160,10 +162,10 @@ Setup `quail-overlay' to the last character."
     (move-overlay quail-overlay (1+ (overlay-start quail-overlay)) (point))))
 
 (defun hangul-djamo (jamo char1 char2)
-  "Return the dobule Jamo index calculated from the arguments.
+  "Return the double Jamo index calculated from the arguments.
 JAMO is a type of Hangul Jamo; `cho', `jung', or `jong'.
-CHAR1 and CAHR2 are Hangul Jamo indices.
-Return nil if CHAR1 and CHAR2 can not combined."
+CHAR1 and CHAR2 are Hangul Jamo indices.
+Return nil if CHAR1 and CHAR2 can not be combined."
   (let* ((jamo (cdr (assoc jamo hangul-djamo-table)))
          (char1 (cdr (assoc char1 jamo))))
     (if char1
@@ -237,7 +239,7 @@ and insert CHAR to new `hangul-queue'."
 (defsubst hangul2-input-method-moum (char)
   "Store Hangul Jamo indice CHAR in `hangul-queue'.
 It is a Hangul 2-Bulsik Moum.
-This function process a Hangul 2-Bulsik Moum.
+This function processes a Hangul 2-Bulsik Moum.
 The Moum can be located in a Jungseong position.
 Other parts are the same as a `hangul2-input-method-jaum'."
   (if (cond ((zerop (aref hangul-queue 2))
@@ -260,7 +262,7 @@ Other parts are the same as a `hangul2-input-method-jaum'."
 (defsubst hangul3-input-method-cho (char)
   "Store Hangul Jamo indice CHAR in `hangul-queue'.
 It is a Hangul 3-Bulsik Choseong.
-This function process a Hangul 3-Bulsik Choseong.
+This function processes a Hangul 3-Bulsik Choseong.
 The Hangul 3-Bulsik is composed of a Choseong, a Jungseong and a Jongseong.
 The Choseong can be located in a Choseong position.
 Other parts are the same as a `hangul2-input-method-jaum'."
@@ -278,7 +280,7 @@ Other parts are the same as a `hangul2-input-method-jaum'."
 (defsubst hangul3-input-method-jung (char)
   "Store Hangul Jamo indice CHAR in `hangul-queue'.
 It is a Hangul 3-Bulsik Jungseong.
-This function process a Hangul 3-Bulsik Jungseong.
+This function processes a Hangul 3-Bulsik Jungseong.
 The Jungseong can be located in a Jungseong position.
 Other parts are the same as a `hangul3-input-method-cho'."
   (if (cond ((and (zerop (aref hangul-queue 2))
@@ -294,7 +296,7 @@ Other parts are the same as a `hangul3-input-method-cho'."
 (defsubst hangul3-input-method-jong (char)
   "Store Hangul Jamo indice CHAR in `hangul-queue'.
 It is a Hangul 3-Bulsik Jongseong.
-This function process a Hangul 3-Bulsik Jongseong.
+This function processes a Hangul 3-Bulsik Jongseong.
 The Jongseong can be located in a Jongseong position.
 Other parts are the same as a `hangul3-input-method-cho'."
   (if (cond ((and (zerop (aref hangul-queue 4))
@@ -352,17 +354,24 @@ Other parts are the same as a `hangul3-input-method-cho'."
     (delete-backward-char 1)))
 
 (defun hangul-to-hanja-conversion ()
-  "Convert the previous hangul character to the corresponding hanja character."
+  "Convert the previous hangul character to the corresponding hanja character.
+When a Korean input method is off, convert the following hangul character."
   (interactive)
   (let ((echo-keystrokes 0)
         delete-func
         hanja-character)
-    (setq hanja-character (hangul-to-hanja-char (preceding-char)))
+    (if (and (overlayp quail-overlay) (overlay-start quail-overlay))
+        (progn
+         (setq hanja-character (hangul-to-hanja-char (preceding-char)))
+         (setq delete-func (lambda () (delete-backward-char 1))))
+      (setq hanja-character (hangul-to-hanja-char (following-char)))
+      (setq delete-func (lambda () (delete-char 1))))
     (when hanja-character
-      (delete-backward-char 1)
+      (funcall delete-func)
       (insert hanja-character)
       (setq hangul-queue (make-vector 6 0))
-      (move-overlay quail-overlay (point) (point)))))
+      (if (and (overlayp quail-overlay) (overlay-start quail-overlay))
+         (move-overlay quail-overlay (point) (point))))))
 
 ;; Support function for `hangul2-input-method'.  Actually, this
 ;; function handles the Hangul 2-Bulsik.  KEY is an entered key code
@@ -503,7 +512,7 @@ Other parts are the same as a `hangul3-input-method-cho'."
   "Activate Hangul input method INPUT-METHOD.
 FUNC is a function to handle input key.
 HELP-TEXT is a text set in `hangul-input-method-help-text'."
-  (setq inactivate-current-input-method-function 'hangul-input-method-inactivate
+  (setq deactivate-current-input-method-function 'hangul-input-method-deactivate
        describe-current-input-method-function 'hangul-input-method-help
        hangul-input-method-help-text help-text)
   (quail-delete-overlays)
@@ -511,8 +520,8 @@ HELP-TEXT is a text set in `hangul-input-method-help-text'."
       (add-hook 'minibuffer-exit-hook 'quail-exit-from-minibuffer))
   (set (make-local-variable 'input-method-function) func))
 
-(defun hangul-input-method-inactivate ()
-  "Inactivate the current Hangul input method."
+(defun hangul-input-method-deactivate ()
+  "Deactivate the current Hangul input method."
   (interactive)
   (unwind-protect
       (progn
@@ -521,6 +530,10 @@ HELP-TEXT is a text set in `hangul-input-method-help-text'."
         (setq describe-current-input-method-function nil))
     (kill-local-variable 'input-method-function)))
 
+(define-obsolete-function-alias
+  'hangul-input-method-inactivate
+  'hangul-input-method-deactivate "24.3")
+
 (defun hangul-input-method-help ()
   "Describe the current Hangul input method."
   (interactive)
@@ -529,5 +542,4 @@ HELP-TEXT is a text set in `hangul-input-method-help-text'."
 
 (provide 'hangul)
 
-;; arch-tag: 26bc93fc-64ee-4fb1-b26d-22220d132dbe
 ;;; hangul.el ends here