lao.el 2.8 KB

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