1;;; lao.el --- support for Lao -*- coding: utf-8 -*-
2
3;; Copyright (C) 2001-2021 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
8;; Copyright (C) 2003
9;;   National Institute of Advanced Industrial Science and Technology (AIST)
10;;   Registration Number H13PRO009
11
12;; Keywords: multilingual, Lao
13
14;; This file is part of GNU Emacs.
15
16;; GNU Emacs is free software: you can redistribute it and/or modify
17;; it under the terms of the GNU General Public License as published by
18;; the Free Software Foundation, either version 3 of the License, or
19;; (at your option) any later version.
20
21;; GNU Emacs is distributed in the hope that it will be useful,
22;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24;; GNU General Public License for more details.
25
26;; You should have received a copy of the GNU General Public License
27;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
28
29;;; Commentary:
30
31;;; Code:
32
33(define-coding-system 'lao
34  "8-bit encoding for ASCII (MSB=0) and LAO (MSB=1)."
35  :coding-type 'charset
36  :mnemonic ?L
37  :charset-list '(lao))
38
39(set-language-info-alist
40 "Lao" '((charset lao)
41	 (coding-system lao)
42	 (coding-priority lao)
43	 (input-method . "lao")
44	 (unibyte-display . lao)
45	 (features lao-util)
46	 (documentation . t)))
47
48(let ((consonant "ກ-ຮໜໝ")
49      (tone "່-໌")
50      (vowel-upper-lower "ັິ-ົໍ")
51      (semivowel-lower "ຼ")
52      (fallback-rule [nil 0 compose-gstring-for-graphic]))
53  ;;            target characters    regexp
54  ;;            -----------------    ------
55  (dolist (l `((,vowel-upper-lower . "[c].[t]?")
56	       (,tone .              "[c].")
57	       (,semivowel-lower .   "[c].[v][t]?")
58	       (,semivowel-lower .   "[c].[t]")))
59    (let* ((chars (car l))
60	   (len (length chars))
61	   ;; Replace `c', `t', `v' to consonant, tone, and vowel.
62	   (regexp (mapconcat #'(lambda (c)
63				  (cond ((= c ?c) consonant)
64					((= c ?t) tone)
65					((= c ?v) vowel-upper-lower)
66					(t (string c))))
67			      (cdr l) ""))
68	   ;; Element of composition-function-table.
69	   (elt (list (vector regexp 1 'lao-composition-function)
70		      fallback-rule))
71	   ch)
72      (dotimes (i len)
73	(setq ch (aref chars i))
74	(if (and (> i 1) (= (aref chars (1- i)) ?-))
75	    ;; End of character range.
76	    (set-char-table-range composition-function-table
77				  (cons (aref chars (- i 2)) ch) elt)
78	  (if (or (= (1+ i) len)
79		  (and (/= ch ?-) (/= (aref chars (1+ i)) ?-)))
80	      ;; A character not forming a range.
81	      (set-char-table-range composition-function-table ch elt)))))))
82
83(provide 'lao)
84
85;;; lao.el ends here
86