-;;; quail/lrt.el --- Quail package for inputting Lao characters by LRT method
-
-;; Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
-;; Licensed to the Free Software Foundation.
-
-;; Keywords: multilingual, input method, Lao, LRT.
-
-;; This file is part of GNU Emacs.
-
-;; 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.
-
-;; GNU Emacs is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;; 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.
-
-;;; Code:
-
-(require 'quail)
-(require 'lao-util)
-
-;; LRT (Lao Roman Transcription) input method accepts the following
-;; key sequence:
-;; consonant [+ semi-vowel-sign-lo ] + vowel [+ maa-sakod ] [+ tone-mark ]
-
-(eval-and-compile
-
-;; Upper vowels and tone-marks are put on the letter.
-;; Semi-vowel-sign-lo and lower vowels are put under the letter.
-(defconst lrt-single-consonant-table
- '(("k" . ?\e(1!\e(B)
- ("kh" . ?\e(1"\e(B)
- ("qh" . ?\e(1$\e(B)
- ("ng" . ?\e(1'\e(B)
- ("j" . ?\e(1(\e(B)
- ("s" . ?\e(1J\e(B)
- ("x" . ?\e(1*\e(B)
- ("y" . ?\e(1-\e(B)
- ("d" . ?\e(14\e(B)
- ("t" . ?\e(15\e(B)
- ("th" . ?\e(16\e(B)
- ("dh" . ?\e(17\e(B)
- ("n" . ?\e(19\e(B)
- ("b" . ?\e(1:\e(B)
- ("p" . ?\e(1;\e(B)
- ("hp" . ?\e(1<\e(B)
- ("fh" . ?\e(1=\e(B)
- ("ph" . ?\e(1>\e(B)
- ("f" . ?\e(1?\e(B)
- ("m" . ?\e(1A\e(B)
- ("gn" . ?\e(1B\e(B)
- ("l" . ?\e(1E\e(B)
- ("r" . ?\e(1C\e(B)
- ("v" . ?\e(1G\e(B)
- ("w" . ?\e(1G\e(B)
- ("hh" . ?\e(1K\e(B)
- ("O" . ?\e(1M\e(B)
- ("h" . ?\e(1N\e(B)
- ("nh" . ?\e(1|\e(B)
- ("mh" . ?\e(1}\e(B)
- ("lh" . ?\e0\e(1K\\e1\e(B)
- ))
-
-;; Semi-vowel-sign-lo is put under the first letter.
-;; Lower vowels are put under the last letter.
-;; Upper vowels and tone-marks are put on the last letter.
-(defconst lrt-double-consonant-table
- '(("ngh" . "\e(1K'\e(B")
- ("yh" . "\e(1K]\e(B")
- ("wh" . "\e(1KG\e(B")
- ("hl" . "\e(1KE\e(B")
- ("hy" . "\e(1K-\e(B")
- ("hn" . "\e(1K9\e(B")
- ("hm" . "\e(1KA\e(B")
- ))
-
-(defconst lrt-semi-vowel-sign-lo
- '("r" . ?\e(1\\e(B))
-
-(defconst lrt-vowel-table
- '(("a" "\e(1P\e(B" (0 ?\e(1P\e(B) (0 ?\e(1Q\e(B))
- ("ar" "\e(1R\e(B" (0 ?\e(1R\e(B))
- ("i" "\e(1T\e(B" (0 ?\e(1T\e(B))
- ("ii" "\e(1U\e(B" (0 ?\e(1U\e(B))
- ("eu" "\e(1V\e(B" (0 ?\e(1V\e(B))
- ("ur" "\e(1W\e(B" (0 ?\e(1W\e(B))
- ("u" "\e(1X\e(B" (0 ?\e(1X\e(B))
- ("uu" "\e(1Y\e(B" (0 ?\e(1Y\e(B))
- ("e" "\e(1`\e(B \e(1P\e(B" (?\e(1`\e(B 0 ?\e(1P\e(B) (?\e(1`\e(B 0 ?\e(1Q\e(B))
- ("ee" "\e(1`\e(B" (?\e(1`\e(B 0))
- ("ae" "\e(1a\e(B \e(1P\e(B" (?\e(1a\e(B 0 ?\e(1P\e(B) (?\e(1a\e(B 0 ?\e(1Q\e(B))
- ("aa" "\e(1a\e(B" (?\e(1a\e(B 0))
- ("o" "\e(1b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sakod-table
- '((?k . ?\e(1!\e(B)
- (?g . ?\e(1'\e(B)
- (?y . ?\e(1-\e(B)
- (?d . ?\e(14\e(B)
- (?n . ?\e(19\e(B)
- (?b . ?\e(1:\e(B)
- (?m . ?\e(1A\e(B)
- (?v . ?\e(1G\e(B)
- (?w . ?\e(1G\e(B)
- ))
-
-(defconst lrt-tone-mark-table
- '(("'" . ?\e(1h\e(B)
- ("\"" . ?\e(1i\e(B)
- ("^" . ?\e(1j\e(B)
- ("+" . ?\e(1k\e(B)
- ("~" . ?\e(1l\e(B)))
-
-;; Return list of composing patterns for normal (without maa-sakod)
-;; key sequence and with-maa-sakod key sequence starting with single
-;; consonant C and optional SEMI-VOWEL.
-(defun lrt-composing-pattern-single-c (c semi-vowel vowel-pattern)
- (let* ((patterns (copy-sequence vowel-pattern))
- (tail patterns)
- place)
- ;; Embed C and SEMI-VOWEL (if any) at the place of 0.
- (while tail
- ;; At first, make a copy.
- (setcar tail (copy-sequence (car tail)))
- ;; Then, do embedding.
- (setq place (memq 0 (car tail)))
- (setcar place c)
- (if semi-vowel
- (setcdr place (cons semi-vowel (cdr place))))
- (setq tail (cdr tail)))
- patterns))
-
-;; Return list of composing patterns for normal (without maa-sakod)
-;; key sequence and with-maa-sakod key sequence starting with double
-;; consonant STR and optional SEMI-VOWEL.
-(defun lrt-composing-pattern-double-c (str semi-vowel vowel-pattern)
- (let* ((patterns (copy-sequence vowel-pattern))
- (tail patterns)
- (chars (string-to-list str))
- place)
- ;; Embed C and SEMI-VOWEL (if any) at the place of 0.
- (while tail
- ;; At first, make a copy.
- (setcar tail (copy-sequence (car tail)))
- ;; Then, do embedding.
- (setq place (memq 0 (car tail)))
- (setcar place (car chars))
- (setcdr place (cons (nth 1 chars) (cdr place)))
- (if semi-vowel
- ;; Embed SEMI-VOWEL in between CHARS.
- (setcdr place (cons semi-vowel (cdr place))))
- (setq tail (cdr tail)))
- patterns))
-
-;; Return a string made of characters in CHAR-LIST while composing
-;; such characters as vowel-upper, vowel-lower, semi-vowel(lower),
-;; and tone-mark with the preceding base character.
-(defun lrt-compose-string (char-list)
- ;; Make a copy because the following work alters it.
- (setq char-list (copy-sequence char-list))
- (let ((i -1)
- (l char-list))
- (while l
- (if (memq (get-char-code-property (car l) 'phonetic-type)
- '(vowel-upper vowel-lower semivowel-lower tone))
- (let (composed-char)
- (if (< i 0)
- ;; No preceding base character.
- (error "Invalid CHAR-LIST: %s" char-list))
- (setq composed-char
- (string-to-char (compose-chars (nth i char-list) (car l))))
- (setcar (nthcdr i char-list) composed-char)
- (setq l (cdr l))
- (setcdr (nthcdr i char-list) l))
- (setq l (cdr l))
- (setq i (1+ i))))
- (concat (apply 'vector char-list))))
-
-(defun lrt-compose-c-s-v (consonant semi-vowel vowel-pattern)
- (let ((pattern-list
- (if (integerp consonant)
- (lrt-composing-pattern-single-c
- consonant semi-vowel vowel-pattern)
- (lrt-composing-pattern-double-c
- consonant semi-vowel vowel-pattern))))
- (cons (vector (lrt-compose-string (car pattern-list)))
- (cons t pattern-list))))
-
-)
-
-(defun lrt-handle-maa-sakod ()
- (interactive)
- (if (or (= (length quail-current-key) 0)
- (not quail-current-data))
- (quail-self-insert-command)
- (if (not (car quail-current-data))
- (progn
- (setq quail-current-data nil)
- (setq unread-command-events
- (cons last-command-event unread-command-events))
- (quail-terminate-translation))
- (if (not (integerp last-command-event))
- (error "Bogus calling sequence"))
- (let* ((maa-sakod (cdr (assq last-command-event lrt-maa-sakod-table)))
- (maa-sakod-pattern (append
- (or (cdr (assq maa-sakod
- (nthcdr 3 quail-current-data)))
- (nth 2 quail-current-data)
- (nth 1 quail-current-data))
- (list maa-sakod))))
- (quail-delete-region)
- (setq quail-current-str (lrt-compose-string maa-sakod-pattern))
- (insert quail-current-str)
- (setq quail-current-key " ")
- (quail-show-translations)
- (setq quail-current-data (list nil maa-sakod-pattern))))))
-
-(defun lrt-handle-tone-mark ()
- (interactive)
- (if (= (length quail-current-key) 0)
- (quail-self-insert-command)
- (if (not quail-current-data)
- (progn
- (setq unread-command-events
- (cons last-command-event unread-command-events))
- (quail-terminate-translation))
- (if (not (integerp last-command-event))
- (error "Bogus calling sequence"))
- (let* ((tone-mark (cdr (assoc (char-to-string last-command-event)
- lrt-tone-mark-table)))
- (tone-mark-pattern
- (if (car quail-current-data)
- (copy-sequence (nth 1 quail-current-data))
- ;; No need of copy because lrt-handle-maa-sakod should
- ;; have already done it.
- (nth 1 quail-current-data)))
- (tail tone-mark-pattern)
- (double-consonant-tail '(?\e(1'\e(B ?\e(1]\e(B ?\e(1G\e(B ?\e(1E\e(B ?\e(1-\e(B ?\e(19\e(B ?\e(1A\e(B))
- place)
- ;; Find a place to embed TONE-MARK. It should be after a
- ;; single or double consonant and following vowels.
- (while (and tail (not place))
- (if (and
- (eq (get-char-code-property (car tail) 'phonetic-type)
- 'consonant)
- ;; Skip `\e(1K\e(B' if it is the first letter of double consonant.
- (or (/= (car tail) ?\e(1K\e(B)
- (not (cdr tail))
- (not
- (if (= (car (cdr tail)) ?\e(1\\e(B)
- (and (cdr (cdr tail))
- (memq (car (cdr (cdr tail))) double-consonant-tail))
- (memq (car (cdr tail)) double-consonant-tail)))))
- (progn
- (setq place tail)
- (setq tail (cdr tail))
- (while (and tail
- (memq (get-char-code-property (car tail)
- 'phonetic-type)
- '(vowel-upper vowel-lower semivowel-lower)))
- (setq place tail tail (cdr tail))))
- (setq tail (cdr tail))))
- ;; Embed TONE-MARK.
- (setcdr place (cons tone-mark (cdr place)))
- (quail-delete-region)
- (insert (lrt-compose-string tone-mark-pattern))
- (setq quail-current-data nil)
- (quail-terminate-translation)))))
-
-(defmacro lrt-generate-quail-map ()
- `(quail-install-map
- ',(let ((map (list nil))
- (semi-vowel-key (car lrt-semi-vowel-sign-lo))
- (semi-vowel-char (cdr lrt-semi-vowel-sign-lo))
- l1 e1 l2 e2 pattern key)
- ;; Single consonants.
- (setq l1 lrt-single-consonant-table)
- (while l1
- (setq e1 (car l1))
- (quail-defrule-internal (car e1) (cdr e1) map)
- (quail-defrule-internal
- (concat (car e1) semi-vowel-key)
- (compose-string (format "%c%c" (cdr e1) semi-vowel-char))
- map)
- (setq l2 lrt-vowel-table)
- (while l2
- (setq e2 (car l2))
- (setq key (concat (car e1) (car e2))
- pattern (lrt-compose-c-s-v (cdr e1) nil (nthcdr 2 e2)))
- (quail-defrule-internal key pattern map)
- (quail-defrule-internal
- (concat key " ")
- (vector (concat (aref (car pattern) 0) " ")) map)
- (setq key (concat (car e1) semi-vowel-key (car e2))
- pattern (lrt-compose-c-s-v (cdr e1) semi-vowel-char
- (nthcdr 2 e2)))
- (quail-defrule-internal key pattern map)
- (quail-defrule-internal
- (concat key " ")
- (vector (concat (aref (car pattern) 0) " ")) map)
- (setq l2 (cdr l2)))
- (setq l1 (cdr l1)))
-
- ;; Double consonants.
- (setq l1 lrt-double-consonant-table)
- (while l1
- (setq e1 (car l1))
- (quail-defrule-internal (car e1) (vector (cdr e1)) map)
- (quail-defrule-internal
- (concat (car e1) semi-vowel-key)
- (vector (concat (compose-string
- (format "%c%c" (sref (cdr e1) 0) semi-vowel-char))
- (substring (cdr e1) (charset-bytes 'lao))))
- map)
- (setq l2 lrt-vowel-table)
- (while l2
- (setq e2 (car l2))
- (setq key (concat (car e1) (car e2))
- pattern (lrt-compose-c-s-v (cdr e1) nil (nthcdr 2 e2)))
- (quail-defrule-internal key pattern map)
- (quail-defrule-internal
- (concat key " ")
- (vector (concat (aref (car pattern) 0) " ")) map)
- (setq key (concat (car e1) semi-vowel-key (car e2))
- pattern (lrt-compose-c-s-v (cdr e1) semi-vowel-char
- (nthcdr 2 e2)))
- (quail-defrule-internal key pattern map)
- (quail-defrule-internal
- (concat key " ")
- (vector (concat (aref (car pattern) 0) " ")) map)
- (setq l2 (cdr l2)))
- (setq l1 (cdr l1)))
-
- ;; Vowels.
- (setq l1 lrt-vowel-table)
- (while l1
- (setq e1 (car l1) l1 (cdr l1))
- (quail-defrule-internal (car e1) (vector (nth 1 e1)) map))
-
- ;; Tone-marks.
- (setq l1 lrt-tone-mark-table)
- (while l1
- (setq e1 (car l1) l1 (cdr l1))
- (quail-defrule-internal (car e1) (cdr e1) map))
-
- map)))
-
-(quail-define-package
- "lao-lrt" "Lao" "\e(1"\e(BR" t
- "Lao input method using LRT (Lao Roman Transcription)"
- '(("k" . lrt-handle-maa-sakod)
- ("g" . lrt-handle-maa-sakod)
- ("y" . lrt-handle-maa-sakod)
- ("d" . lrt-handle-maa-sakod)
- ("n" . lrt-handle-maa-sakod)
- ("b" . lrt-handle-maa-sakod)
- ("m" . lrt-handle-maa-sakod)
- ("v" . lrt-handle-maa-sakod)
- ("w" . lrt-handle-maa-sakod)
- ("'" . lrt-handle-tone-mark)
- ("\"" . lrt-handle-tone-mark)
- ("^" . lrt-handle-tone-mark)
- ("+" . lrt-handle-tone-mark)
- ("~" . lrt-handle-tone-mark))
- 'forget-last-selection 'deterministic 'kbd-translate 'show-layout)
-
-(lrt-generate-quail-map)
+;;; lrt.el --- Quail package for inputting Lao characters by LRT method -*-coding: iso-2022-7bit;-*-
+
+;; Copyright (C) 1998, 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, Lao, LRT.
+
+;; This file is part of GNU Emacs.
+
+;; 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 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
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'quail)
+(require 'lao-util)
+
+;; LRT (Lao Roman Transcription) input method accepts the following
+;; key sequence:
+;; consonant [+ semi-vowel-sign-lo ] + vowel [+ maa-sakod ] [+ tone-mark ]
+
+(defun quail-lao-update-translation (control-flag)
+ (if (integerp control-flag)
+ ;; Non-composable character typed.
+ (setq quail-current-str
+ (buffer-substring (overlay-start quail-overlay)
+ (overlay-end quail-overlay))
+ unread-command-events
+ (string-to-list
+ (substring quail-current-key control-flag)))
+ (let ((lao-str (lao-transcribe-roman-to-lao-string quail-current-key)))
+ (if (> (aref lao-str 0) 255)
+ (setq quail-current-str lao-str)
+ (or quail-current-str
+ (setq quail-current-str quail-current-key)))))
+ control-flag)
+
+
+(quail-define-package
+ "lao-lrt" "Lao" "\e(1E\e(BR" t
+ "Lao input method using LRT (Lao Roman Transcription).
+`\\' (backslash) + number-key => \e(1p\e(B,\e(1q\e(B,\e(1r\e(B,... LAO DIGIT ZERO, ONE, TWO, ...
+`\\' (backslash) + `\\' => \e(1f\e(B LAO KO LA (REPETITION)
+`\\' (backslash) + `$' => \e(1O\e(B LAO ELLIPSIS
+"
+ nil 'forget-last-selection 'deterministic 'kbd-translate 'show-layout
+ nil nil nil 'quail-lao-update-translation nil t)
+
+;; LRT (Lao Roman Transcription) input method accepts the following
+;; key sequence:
+;; consonant [ semi-vowel-sign-lo ] vowel [ maa-sakod ] [ tone-mark ]
+
+(quail-install-map
+ (quail-map-from-table
+ '((base-state (lao-transcription-consonant-alist . sv-state)
+ lao-transcription-vowel-alist
+ lao-transcription-tone-alist)
+ (sv-state (lao-transcription-semi-vowel-alist . v-state)
+ (lao-transcription-vowel-alist . mt-state))
+ (v-state (lao-transcription-vowel-alist . mt-state))
+ (mt-state (lao-transcription-maa-sakod-alist . t-state)
+ lao-transcription-tone-alist)
+ (t-state lao-transcription-tone-alist))))
+
+;; arch-tag: f65e4038-e187-4906-997b-d2de7ed813d2
+;;; lrt.el ends here