]> code.delx.au - gnu-emacs/blobdiff - leim/quail/japanese.el
* syntax.c (Fchar_syntax): Check the arg is a character.
[gnu-emacs] / leim / quail / japanese.el
index 69239d5b9f64724603a134d2449498fd0c6d66d9..e1f7e74e0306e6d3f2b93827e40e0458dca65abe 100644 (file)
@@ -1,16 +1,20 @@
-;;; quail/japanese.el --- Quail package for inputting Japanese
+;;; japanese.el --- Quail package for inputting Japanese  -*-coding: iso-2022-7bit;-*-
 
-;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;;   Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010
+;;   National Institute of Advanced Industrial Science and Technology (AIST)
+;;   Registration Number H14PRO021
 
 ;; Keywords: multilingual, input method, Japanese
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,9 +22,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
 
 ;;; Code:
 
@@ -54,7 +58,7 @@
              (setq unread-command-events
                    (list (aref quail-current-key control-flag)))))))
   control-flag)
-        
+
 ;; Convert Hiragana <-> Katakana in the current translation region.
 (defun quail-japanese-toggle-kana ()
   (interactive)
@@ -77,9 +81,9 @@
   (when (= (char-before (overlay-end quail-conv-overlay)) ?n)
     ;; The last char is `n'.  We had better convert it to `\e$B$s\e(B'
     ;; before kana-kanji conversion.
-    (goto-char (overlay-end quail-conv-overlay))
-    (delete-char -1)
-    (insert ?\e$B$s\e(B))
+    (goto-char (1- (overlay-end quail-conv-overlay)))
+    (insert ?\e$B$s\e(B)
+    (delete-char 1))
   (let* ((from (copy-marker (overlay-start quail-conv-overlay)))
         (len (- (overlay-end quail-conv-overlay) from)))
     (quail-delete-overlays)
     ("ra" "\e$B$i\e(B") ("ri" "\e$B$j\e(B") ("ru" "\e$B$k\e(B") ("re" "\e$B$l\e(B") ("ro" "\e$B$m\e(B")
     ("la" "\e$B$i\e(B") ("li" "\e$B$j\e(B") ("lu" "\e$B$k\e(B") ("le" "\e$B$l\e(B") ("lo" "\e$B$m\e(B")
     ("wa" "\e$B$o\e(B") ("wi" "\e$B$p\e(B") ("wu" "\e$B$&\e(B") ("we" "\e$B$q\e(B") ("wo" "\e$B$r\e(B")
-    ("n'" "\e$B$s\e(B")                               
+    ("n'" "\e$B$s\e(B")
     ("ga" "\e$B$,\e(B") ("gi" "\e$B$.\e(B") ("gu" "\e$B$0\e(B") ("ge" "\e$B$2\e(B") ("go" "\e$B$4\e(B")
     ("za" "\e$B$6\e(B") ("zi" "\e$B$8\e(B") ("zu" "\e$B$:\e(B") ("ze" "\e$B$<\e(B") ("zo" "\e$B$>\e(B")
     ("da" "\e$B$@\e(B") ("di" "\e$B$B\e(B") ("du" "\e$B$E\e(B") ("de" "\e$B$G\e(B") ("do" "\e$B$I\e(B")
@@ -459,7 +463,7 @@ qh: shift to the input method `japanese',
 ("p" "\e$B#p\e(B") ("q" "\e$B#q\e(B") ("r" "\e$B#r\e(B") ("s" "\e$B#s\e(B")
 ("t" "\e$B#t\e(B") ("u" "\e$B#u\e(B") ("v" "\e$B#v\e(B") ("w" "\e$B#w\e(B")
 ("x" "\e$B#x\e(B") ("y" "\e$B#y\e(B") ("z" "\e$B#z\e(B") ("{" "\e$B!P\e(B")
-("|" "\e$B!C\e(B") ("}" "\e$B!Q\e(B") ("~" "\e$B!A\e(B") 
+("|" "\e$B!C\e(B") ("}" "\e$B!Q\e(B") ("~" "\e$B!A\e(B")
 
 ("qq" quail-japanese-switch-package)
 ("qh" quail-japanese-switch-package)
@@ -485,9 +489,24 @@ qq:        toggle between this input method and the input method `japanese-ascii'.
  nil t t nil nil nil nil nil
  'quail-japanese-hankaku-update-translation)
 
-;; Use the same map as that of `japanese'.
-(setcar (cdr (cdr quail-current-package))
-       (nth 2 (assoc "japanese" quail-package-alist)))
+(dolist (elt quail-japanese-transliteration-rules)
+  (quail-defrule (car elt)
+                (let ((trans (nth 1 elt)))
+                  (when (or (stringp trans) (vectorp trans))
+                    (let ((s (japanese-hankaku (if (stringp trans)
+                                                   trans
+                                                 (aref trans 0)))))
+                      ;; If the result of the conversion is a string
+                      ;; containing more than one character, make the
+                      ;; result a vector, so that quail-defrule
+                      ;; recognizes the whole string is the
+                      ;; translation, instead of interpreting
+                      ;; individual characters as alternative
+                      ;; translations.
+                      (if (and (stringp s) (> (length s) 1))
+                          (setq trans (vector s))
+                        (setq trans s))))
+                  trans)))
 
 (quail-define-package
  "japanese-hiragana" "Japanese" "\e$B$"\e(B"
@@ -510,7 +529,7 @@ qq: toggle between this input method and the input method `japanese-ascii'.
       (setq quail-current-str (japanese-katakana quail-current-str)))
   control-flag)
 
-(quail-define-package 
+(quail-define-package
  "japanese-katakana" "Japanese" "\e$B%"\e(B"
  nil
  "Japanese katakana input method by Roman transliteration."
@@ -520,9 +539,11 @@ qq:        toggle between this input method and the input method `japanese-ascii'.
 (dolist (elt quail-japanese-transliteration-rules)
   (quail-defrule (car elt)
                 (let ((trans (nth 1 elt)))
-                  (cond((stringp trans)
-                        (japanese-katakana trans))
-                       ((vectorp trans)
-                        (vector (japanese-katakana (aref trans 0))))
-                       (t trans)))))
-
+                  (cond ((stringp trans)
+                         (japanese-katakana trans))
+                        ((vectorp trans)
+                         (vector (japanese-katakana (aref trans 0))))
+                        (t trans)))))
+
+;; arch-tag: 47e0bfd4-6ecc-4d01-89a8-d687c5e01ff7
+;;; japanese.el ends here