aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/language/indian.el2
-rw-r--r--lisp/leim/quail/indian.el306
3 files changed, 247 insertions, 68 deletions
diff --git a/etc/NEWS b/etc/NEWS
index da2b1580240..19f6879a8c7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1047,6 +1047,13 @@ supported.
1047Type 'C-u C-h t' to select it in case your language setup does not do 1047Type 'C-u C-h t' to select it in case your language setup does not do
1048so automatically. 1048so automatically.
1049 1049
1050---
1051*** New default phonetic input method for the Tamil language environment.
1052The default input method for the Tamil language environment is now
1053"tamil-phonetic" which is a customizable phonetic input method. To
1054change the input method's translation rules, customize the user option
1055'tamil-translation-rules'.
1056
1050 1057
1051* Changes in Specialized Modes and Packages in Emacs 29.1 1058* Changes in Specialized Modes and Packages in Emacs 29.1
1052 1059
diff --git a/lisp/language/indian.el b/lisp/language/indian.el
index 2887d410adf..407173827fe 100644
--- a/lisp/language/indian.el
+++ b/lisp/language/indian.el
@@ -109,7 +109,7 @@ are supported in this language environment."))
109 "Tamil" '((charset unicode) 109 "Tamil" '((charset unicode)
110 (coding-system utf-8) 110 (coding-system utf-8)
111 (coding-priority utf-8) 111 (coding-priority utf-8)
112 (input-method . "tamil-itrans") 112 (input-method . "tamil-phonetic")
113 (sample-text . "Tamil (தமிழ்) வணக்கம்") 113 (sample-text . "Tamil (தமிழ்) வணக்கம்")
114 (documentation . "\ 114 (documentation . "\
115South Indian Language Tamil is supported in this language environment.")) 115South Indian Language Tamil is supported in this language environment."))
diff --git a/lisp/leim/quail/indian.el b/lisp/leim/quail/indian.el
index 04e95b0737b..62836f31319 100644
--- a/lisp/leim/quail/indian.el
+++ b/lisp/leim/quail/indian.el
@@ -127,47 +127,34 @@
127 indian-mlm-itrans-v5-hash "malayalam-itrans" "Malayalam" "MlmIT" 127 indian-mlm-itrans-v5-hash "malayalam-itrans" "Malayalam" "MlmIT"
128 "Malayalam transliteration by ITRANS method.") 128 "Malayalam transliteration by ITRANS method.")
129 129
130(defvar quail-tamil-itrans-syllable-table 130;; This is needed since the Unicode codepoint order does not reflect
131 (let ((vowels 131;; the actual order in the Tamil language.
132 '(("அ" nil "a") 132(defvar quail-tamil-itrans--consonant-order
133 ("ஆ" "ா" "A") 133 '("க" "ங" "ச" "ஞ" "ட" "ண"
134 ("இ" "ி" "i") 134 "த" "ந" "ப" "ம" "ய" "ர"
135 ("ஈ" "ீ" "I") 135 "ல" "வ" "ழ" "ள" "ற" "ன"
136 ("உ" "ு" "u") 136 "ஜ" "ஸ" "ஷ" "ஹ" "க்ஷ"
137 ("ஊ" "ூ" "U") 137 "க்‌ஷ" "ஶ"))
138 ("எ" "ெ" "e") 138
139 ("ஏ" "ே" "E") 139(defun quail-tamil-itrans-compute-syllable-table (vowels consonants)
140 ("ஐ" "ை" "ai") 140 "Return the syllable table for the input method as a string.
141 ("ஒ" "ொ" "o") 141VOWELS is a list of (VOWEL SIGN INPUT-SEQ) where VOWEL is the
142 ("ஓ" "ோ" "O") 142Tamil vowel character, SIGN is the vowel sign corresponding to
143 ("ஔ" "ௌ" "au"))) 143that vowel character or nil for none, and INPUT-SEQ is the input
144 (consonants 144sequence to insert VOWEL.
145 '(("க" "k") ; U+0B95 145
146 ("ங" "N^") ; U+0B99 146CONSONANTS is a list of (CONSONANT INPUT-SEQ...) where CONSONANT
147 ("ச" "ch") ; U+0B9A 147is the Tamil consonant character, and INPUT-SEQ is one or more
148 ("ஞ" "JN") ; U+0B9E 148strings that describe how to insert CONSONANT."
149 ("ட" "T") ; U+0B9F 149 (setq vowels (sort vowels
150 ("ண" "N") ; U+0BA3 150 (lambda (x y)
151 ("த" "t") ; U+0BA4 151 (string-lessp (car x) (car y)))))
152 ("ந" "n") ; U+0BA8 152 (setq consonants
153 ("ப" "p") ; U+0BAA 153 (sort consonants
154 ("ம" "m") ; U+0BAE 154 (lambda (x y)
155 ("ய" "y") ; U+0BAF 155 (or (seq-position (car x) quail-tamil-itrans--consonant-order) 1000)
156 ("ர" "r") ; U+0BB0 156 (or (seq-position (car y) quail-tamil-itrans--consonant-order) 1000))))
157 ("ல" "l") ; U+0BB2 157 (let ((virama #x0BCD)
158 ("வ" "v") ; U+0BB5
159 ("ழ" "z") ; U+0BB4
160 ("ள" "L") ; U+0BB3
161 ("ற" "rh") ; U+0BB1
162 ("ன" "nh") ; U+0BA9
163 ("ஜ" "j") ; U+0B9C
164 ("ஶ" nil) ; U+0BB6
165 ("ஷ" "Sh") ; U+0BB7
166 ("ஸ" "s") ; U+0BB8
167 ("ஹ" "h") ; U+0BB9
168 ("க்ஷ" "x" ) ; U+0B95
169 ))
170 (virama #x0BCD)
171 clm) 158 clm)
172 (with-temp-buffer 159 (with-temp-buffer
173 (insert "\n") 160 (insert "\n")
@@ -197,21 +184,45 @@
197 (insert (propertize "\t" 'display (list 'space :align-to clm)) 184 (insert (propertize "\t" 'display (list 'space :align-to clm))
198 (car c) (or (nth 1 v) "")) 185 (car c) (or (nth 1 v) ""))
199 (setq clm (+ clm 6))) 186 (setq clm (+ clm 6)))
200 (insert "\n" (or (nth 1 c) "") 187 (dolist (ct (cdr c))
201 (propertize "\t" 'display '(space :align-to 4)) 188 (insert "\n" (or ct "")
202 "|") 189 (propertize "\t" 'display '(space :align-to 4))
203 (setq clm 6) 190 "|")
204 191 (setq clm 6)
205 (dolist (v vowels) 192 (dolist (v vowels)
206 (apply #'insert (propertize "\t" 'display (list 'space :align-to clm)) 193 (apply #'insert (propertize "\t" 'display (list 'space :align-to clm))
207 (if (nth 1 c) (list (nth 1 c) (nth 2 v)) (list ""))) 194 (if ct (list ct (nth 2 v)) (list "")))
208 (setq clm (+ clm 6)))) 195 (setq clm (+ clm 6)))))
209 (insert "\n") 196 (insert "\n")
210 (insert "----+") 197 (insert "----+")
211 (insert-char ?- 74) 198 (insert-char ?- 74)
212 (insert "\n") 199 (insert "\n")
213 (buffer-string)))) 200 (buffer-string))))
214 201
202(defvar quail-tamil-itrans-syllable-table
203 (quail-tamil-itrans-compute-syllable-table
204 (let ((vowels (car indian-tml-base-table))
205 trans v ret)
206 (dotimes (i (length vowels))
207 (when (setq v (nth i vowels))
208 (when (characterp (car v))
209 (setcar v (string (car v))))
210 (setq trans (nth i (car indian-itrans-v5-table-for-tamil)))
211 (push (append v (list (if (listp trans) (car trans) trans)))
212 ret)))
213 ret)
214 (let ((consonants (cadr indian-tml-base-table))
215 trans c ret)
216 (dotimes (i (length consonants))
217 (when (setq c (nth i consonants))
218 (when (characterp c)
219 (setq c (string c)))
220 (setq trans (nth i (cadr indian-itrans-v5-table-for-tamil)))
221 (push (cons c (if (listp trans) trans (list trans)))
222 ret)))
223 (setq ret (nreverse ret))
224 ret)))
225
215(defvar quail-tamil-itrans-numerics-and-symbols-table 226(defvar quail-tamil-itrans-numerics-and-symbols-table
216 (let ((numerics '((?௰ "பத்து") (?௱ "நூறு") (?௲ "ஆயிரம்"))) 227 (let ((numerics '((?௰ "பத்து") (?௱ "நூறு") (?௲ "ஆயிரம்")))
217 (symbols '((?௳ "நாள்") (?௴ "மாதம்") (?௵ "வருடம்") 228 (symbols '((?௳ "நாள்") (?௴ "மாதம்") (?௵ "வருடம்")
@@ -244,25 +255,28 @@
244 (insert "\n") 255 (insert "\n")
245 (buffer-string)))) 256 (buffer-string))))
246 257
247(defun quail-tamil-itrans-compute-signs-table (digitp) 258(defun quail-tamil-itrans-compute-signs-table (digitp various)
248 "Compute the signs table for the tamil-itrans input method. 259 "Compute the signs table for the tamil-itrans input method.
249If DIGITP is non-nil, include the digits translation as well." 260If DIGITP is non-nil, include the digits translation as well.
250 (let ((various '((?ஃ . "H") ("ஸ்ரீ" . "srii") (?ௐ))) 261If VARIOUS is non-nil, then it should a list of (CHAR TRANS)
251 (digits "௦௧௨௩௪௫௬௭௮௯") 262where CHAR is the character/string to translate and TRANS is
263CHAR's translation."
264 (let ((digits "௦௧௨௩௪௫௬௭௮௯")
252 (width 6) clm) 265 (width 6) clm)
253 (with-temp-buffer 266 (with-temp-buffer
254 (insert "\n" (make-string 18 ?-) "+") 267 (insert "\n" (make-string 18 ?-))
255 (when digitp (insert (make-string 60 ?-))) 268 (when digitp
269 (insert "+" (make-string 60 ?-)))
256 (insert "\n") 270 (insert "\n")
257 (insert 271 (insert
258 (propertize "\t" 'display '(space :align-to 5)) "various" 272 (propertize "\t" 'display '(space :align-to 5)) "various"
259 (propertize "\t" 'display '(space :align-to 18)) "|") 273 (propertize "\t" 'display '(space :align-to 18)))
260 (when digitp 274 (when digitp
261 (insert 275 (insert
262 (propertize "\t" 'display '(space :align-to 45)) "digits")) 276 "|" (propertize "\t" 'display '(space :align-to 45)) "digits"))
263 (insert "\n" (make-string 18 ?-) "+") 277 (insert "\n" (make-string 18 ?-))
264 (when digitp 278 (when digitp
265 (insert (make-string 60 ?-))) 279 (insert "+" (make-string 60 ?-)))
266 (insert "\n") 280 (insert "\n")
267 (setq clm 0) 281 (setq clm 0)
268 282
@@ -270,7 +284,8 @@ If DIGITP is non-nil, include the digits translation as well."
270 (insert (propertize "\t" 'display (list 'space :align-to clm)) 284 (insert (propertize "\t" 'display (list 'space :align-to clm))
271 (car (nth i various))) 285 (car (nth i various)))
272 (setq clm (+ clm width))) 286 (setq clm (+ clm width)))
273 (insert (propertize "\t" 'display '(space :align-to 18)) "|") 287 (when digitp
288 (insert (propertize "\t" 'display '(space :align-to 18)) "|"))
274 (setq clm 20) 289 (setq clm 20)
275 (when digitp 290 (when digitp
276 (dotimes (i 10) 291 (dotimes (i 10)
@@ -281,25 +296,28 @@ If DIGITP is non-nil, include the digits translation as well."
281 (setq clm 0) 296 (setq clm 0)
282 (dotimes (i (length various)) 297 (dotimes (i (length various))
283 (insert (propertize "\t" 'display (list 'space :align-to clm)) 298 (insert (propertize "\t" 'display (list 'space :align-to clm))
284 (or (cdr (nth i various)) "")) 299 (or (cadr (nth i various)) ""))
285 (setq clm (+ clm width))) 300 (setq clm (+ clm width)))
286 (insert (propertize "\t" 'display '(space :align-to 18)) "|") 301 (when digitp
302 (insert (propertize "\t" 'display '(space :align-to 18)) "|"))
287 (setq clm 20) 303 (setq clm 20)
288 (when digitp 304 (when digitp
289 (dotimes (i 10) 305 (dotimes (i 10)
290 (insert (propertize "\t" 'display (list 'space :align-to clm)) 306 (insert (propertize "\t" 'display (list 'space :align-to clm))
291 (format "%d" i)) 307 (format "%d" i))
292 (setq clm (+ clm width)))) 308 (setq clm (+ clm width))))
293 (insert "\n" (make-string 18 ?-) "+") 309 (insert "\n" (make-string 18 ?-))
294 (when digitp 310 (when digitp
295 (insert (make-string 60 ?-) "\n")) 311 (insert "+" (make-string 60 ?-) "\n"))
296 (buffer-string)))) 312 (buffer-string))))
297 313
298(defvar quail-tamil-itrans-various-signs-and-digits-table 314(defvar quail-tamil-itrans-various-signs-and-digits-table
299 (quail-tamil-itrans-compute-signs-table t)) 315 (quail-tamil-itrans-compute-signs-table
316 t '((?ஃ "H") ("ஸ்ரீ" "srii") (?ௐ "OM"))))
300 317
301(defvar quail-tamil-itrans-various-signs-table 318(defvar quail-tamil-itrans-various-signs-table
302 (quail-tamil-itrans-compute-signs-table nil)) 319 (quail-tamil-itrans-compute-signs-table
320 nil '((?ஃ "H") ("ஸ்ரீ" "srii") (?ௐ "OM"))))
303 321
304(if nil 322(if nil
305 (quail-define-package "tamil-itrans" "Tamil" "TmlIT" t "Tamil ITRANS")) 323 (quail-define-package "tamil-itrans" "Tamil" "TmlIT" t "Tamil ITRANS"))
@@ -348,6 +366,160 @@ Their descriptions are included for easy reference.
348Full key sequences are listed below:") 366Full key sequences are listed below:")
349 367
350;;; 368;;;
369;;; Tamil phonetic input method
370;;;
371
372;; Define the input method straightaway.
373(quail-define-package "tamil-phonetic" "Tamil" "ழ" t
374 "Customisable Tamil phonetic input method.
375To change the translation rules of the input method, customize
376`tamil-translation-rules'.
377
378To use native Tamil digits, customize `tamil-translation-rules'
379accordingly.
380
381To end the current translation process, say \\<quail-translation-keymap>\\[quail-select-current] (defined in
382`quail-translation-keymap'). This is useful when there's a
383conflict between two possible translation.
384
385The current input scheme is:
386
387### Basic syllables (உயிர்மெய் எழுத்துக்கள்) ###
388\\=\\<tamil--syllable-table>
389
390### Miscellaneous ####
391\\=\\<tamil--signs-table>
392
393The following characters have NO input sequence associated with
394them by default. Their descriptions are included for easy
395reference.
396\\=\\<quail-tamil-itrans-numerics-and-symbols-table>
397
398Full key sequences are listed below:"
399 nil nil nil nil nil nil t)
400
401(defvar tamil--syllable-table nil)
402(defvar tamil--signs-table nil)
403(defvar tamil--hashtables
404 (cons (make-hash-table :test #'equal)
405 (make-hash-table :test #'equal)))
406(defvar tamil--vowel-signs
407 '(("அ" . t) ("ஆ" . ?ா) ("இ" . ?ி) ("ஈ" . ?ீ)
408 ("உ" . ?ு) ("ஊ" . ?ூ) ("எ" . ?ெ) ("ஏ" . ?ே)
409 ("ஐ" . ?ை) ("ஒ" . ?ொ) ("ஓ" . ?ோ) ("ஔ" . ?ௌ)))
410
411(defun tamil--setter (sym val)
412 (set-default sym val)
413 (tamil--update-quail-rules val))
414
415(defun tamil--make-tables (rules)
416 (let (v v-table v-trans
417 c-table c-trans
418 m-table m-trans)
419 (dolist (ch rules)
420 (cond
421 ;; Vowel.
422 ((setq v (assoc-default (car ch) tamil--vowel-signs))
423 (push (list (car ch) (and (characterp v) v)) v-table)
424 (push (cdr ch) v-trans))
425 ;; Consonant. It needs to end with pulli.
426 ((string-suffix-p "்" (car ch))
427 ;; Strip the pulli now.
428 (push (substring (car ch) 0 -1) c-table)
429 (push (cdr ch) c-trans))
430 ;; If nothing else, then consider it a misc character.
431 (t (push (car ch) m-table)
432 (push (cdr ch) m-trans))))
433 (list v-table v-trans c-table c-trans m-table m-trans)))
434
435(defun tamil--update-quail-rules (rules &optional name)
436 ;; This function does pretty much what `indian-make-hash' does
437 ;; except that we don't try to copy the structure of
438 ;; `indian-tml-base-table' which leads to less code hassle.
439 (let* ((quail-current-package (assoc (or name "tamil-phonetic") quail-package-alist))
440 (tables (tamil--make-tables rules))
441 (v (nth 0 tables))
442 (v-trans (nth 1 tables))
443 (c (nth 2 tables))
444 (c-trans (nth 3 tables))
445 (m (nth 4 tables))
446 (m-trans (nth 5 tables))
447 (pulli (string #x0BCD)))
448 (clrhash (car tamil--hashtables))
449 (clrhash (cdr tamil--hashtables))
450 (indian--puthash-v v v-trans tamil--hashtables)
451 (indian--puthash-c c c-trans pulli tamil--hashtables)
452 (indian--puthash-cv c c-trans v v-trans tamil--hashtables)
453 (indian--puthash-m m m-trans tamil--hashtables)
454 ;; Now override the current translation rules.
455 ;; Empty quail map is '(list nil)'.
456 (setf (nth 2 quail-current-package) '(nil))
457 (maphash (lambda (k v)
458 (quail-defrule k (if (length= v 1)
459 (string-to-char v)
460 (vector v))))
461 (cdr tamil--hashtables))
462 (setq tamil--syllable-table
463 (quail-tamil-itrans-compute-syllable-table
464 (mapcar (lambda (ch) (append ch (pop v-trans))) v)
465 (mapcar (lambda (ch) (cons ch (pop c-trans))) c))
466 tamil--signs-table
467 (quail-tamil-itrans-compute-signs-table
468 nil
469 (append (mapcar (lambda (ch) (cons ch (pop m-trans))) m)
470 (and (gethash "ஸ்" (car tamil--hashtables))
471 `(("ஸ்ரீ" ,(concat (gethash "ஸ்" (car tamil--hashtables))
472 (gethash "ரீ" (car tamil--hashtables)))))))))))
473
474(defgroup tamil-input nil
475 "Translation rules for the Tamil input method."
476 :prefix "tamil-"
477 :group 'leim)
478
479(defcustom tamil-translation-rules
480 ;; Vowels.
481 '(("அ" "a") ("ஆ" "aa") ("இ" "i") ("ஈ" "ii")
482 ("உ" "u") ("ஊ" "uu") ("எ" "e") ("ஏ" "ee")
483 ("ஐ" "ai") ("ஒ" "o") ("ஓ" "oo") ("ஔ" "au" "ow")
484
485 ;; Consonants.
486 ("க்" "k" "g") ("ங்" "ng") ("ச்" "ch" "s") ("ஞ்" "nj") ("ட்" "t" "d")
487 ("ண்" "N") ("த்" "th" "dh") ("ந்" "nh") ("ப்" "p" "b") ("ம்" "m")
488 ("ய்" "y") ("ர்" "r") ("ல்" "l") ("வ்" "v") ("ழ்" "z" "zh")
489 ("ள்" "L") ("ற்" "rh") ("ன்" "n")
490 ;; Sanskrit.
491 ("ஜ்" "j") ("ஸ்" "S") ("ஷ்" "sh") ("ஹ்" "h")
492 ("க்‌ஷ்" "ksh") ("க்ஷ்" "ksH") ("ஶ்" "Z")
493
494 ;; Misc. ஃ is neither a consonant nor a vowel.
495 ("ஃ" "F" "q")
496 ("ௐ" "OM"))
497 "List of input sequences to translate to Tamil characters.
498Each element should be (CHARACTER INPUT-SEQUENCES...) where
499CHARACTER is the Tamil character, and INPUT-SEQUENCES is a list
500of input sequences which produce that character.
501
502CHARACTER is considered as a consonant (மெய் எழுத்து) if it ends
503with a pulli (virama).
504
505CHARACTER that is neither a vowel nor a consonant are inserted as
506is."
507 :group 'tamil-input
508 :type '(alist :key-type string :value-type (repeat string))
509 :set #'tamil--setter
510 :version "29.1"
511 :options
512 (delq nil
513 (append (mapcar #'car tamil--vowel-signs)
514 (mapcar (lambda (x) (if (characterp x)
515 (string x #x0BCD)
516 (and x (concat x "்"))))
517 (nth 1 indian-tml-base-table))
518 '("ஃ" "ௐ")
519 ;; Digits.
520 (mapcar #'string (nth 3 indian-tml-base-digits-table)))))
521
522;;;
351;;; Input by Inscript 523;;; Input by Inscript
352;;; 524;;;
353 525