From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Visuwesh Newsgroups: gmane.emacs.bugs Subject: bug#56323: 29.0.50; [v2] Add new customisable phonetic Tamil input method Date: Fri, 01 Jul 2022 18:29:00 +0530 Message-ID: <878rpdq99n.fsf@gmail.com> References: <87pmiqe4da.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17590"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) To: 56323@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 01 15:01:00 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o7GGa-0004Gj-9H for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Jul 2022 15:01:00 +0200 Original-Received: from localhost ([::1]:34048 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7GGY-0005BP-PX for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 01 Jul 2022 09:00:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7GFe-0005BB-N9 for bug-gnu-emacs@gnu.org; Fri, 01 Jul 2022 09:00:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7GFe-0001nv-Br for bug-gnu-emacs@gnu.org; Fri, 01 Jul 2022 09:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o7GFe-0005W2-9P for bug-gnu-emacs@gnu.org; Fri, 01 Jul 2022 09:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Visuwesh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Jul 2022 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56323 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 56323-submit@debbugs.gnu.org id=B56323.165668035521106 (code B ref 56323); Fri, 01 Jul 2022 13:00:02 +0000 Original-Received: (at 56323) by debbugs.gnu.org; 1 Jul 2022 12:59:15 +0000 Original-Received: from localhost ([127.0.0.1]:36644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7GEs-0005UL-Io for submit@debbugs.gnu.org; Fri, 01 Jul 2022 08:59:15 -0400 Original-Received: from mail-pg1-f194.google.com ([209.85.215.194]:36623) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7GEq-0005U1-4m for 56323@debbugs.gnu.org; Fri, 01 Jul 2022 08:59:13 -0400 Original-Received: by mail-pg1-f194.google.com with SMTP id s206so2352164pgs.3 for <56323@debbugs.gnu.org>; Fri, 01 Jul 2022 05:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=jzFq3u2cWhjmZbp2qx1JyDwuqrcSNUD6xAik0zRSePQ=; b=ACmY/eUT93XNVSgmux5w9s99Bc7KAryF9eQv8jAANzigAEyto8GnHA2Dvpi16MMLLP eQxmQLXEVWvvkJh0KtVrWOPITSQ4Vb/nr6YC/zowl4XVTOayAD37VTJz2SegCbOO7/gP jTmXBT4nExE0Km+JEaONlNR/AVedh9UiDXPITZ4d98wIhSgxKv7Wumt4PpT14acmy5ql GKmN4bDEaUbqyGCGKvqVXALf9eGPXxuX7bdq2IOSfW7BVykbr5jBTthOngnHXwL6+WL4 ySPjoXQhqEcWKcLt/D7CyM97bMru/elAyrmaF3WDBpNBl0xYX3fpJI6vWLbwqiHVnh2T uqdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=jzFq3u2cWhjmZbp2qx1JyDwuqrcSNUD6xAik0zRSePQ=; b=5VfwPIIXXzHD+UTvJ5TheDgeOb3IN3xf9Jz6i2nR04ilgzKFXo4lSaNM4vOYoFyXnv AL/7hgVsq89zbfjWEx6hZBPfhIP42p6nypUMc3jyMAay7VFvTdLfXoG4IcHxfY2/WosW UHIHbW7xj9s/M3slkNgIruczlK/HpqxxJWimcQGRF6Vn0PeTdZizCV+EwSQaopceNIiC TXmH3dr4KwfRrlZT7t4LhGp7WjgWIDT+SHs12q5vGZHYDxqoS5fola7/izVc8WL9/pGB coiv4W/WeGNffpGnvp6H+dSSCtFGBkLkSwlba3kHnMmnTJBngddfiL4+9Ddc1lru/eus Lyig== X-Gm-Message-State: AJIora+ULwbOTQO9ZMt1APr/HdLS5N7vqcNKnqk9XNuqLWSJD2nCMTb7 wRs8bqKztQ138w37fzWabHN12avM4lo= X-Google-Smtp-Source: AGRyM1s46OxtKgS30xhNdYz7m8c1pI78s9k+9dXfCUBuJM9zsj1Z/GhgtGGrS0BmaZMMOTB85R4LIA== X-Received: by 2002:aa7:93a5:0:b0:51b:e0f8:97a6 with SMTP id x5-20020aa793a5000000b0051be0f897a6mr19987125pff.44.1656680344592; Fri, 01 Jul 2022 05:59:04 -0700 (PDT) Original-Received: from localhost ([49.204.133.141]) by smtp.gmail.com with ESMTPSA id a4-20020a62bd04000000b00525714c3e07sm15454617pff.48.2022.07.01.05.59.02 for <56323@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 05:59:03 -0700 (PDT) In-Reply-To: <87pmiqe4da.fsf@gmail.com> (Visuwesh's message of "Thu, 30 Jun 2022 17:43:21 +0530") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235805 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable [=E0=AE=B5=E0=AE=BF=E0=AE=AF=E0=AE=BE=E0=AE=B4=E0=AE=A9=E0=AF=8D =E0=AE=9C= =E0=AF=82=E0=AE=A9=E0=AF=8D 30, 2022] Visuwesh wrote: > The second patch actually adds the new phonetic input method. I will > leave the rationale for making it a _customisable_ input method in > footnote [1]. To reuse the existing code that calculates the various > tables for the tamil-itrans IM, I turned the code in defvars to defuns. > However, the definition of the almighty > quail-tamil-itrans-syllable-table is still huge since I needed to do a > whole lot to convert the indian-tml-base-table to a format that will > accepted by the new defun `quail-tamil-itrans-compute-syllable-table'. > [blah blah blah...] Here's a second revision of the second patch. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-Add-new-customizable-phonetic-Tamil-input-method.patch Content-Transfer-Encoding: quoted-printable >From 232e58dc10cce110870697c85721411822d6de64 Mon Sep 17 00:00:00 2001 From: Visuwesh Date: Thu, 30 Jun 2022 17:01:07 +0530 Subject: [PATCH] Add new customizable phonetic Tamil input method * lisp/leim/quail/indian.el (quail-tamil-itrans-compute-syllable-table): New function extracted from.. (quail-tamil-itrans-syllable-table): ... here. Use above function. (quail-tamil-itrans-compute-signs-table): Add new argument VARIOUS. (quail-tamil-itrans-various-signs-and-digits-table) (quail-tamil-itrans-various-signs-table): Adjust function call, and add TAMIL OM sign translation. (tamil): New phonetic Tamil input method. (tamil-vowel-translation, tamil-consonant-translation) (tamil-misc-translation, tamil-native-digits): New defcustoms to change the translation rules of the input method. (tamil-uyir-translation, tamil-mei-translation): Aliases to new defcustom for better discoverability. (tamil--syllable-table, tamil--signs-table, tamil--hashtables) (tamil--vowel-signs): Internal variables used by the Tamil input method. (tamil--make-tables): Function to produce vowels, consonants, and their translations. (tamil--update-quail-rules): Function to update the translation rules for the Tamil input method. * lisp/language/indian.el ("Tamil"): Change the default input method of the Tamil language environment to the phonetic input method. --- lisp/language/indian.el | 2 +- lisp/leim/quail/indian.el | 301 +++++++++++++++++++++++++++++--------- 2 files changed, 235 insertions(+), 68 deletions(-) diff --git a/lisp/language/indian.el b/lisp/language/indian.el index 2887d410ad..91ad818533 100644 --- a/lisp/language/indian.el +++ b/lisp/language/indian.el @@ -109,7 +109,7 @@ 'devanagari "Tamil" '((charset unicode) (coding-system utf-8) (coding-priority utf-8) - (input-method . "tamil-itrans") + (input-method . "tamil") (sample-text . "Tamil (=E0=AE=A4=E0=AE=AE=E0=AE=BF=E0=AE=B4=E0= =AF=8D) =E0=AE=B5=E0=AE=A3=E0=AE=95=E0=AF=8D=E0=AE=95=E0=AE=AE=E0=AF=8D") (documentation . "\ South Indian Language Tamil is supported in this language environment.")) diff --git a/lisp/leim/quail/indian.el b/lisp/leim/quail/indian.el index 8fffcc3511..d7d33fb68f 100644 --- a/lisp/leim/quail/indian.el +++ b/lisp/leim/quail/indian.el @@ -127,47 +127,19 @@ "\\''" indian-mlm-itrans-v5-hash "malayalam-itrans" "Malayalam" "MlmIT" "Malayalam transliteration by ITRANS method.") =20 -(defvar quail-tamil-itrans-syllable-table - (let ((vowels - '(("=E0=AE=85" nil "a") - ("=E0=AE=86" "=E0=AE=BE" "A") - ("=E0=AE=87" "=E0=AE=BF" "i") - ("=E0=AE=88" "=E0=AF=80" "I") - ("=E0=AE=89" "=E0=AF=81" "u") - ("=E0=AE=8A" "=E0=AF=82" "U") - ("=E0=AE=8E" "=E0=AF=86" "e") - ("=E0=AE=8F" "=E0=AF=87" "E") - ("=E0=AE=90" "=E0=AF=88" "ai") - ("=E0=AE=92" "=E0=AF=8A" "o") - ("=E0=AE=93" "=E0=AF=8B" "O") - ("=E0=AE=94" "=E0=AF=8C" "au"))) - (consonants - '(("=E0=AE=95" "k") ; U+0B95 - ("=E0=AE=99" "N^") ; U+0B99 - ("=E0=AE=9A" "ch") ; U+0B9A - ("=E0=AE=9E" "JN") ; U+0B9E - ("=E0=AE=9F" "T") ; U+0B9F - ("=E0=AE=A3" "N") ; U+0BA3 - ("=E0=AE=A4" "t") ; U+0BA4 - ("=E0=AE=A8" "n") ; U+0BA8 - ("=E0=AE=AA" "p") ; U+0BAA - ("=E0=AE=AE" "m") ; U+0BAE - ("=E0=AE=AF" "y") ; U+0BAF - ("=E0=AE=B0" "r") ; U+0BB0 - ("=E0=AE=B2" "l") ; U+0BB2 - ("=E0=AE=B5" "v") ; U+0BB5 - ("=E0=AE=B4" "z") ; U+0BB4 - ("=E0=AE=B3" "L") ; U+0BB3 - ("=E0=AE=B1" "rh") ; U+0BB1 - ("=E0=AE=A9" "nh") ; U+0BA9 - ("=E0=AE=9C" "j") ; U+0B9C - ("=E0=AE=B6" nil) ; U+0BB6 - ("=E0=AE=B7" "Sh") ; U+0BB7 - ("=E0=AE=B8" "s") ; U+0BB8 - ("=E0=AE=B9" "h") ; U+0BB9 - ("=E0=AE=95=E0=AF=8D=E0=AE=B7" "x" ) ; U+0B95 - )) - (virama #x0BCD) +;; FIXME: This only accepts a single translation for vowels. Ideally, +;; we want it to support mutliple translation just like consonants. +;; This also does not sort by vowel or consonant. :( +(defun quail-tamil-itrans-compute-syllable-table (vowels consonants) + "Return the syllable table for the input method as a string. +VOWELS is a list of (VOWEL SIGN TRANS) where VOWEL is a string or +character representing the Tamil vowel character, SIGN is the +vowel sign corresponding to VOWEL or nil for none, and TRANS is +the input sequence to insert VOWEL. +CONSONANTS is a list of (CONSONANT TRANS...) where CONSONANT is +the Tamil consonant character, and TRANS is one or more strings +that describe how to insert CONSONANT." + (let ((virama #x0BCD) clm) (with-temp-buffer (insert "\n") @@ -197,21 +169,42 @@ quail-tamil-itrans-syllable-table (insert (propertize "\t" 'display (list 'space :align-to clm)) (car c) (or (nth 1 v) "")) (setq clm (+ clm 6))) - (insert "\n" (or (nth 1 c) "") - (propertize "\t" 'display '(space :align-to 4)) - "|") - (setq clm 6) - - (dolist (v vowels) - (apply #'insert (propertize "\t" 'display (list 'space :align-to clm)) - (if (nth 1 c) (list (nth 1 c) (nth 2 v)) (list ""))) - (setq clm (+ clm 6)))) + (dolist (ct (cdr c)) + (insert "\n" (or ct "") + (propertize "\t" 'display '(space :align-to 4)) + "|") + (setq clm 6) + (dolist (v vowels) + (apply #'insert (propertize "\t" 'display (list 'space :align-to clm)) + (if ct (list ct (nth 2 v)) (list ""))) + (setq clm (+ clm 6))))) (insert "\n") (insert "----+") (insert-char ?- 74) (insert "\n") (buffer-string)))) =20 +(defvar quail-tamil-itrans-syllable-table + (quail-tamil-itrans-compute-syllable-table + (let ((vowels (car indian-tml-base-table)) + trans v ret) + (dotimes (i (length vowels)) + (when (setq v (nth i vowels)) + (setq trans (nth i (car indian-itrans-v5-table-for-tamil))) + (push (append v (list (if (listp trans) (car trans) trans))) + ret))) + (setq ret (nreverse ret)) + ret) + (let ((consonants (cadr indian-tml-base-table)) + trans c ret) + (dotimes (i (length consonants)) + (when (setq c (nth i consonants)) + (setq trans (nth i (cadr indian-itrans-v5-table-for-tamil))) + (push (cons c (if (listp trans) trans (list trans))) + ret))) + (setq ret (nreverse ret)) + ret))) + (defvar quail-tamil-itrans-numerics-and-symbols-table (let ((numerics '((?=E0=AF=B0 "=E0=AE=AA=E0=AE=A4=E0=AF=8D=E0=AE=A4=E0= =AF=81") (?=E0=AF=B1 "=E0=AE=A8=E0=AF=82=E0=AE=B1=E0=AF=81") (?=E0=AF=B2 "= =E0=AE=86=E0=AE=AF=E0=AE=BF=E0=AE=B0=E0=AE=AE=E0=AF=8D"))) (symbols '((?=E0=AF=B3 "=E0=AE=A8=E0=AE=BE=E0=AE=B3=E0=AF=8D") (?=E0=AF= =B4 "=E0=AE=AE=E0=AE=BE=E0=AE=A4=E0=AE=AE=E0=AF=8D") (?=E0=AF=B5 "=E0=AE=B5= =E0=AE=B0=E0=AF=81=E0=AE=9F=E0=AE=AE=E0=AF=8D") @@ -244,25 +237,28 @@ quail-tamil-itrans-numerics-and-symbols-table (insert "\n") (buffer-string)))) =20 -(defun quail-tamil-itrans-compute-signs-table (digitp) +(defun quail-tamil-itrans-compute-signs-table (digitp various) "Compute the signs table for the tamil-itrans input method. -If DIGITP is non-nil, include the digits translation as well." - (let ((various '((?=E0=AE=83 . "H") ("=E0=AE=B8=E0=AF=8D=E0=AE=B0=E0=AF= =80" . "srii") (?=E0=AF=90))) - (digits "=E0=AF=A6=E0=AF=A7=E0=AF=A8=E0=AF=A9=E0=AF=AA=E0=AF=AB=E0=AF=AC= =E0=AF=AD=E0=AF=AE=E0=AF=AF") +If DIGITP is non-nil, include the digits translation as well. +If VARIOUS is non-nil, then it should a list of (CHAR TRANS) +where CHAR is the character/string to translate and TRANS is +CHAR's translation." + (let ((digits "=E0=AF=A6=E0=AF=A7=E0=AF=A8=E0=AF=A9=E0=AF=AA=E0=AF=AB=E0= =AF=AC=E0=AF=AD=E0=AF=AE=E0=AF=AF") (width 6) clm) (with-temp-buffer - (insert "\n" (make-string 18 ?-) "+") - (when digitp (insert (make-string 60 ?-))) + (insert "\n" (make-string 18 ?-)) + (when digitp + (insert "+" (make-string 60 ?-))) (insert "\n") (insert (propertize "\t" 'display '(space :align-to 5)) "various" - (propertize "\t" 'display '(space :align-to 18)) "|") + (propertize "\t" 'display '(space :align-to 18))) (when digitp (insert - (propertize "\t" 'display '(space :align-to 45)) "digits")) - (insert "\n" (make-string 18 ?-) "+") + "|" (propertize "\t" 'display '(space :align-to 45)) "digits")) + (insert "\n" (make-string 18 ?-)) (when digitp - (insert (make-string 60 ?-))) + (insert "+" (make-string 60 ?-))) (insert "\n") (setq clm 0) =20 @@ -270,7 +266,8 @@ quail-tamil-itrans-compute-signs-table (insert (propertize "\t" 'display (list 'space :align-to clm)) (car (nth i various))) (setq clm (+ clm width))) - (insert (propertize "\t" 'display '(space :align-to 18)) "|") + (when digitp + (insert (propertize "\t" 'display '(space :align-to 18)) "|")) (setq clm 20) (when digitp (dotimes (i 10) @@ -281,25 +278,28 @@ quail-tamil-itrans-compute-signs-table (setq clm 0) (dotimes (i (length various)) (insert (propertize "\t" 'display (list 'space :align-to clm)) - (or (cdr (nth i various)) "")) + (or (cadr (nth i various)) "")) (setq clm (+ clm width))) - (insert (propertize "\t" 'display '(space :align-to 18)) "|") + (when digitp + (insert (propertize "\t" 'display '(space :align-to 18)) "|")) (setq clm 20) (when digitp (dotimes (i 10) (insert (propertize "\t" 'display (list 'space :align-to clm)) (format "%d" i)) (setq clm (+ clm width)))) - (insert "\n" (make-string 18 ?-) "+") + (insert "\n" (make-string 18 ?-)) (when digitp - (insert (make-string 60 ?-) "\n")) + (insert "+" (make-string 60 ?-) "\n")) (buffer-string)))) =20 (defvar quail-tamil-itrans-various-signs-and-digits-table - (quail-tamil-itrans-compute-signs-table t)) + (quail-tamil-itrans-compute-signs-table + t '((?=E0=AE=83 "H") ("=E0=AE=B8=E0=AF=8D=E0=AE=B0=E0=AF=80" "srii") (?= =E0=AF=90 "OM")))) =20 (defvar quail-tamil-itrans-various-signs-table - (quail-tamil-itrans-compute-signs-table nil)) + (quail-tamil-itrans-compute-signs-table + nil '((?=E0=AE=83 "H") ("=E0=AE=B8=E0=AF=8D=E0=AE=B0=E0=AF=80" "srii") = (?=E0=AF=90 "OM")))) =20 (if nil (quail-define-package "tamil-itrans" "Tamil" "TmlIT" t "Tamil ITRANS")) @@ -347,6 +347,173 @@ quail-tamil-itrans-various-signs-table =20 Full key sequences are listed below:") =20 +;;; +;;; Tamil phonetic input method +;;; + +(defvaralias 'tamil-uyir-translation 'tamil-vowel-translation) +(defcustom tamil-vowel-translation + '(("=E0=AE=85" "a") ("=E0=AE=86" "aa") ("=E0=AE=87" "i") ("=E0=AE=88" "i= i") + ("=E0=AE=89" "u") ("=E0=AE=8A" "uu") ("=E0=AE=8E" "e") ("=E0=AE=8F" "e= e") + ("=E0=AE=90" "ai") ("=E0=AE=92" "o") ("=E0=AE=93" "oo") ("=E0=AE=94" "= au" "ow")) + "List of input sequences to translate to Tamil vowels. +Each element should be (VOWEL . TRANSLATIONS) where VOWEL is the +Tamil vowel character (=E0=AE=89=E0=AE=AF=E0=AE=BF=E0=AE=B0=E0=AF=86=E0=AE= =B4=E0=AF=81=E0=AE=A4=E0=AF=8D=E0=AE=A4=E0=AF=81) and TRANSLATIONS is the +list of input sequences to translate to that vowel." + :group 'leim + :version "29.1" + :type '(alist :key string :value-type (repeat string)) + :options (delq nil + (mapcar (lambda (x) (and (consp x) (string (car x)))) + (car indian-tml-base-table)))) + +(defvaralias 'tamil-mei-translation 'tamil-consonant-translation) +(defcustom tamil-consonant-translation + '(("=E0=AE=95=E0=AF=8D" "k" "g") ("=E0=AE=99=E0=AF=8D" "ng") ("=E0=AE=9A= =E0=AF=8D" "ch" "s") ("=E0=AE=9E=E0=AF=8D" "nj") ("=E0=AE=9F=E0=AF=8D" "t" = "d") + ("=E0=AE=A3=E0=AF=8D" "N") ("=E0=AE=A4=E0=AF=8D" "th" "dh") ("=E0=AE= =A8=E0=AF=8D" "nh") ("=E0=AE=AA=E0=AF=8D" "p" "b") ("=E0=AE=AE=E0=AF=8D" "m= ") + ("=E0=AE=AF=E0=AF=8D" "y") ("=E0=AE=B0=E0=AF=8D" "r") ("=E0=AE=B2=E0= =AF=8D" "l") ("=E0=AE=B5=E0=AF=8D" "v") ("=E0=AE=B4=E0=AF=8D" "z" "zh") + ("=E0=AE=B3=E0=AF=8D" "L") ("=E0=AE=B1=E0=AF=8D" "rh") ("=E0=AE=A9=E0= =AF=8D" "n") + ;; Sanskrit. + ("=E0=AE=9C=E0=AF=8D" "j") ("=E0=AE=B8=E0=AF=8D" "S") ("=E0=AE=95=E0= =AF=8D=E0=AE=B7=E0=AF=8D" "ksH") ("=E0=AE=B7=E0=AF=8D" "sh") ("=E0=AE=B9=E0= =AF=8D" "h") + ("=E0=AE=95=E0=AF=8D=E2=80=8C=E0=AE=B7=E0=AF=8D" "ksh") ("=E0=AE=B6=E0= =AF=8D" "Z")) + "List of input sequences to translate to Tamil consonants. +Each element should be (VOWEL . TRANSLATIONS) where VOWEL is the +Tamil consonant character (=E0=AE=AE=E0=AF=86=E0=AE=AF=E0=AF=8D =E0=AE=8E= =E0=AE=B4=E0=AF=81=E0=AE=A4=E0=AF=8D=E0=AE=A4=E0=AF=81) and TRANSLATIONS is= a list +of input sequences to translate to that consonant." + :group 'leim + :version "29.1" + :type '(alist :key string :value-type (repeat string)) + :options (delq nil + (mapcar (lambda (x) (if (stringp x) + (concat x "=E0=AF=8D") + ;; #x0BCD =3D pulli/virama. + (and x (string x #x0BCD)))) + (cadr indian-tml-base-table)))) + +(defcustom tamil-misc-translation + ;; =E0=AE=83 is not a vowel or a consonant. + '(("=E0=AE=83" "F" "q") + ("=E0=AF=90" "OM")) + "List of input sequences to translate to various Tamil characters. +Each should element should be (CHARACTER . TRANSLATIONS) where +CHARACTER may be any string and TRANSLATIONS is a list of input +sequences to translate to that CHARACTER." + :group 'leim + :version "29.1" + :type '(alist :key string :value-type (repeat string))) + +(defcustom tamil-native-digits nil + "When non-nil, use Tamil native digits instead of Arabic ones." + :group 'leim + :version "29.1" + :type 'boolean) + +(defvar tamil--syllable-table nil) +(defvar tamil--signs-table nil) +(defvar tamil--hashtables + (cons (make-hash-table :test #'equal) + (make-hash-table :test #'equal))) +(defvar tamil--vowel-signs + '(("=E0=AE=85" . nil) ("=E0=AE=86" . ?=E0=AE=BE) ("=E0=AE=87" . ?=E0=AE= =BF) ("=E0=AE=88" . ?=E0=AF=80) + ("=E0=AE=89" . ?=E0=AF=81) ("=E0=AE=8A" . ?=E0=AF=82) ("=E0=AE=8E" . ?= =E0=AF=86) ("=E0=AE=8F" . ?=E0=AF=87) + ("=E0=AE=90" . ?=E0=AF=88) ("=E0=AE=92" . ?=E0=AF=8A) ("=E0=AE=93" . ?= =E0=AF=8B) ("=E0=AE=94" . ?=E0=AF=8C))) + +(defun tamil--make-tables () + "Return vowels, consonants, and their translation rules. +The returned table is a list (VOWELS CONSONANTS VTRANS CTRANS) +where VOWELS is a list of (VOWEL VOWEL-SIGN) where VOWEL is the +Tamil vowel character, and VOWEL-SIGN is its sign, CONSONANTS is +a list of consonants that have translation rules. +VTRANS is a list of translation rules for vowels in VOWELS in the +order they appear, CTRANS is a list of translation rules for +consonants in CONSONANTS." + (let (c-table v-table v-trans c-trans) + (dolist (v tamil-vowel-translation) + (push (list (car v) (assoc-default (car v) tamil--vowel-signs)) v-ta= ble) + (push (cdr v) v-trans)) + (dolist (c tamil-consonant-translation) + (push (cdr c) c-trans) + ;; Remove pulli/virama from consonant entry. + (push (substring (car c) 0 -1) c-table)) + ;; FIXME: Remove when sorting is done properly! + (setq c-table (nreverse c-table) + v-table (nreverse v-table) + c-trans (nreverse c-trans) + v-trans (nreverse v-trans)) + (list v-table c-table + v-trans c-trans))) + +(defun tamil--update-quail-rules () + ;; This function does pretty much what `indian-make-hash' does + ;; except that we don't try to copy the structure of + ;; `indian-tml-base-table' which leads to less code hassle. + (let* ((tables (tamil--make-tables)) + (vowels (nth 0 tables)) + (vowels-trans (nth 2 tables)) + (consonants (nth 1 tables)) + (consonants-trans (nth 3 tables)) + (pulli (string #x0BCD))) + (clrhash (car tamil--hashtables)) + (clrhash (cdr tamil--hashtables)) + (indian--puthash-v vowels vowels-trans tamil--hashtables) + (indian--puthash-c consonants consonants-trans pulli tamil--hashtables) + (indian--puthash-cv consonants consonants-trans + vowels vowels-trans tamil--hashtables) + (indian--puthash-m (mapcar #'car tamil-misc-translation) + (mapcar #'cdr tamil-misc-translation) + tamil--hashtables) + (when tamil-native-digits + (indian--puthash-m (nth 3 indian-tml-base-digits-table) + '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9") + tamil--hashtables)) + ;; Now override the current translation rules. + ;; Empty quail map is '(list nil)'. + (setf (nth 2 quail-current-package) '(())) + (maphash (lambda (k v) + (quail-defrule k (if (length=3D v 1) + (string-to-char v) + (vector v)))) + (cdr tamil--hashtables)) + (setq tamil--syllable-table + (quail-tamil-itrans-compute-syllable-table + (mapcar (lambda (v) (append v (pop vowels-trans))) vowels) + (mapcar (lambda (c) (cons c (pop consonants-trans))) consonant= s)) + tamil--signs-table + ;; FIXME: This should also show how to input =E0=AE=B8=E0=AF=8D= =E0=AE=B0=E0=AF=80 (default: Srii). + (quail-tamil-itrans-compute-signs-table + tamil-native-digits tamil-misc-translation)))) + +(quail-define-package + "tamil" "Tamil" "=E0=AE=B4" t + "Customisable Tamil phonetic input method. +To change the translation of vowels (=E0=AE=89=E0=AE=AF=E0=AE=BF=E0=AE=B0= =E0=AF=86=E0=AE=A4=E0=AF=8D=E0=AE=A4=E0=AF=81=E0=AE=95=E0=AF=8D=E0=AE=95=E0= =AE=B3=E0=AF=8D), customize `tamil-vowel-translation'. +To change the translation of consonants (=E0=AE=AE=E0=AF=86=E0=AE=AF=E0=AF= =8D =E0=AE=8E=E0=AE=B4=E0=AF=81=E0=AE=A4=E0=AF=8D=E0=AE=A4=E0=AF=81=E0=AE= =95=E0=AF=8D=E0=AE=95=E0=AE=B3=E0=AF=8D), customize + `tamil-consonant-translation'. +To input miscellaneous characters (including =E0=AE=83), customize + `tamil-misc-translation'. +To use native Tamil digits, customize `tamil-native-digits'. + +To end the current translation process, say \\\\= [quail-select-current] (defined in +`quail-translation-keymap'). This is useful when there's a + conflict between two possible translation. + +The current input scheme is: + +### Basic syllables (=E0=AE=89=E0=AE=AF=E0=AE=BF=E0=AE=B0=E0=AF=8D=E0=AE= =AE=E0=AF=86=E0=AE=AF=E0=AF=8D =E0=AE=8E=E0=AE=B4=E0=AF=81=E0=AE=A4=E0=AF= =8D=E0=AE=A4=E0=AF=81=E0=AE=95=E0=AF=8D=E0=AE=95=E0=AE=B3=E0=AF=8D) ### +\\=3D\\ + +### Miscellaneous #### +\\=3D\\ + +The following characters have NO input sequence associated with +them by default. Their descriptions are included for easy +reference. +\\=3D\\ + +Full key sequences are listed below:" + nil nil nil nil nil nil t) +(tamil--update-quail-rules) + ;;; ;;; Input by Inscript ;;; --=20 2.35.1 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I still haven't added a :set function yet since I'm not sure if there's a way to avoid the chain of boundp checks. In this revision, I simplified the code a tiny bit wrt calculating the translation table since I no longer use the indian-make-hash function but call whatever functions it call directly in tamil--update-quail-rules: this greatly reduces the amount of massaging that needs to be done. Also, can someone guide me to write a sort function for quail-tamil-itrans-compute-syllable-table please? The ideal order of consonants should be the same as the one in the default value of tamil-consonant-translation, same for tamil-vowel-translation. I tried the following (sort (reverse (mapcar #'car tamil-consonant-translation)) (lambda (x y) (let ((lx (length x)) (ly (length y))) (if (=3D lx ly) (string-lessp x y) (< lx ly))))) but that definitely doesn't do what I want. The idea was to sort the list so that the basic consonants (=E0=AE=95=E0=AF=8D =E0=AE=99=E0=AF=8D = =E0=AE=9A=E0=AF=8D etc.) first then the composite ones (=E0=AE=95=E0=AF=8D=E2=80=8C=E0=AE=B7=E0=AF=8D =E0=AE=95=E0=AF=8D=E0= =AE=B7=E0=AF=8D etc.) but `string-lessp' does not even sort the basic consonants in the right order (the right order being the order in the default value of `tamil-consonant-translation'). Can I use the min-width property in buffer text? I'm not sure if it was finished since I remember some discussion surrounding that it wasn't quite finished yet. I would like to try to use it for syllable table and friends. --=-=-=--