* lisp/textmodes/tex-mode.el (tex-font-lock-keywords-1): Highlight not only
[emacs.git] / leim / quail / persian.el
blob70e2d38032922d113883b4b7737a08931cb2c919
1 ;;; persian.el --- Quail package for inputting Persian/Farsi keyboard -*- coding: utf-8;-*-
3 ;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
5 ;; Author: Mohsen BANAN <libre@mohsen.1.banan.byname.net>
6 ;; http://mohsen.1.banan.byname.net/contact
8 ;; Keywords: multilingual, input method, Farsi, Persian, keyboard
10 ;; 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.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; This is a Halaal Poly-Existential intended to remain perpetually Halaal.
27 ;;; Commentary:
29 ;; This file contains a collection of input methods for
30 ;; Persian languages (Farsi, Urdu, Pashto/Afghanic, ...)
32 ;; At this time, the following input methods are specified:
34 ;; - (farsi-isiri-9149) Persian Keyboard based on Islamic Republic of Iran's ISIR-9147
35 ;; - (farsi-transliterate-banan) An intuitive transliteration keyboard for Farsi
37 ;; Additional documentation for these input methods can be found at:
38 ;; http://www.persoarabic.org/PLPC/120036
41 ;;; Code:
43 (require 'quail)
46 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48 ;; farsi-isiri-9147
50 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52 ;; The keyboard mapping defined here is based on:
54 ;; Institute of Standards and Industrial Research of Iran
55 ;; Information Technology – Layout of Persian Letters and Symbols
56 ;; on Computer Keyboards
57 ;; ISIRI 9147 -- 1st edition
58 ;; http://www.isiri.org/UserStd/DownloadStd.aspx?id=9147
60 ;; The specification is also republished at
61 ;; http://www.farsiweb.ir/wiki/Image:Isiri-9147.pdf
62 ;; and various other sites.
64 ;; ISIRI-6219 is also relevant.
66 ;; Layers 1, 2 and 3 of ISIRI-9147 are fully implemented with the
67 ;; exception of the Backslash, Alt-Backslash, Shift-Space and
68 ;; Alt-Space keys.
70 ;; The Backslash key is used to replace کلید با دگر ساز راست‌ -- the Alt or
71 ;; Meta key.
73 ;; Layer 3 is then entered with the Backslash key and Layer 3 is
74 ;; implemented as two letter keys as specified in ISIRI-9147.
76 ;; The character corresponding to Backslash is entered with Backslash-Backslash.
77 ;; Alt-Backslash has been moved to Backslash-r.
78 ;; Alt-Space has been moved to Backslash-t.
79 ;; Shift-Space has been moved to Backslash-y.
81 ;; With these modifications, farsi-isiri-9147 is a full implementation
82 ;; of ISIRI-9147. Additionally, these modifications allow for this
83 ;; implementation to be ascii input stream based -- in addition to
84 ;; being a keyboard layout.
86 ;; If a key on Layer 1 was reserved to replace دگر ساز راست‌ (the Alt
87 ;; or Meta key), then farsi-isiri-9147 could have claimed full
88 ;; compliance -- without the need for the above description. Perhaps
89 ;; this can be considered a flaw in the base ISIRI-9147 specification
90 ;; to be addressed in the next revision.
94 (quail-define-package
95 "farsi-isiri-9147" "Farsi" " ف" nil "Farsi input method.
97 Based on ISIRI-9147 Layout of Persian Letters and Symbols on Computer Keyboards.
98 " nil t t t t nil nil nil nil nil t)
100 ;; Note: the rows of keys below are enclosed in Left-To-Right Override
101 ;; embedding, to prevent them from being reordered by the Emacs
102 ;; display engine.
105 ;; +----------------------------------------------------------------+
106 ;; ‭| ۱! | ۲٬ | ۳٫ | ۴﷼ | ۵٪ | ۶× | ۷، | ۸* | ۹( | ۰) | -ـ | =+ | `÷ |‬
107 ;; +----------------------------------------------------------------+
108 ;; ‭| ضْ| صٌ| ثٍ| قً| فُ| غِ| عَ| هّ| خ] | ح[ | ج{ | چ} |‬
109 ;; +------------------------------------------------------------+
110 ;; ‭| ش‌ؤ | س‌ئ | ی‌ي | ب‌إ | لأ | اآ | ت‌ة | ن« | م» | ک: | گ؛ | \| |‬
111 ;; +-----------------------------------------------------------+
112 ;; ‭| ظ‌ك | طٓ| زژ | رٰ| ذB | دٔ| پء | و< | .> | /؟ |‬
113 ;; +-------------------------------------------+
115 (quail-define-rules
116 ("1")
117 ("2")
118 ("3")
119 ("4")
120 ("5")
121 ("6")
122 ("7")
123 ("8")
124 ("9")
125 ("0")
126 ("-" ?-)
127 ("=" ?=)
128 ("`" ?\u200D) ;; ZWJ -- ZERO WIDTH JOINER اتصال مجازى
129 ("q")
130 ("w")
131 ("e")
132 ("r")
133 ("t")
134 ("y")
135 ("u")
136 ("i")
137 ("o")
138 ("p")
139 ("[")
140 ("]")
141 ("a")
142 ("s")
143 ("d")
144 ("f")
145 ("g")
146 ("h")
147 ("j")
148 ("k")
149 ("l")
150 (";")
151 ("'")
153 ("z")
154 ("x")
155 ("c")
156 ("v")
157 ("b")
158 ("n")
159 ("m")
160 (",")
161 ("." ?.)
162 ("/" ?/)
164 ("!" ?!)
165 ("@")
166 ("#")
167 ("$" ?﷼)
168 ("%")
169 ("^")
170 ("&")
171 ("*" ?*)
172 ("(" ?\))
173 (")" ?\()
174 ("_")
175 ("+" ?+)
176 ("~")
177 ("Q") ;; ساکن فارسى
178 ("W") ;; دو پيش فارسى -- تنوين رفع
179 ("E") ;; دو زير فارسى -- تنوين جر
180 ("R") ;; دو زبر فارسى -- تنوين نصب
181 ("T") ;; پيش فارسى -- ضمه
182 ("Y") ;; زير فارسى -- کسره
183 ("U") ;; زبر فارسى -- فتحه
184 ("I") ;; تشديد فارسى
185 ("O" ?\])
186 ("P" ?\[)
187 ("{" ?})
188 ("}" ?{)
189 ("A")
190 ("S")
191 ("D")
192 ("F")
193 ("G")
194 ("H")
195 ("J")
196 ("K")
197 ("L")
198 (":" ?:)
199 ("\"")
200 ("|" ?|)
201 ("Z")
202 ("X")
203 ("C")
204 ("V")
205 ("B" ?\u200C) ;; ZWNJ -- ZERO WIDTH NON-JOINER فاصلهٔ مجازى
206 ("N") ;; همزه فارسى بالا
207 ("M") ;; harf farsi hamzeh
208 ("<" ?>)
209 (">" ?<)
210 ("?")
212 ;; Level 3 Entered with \
214 ("\\" ?\\) ;; خط اريب وارو
215 ("\\\\" ?\\)
216 ("\\~" ?\u007E)
217 ("\\1" ?\u0060)
218 ("\\2" ?\u0040)
219 ("\\3" ?\u0023)
220 ("\\4" ?\u0024)
221 ("\\5" ?\u0025)
222 ("\\6" ?\u005E)
223 ("\\7" ?\u0026)
224 ("\\8" ?\u2022)
225 ("\\9" ?\u200E)
226 ("\\0" ?\u200F)
227 ("\\-" ?\u005F)
228 ("\\+" ?\u2212)
229 ("\\q" ?\u00B0)
230 ;;\\w" ?\u0000)
231 ("\\e" ?\u20AC)
232 ("\\r" ?\u2010) ;; replacement for Alt-BSL
233 ("\\t" ?\u00A0) ;; replacement for ALT-SPC
234 ("\\y" ?\u200C) ;; replacement for SHIFT-SPC
235 ;;("\\u" ?\u0000)
236 ("\\i" ?\u202D)
237 ("\\o" ?\u202E)
238 ("\\p" ?\u202C)
239 ("\\[" ?\u202A)
240 ("\\]" ?\u202B)
241 ;;("\\a" ?\u0000)
242 ;;("\\s" ?\u0000)
243 ("\\d" ?\u0649)
244 ;;("\\f" ?\u0000)
245 ;;("\\g" ?\u0000)
246 ("\\h" ?\u0671)
247 ;;("\\j" ?\u0000)
248 ("\\k" ?\uFD3E)
249 ("\\l" ?\uFD3F)
250 ("\\;" ?\u003B)
251 ("\\'" ?\u0022)
252 ;;("\\z" ?\u0000)
253 ;;("\\x" ?\u0000)
254 ;;("\\c" ?\u0000)
255 ("\\v" ?\u0656)
256 ("\\b" ?\u200D)
257 ("\\n" ?\u0655)
258 ("\\m" ?\u2026)
259 ("\\," ?\u002C)
260 ("\\." ?\u0027)
261 ("\\?" ?\u003F)
262 ;;("\\\\" ?\u2010) ;; Moved to backslash r to leave room for BSL-BSL
266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
268 ;; farsi-transliterate-banan
270 ;; Given a Qwerty keyboard, use Persian-to-Latin transliteration knowledge
271 ;; to reverse transliterate in persian
273 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
275 ;;; See http://www.persoarabic.org/PLPC/120036 document for more complete
276 ;;; documentation of keyboard bindings and usage instructions.
279 ;; ISIRI-9147 Persian keyboard is generally not well suited for Iranian-Expatriates
280 ;; working/living in the West.
282 ;; The qwerty keyboard is usually second nature to Persian speaking expatriates and they
283 ;; don't want to learn/adapt to ISIRI-9147. They expect software to adapt to them.
285 ;; That is what the ``Banan Multi-Character (Reverse) Transliteration Persian Input Method'' does.
287 ;; The typical profile of the user is assumed to be one who:
289 ;; - can write in farsi (not just speak it).
290 ;; - is fully comfortable with a qwerty latin keyboard.
291 ;; - is not familiar with isir-9147 and does not wish to be trained.
292 ;; - communicates and writes in a mixed globish/persian -- not pure persian.
293 ;; - is intuitively familiar with transliteration of farsi/persian into latin based on two letter
294 ;; phonetic mapping to persian characters (e.g., gh ق -- kh خ -- sh ش -- ch چ -- zh ژ.
296 ;; This transliteration keyboard is designed to be intuitive such that
297 ;; mapping are easy and natural to remember for a persian writer.
298 ;; It is designed to be equivalent in capability to farsi-isiri-9147
299 ;; and provide for inputting all characters enumerated in ISIRI-6219.
301 ;; farsi-transliterate-banan is of course phonetic oriented. But it is very different from
302 ;; pinglish. Pinglish is word oriented where you sound out the word with latin letters --
303 ;; including the vowels. farsi-transliterate-banan is letter oriented where you enter the
304 ;; latin letter/letters closest to the persian letter. And usually omit vowels.
306 ;; For some persian characters there are multiple ways of inputting
307 ;; the same character. For example both ``i'' and ``y'' produce ی.
308 ;; For یک ``yk'', ``y'' is more natural and for این ``ain'', ``i'' is more natural.
310 ;; The more frequently used keys are mapped to lower case. The less frequently used letter moves to
311 ;; upper case. For example: ``s'' is س and ``S'' is ص. ``h'' is ح and ``H''
312 ;; is ه.
314 ;; Multi-character input is based on \, &, and / prefix
315 ;; characters. The letter 'h' is used as a postfix for the following two character mappings:
316 ;; gh ق -- kh خ -- sh ش -- ch چ -- zh ژ -- Th ة -- Yh ى.
319 ;; Prefix letter \ is used for two character inputs when an alternate form of a letter
320 ;; is desired for example \% is: ‌÷ when % is: ٪.
322 ;; Prefix letter & is used for multi-character inputs when special characters are
323 ;; desired based on their abbreviate name. For example you can enter &lrm; to enter the
324 ;; ``LEFT-TO-RIGHT MARK'' character.
326 ;; Prefix letter / is used to provide two characters. / is: ``ZERO WIDTH NON-JOINER''
327 ;; and // is /.
329 ;; The letter 'h' is used in a number of two character postfix mappings,
330 ;; for example ``sh'' ش. So if you need the sequence of ``s'' and ``h'' you
331 ;; need to repeat the ``s''. For example: سحر = 's' 's' 'h' 'r'.
335 (quail-define-package
336 "farsi-transliterate-banan" "Farsi" "ب" t
337 "Intuitive transliteration keyboard layout for persian/farsi.
338 " nil t t t t nil nil nil nil nil t)
341 (quail-define-rules
342 ;;;;;;;;;;; isiri-6219 Table 5 -- جدول ۵ - حروِفِ اصلیِ فارسی
343 ("W") ;; hamzeh
344 ("A") ;; U+0622 & ARABIC LETTER ALEF WITH MADDA ABOVE & الف با کلاه
345 ("a") ;; U+0627 & ARABIC LETTER ALEF & الف
346 ("\\a")
347 ("b") ;; U+0628 & ARABIC LETTER BEH &
348 ("p") ;; U+067e & ARABIC LETTER PEH &
349 ("t")
350 ("tt")
351 ("c")
352 ("cc")
353 ("j")
354 ("ch")
355 ("h")
356 ("kh")
357 ("d")
358 ("Z")
359 ("r")
360 ("z")
361 ("zz")
362 ("zh")
363 ("s")
364 ("ss")
365 ("sh")
366 ("S")
367 ("x")
368 ("T")
369 ("TT")
370 ("X")
371 ("w")
372 ("q")
373 ("f")
374 ("Q")
375 ("gh")
376 ("k")
377 ("kk")
378 ("g")
379 ("gg")
380 ("l")
381 ("m")
382 ("n")
383 ("v")
384 ("u")
385 ("V")
386 ("H")
387 ("y")
388 ("i")
389 ("I")
392 ;;;;;;;;;;; isiri-6219 Table 6 -- جدول ۶ - حروِفِ عربی
393 ("F")
394 ("D" ?\u0671) ;; (ucs-insert #x0671)ٱ named: حرفِ الفِ وصل
395 ("K") ;; Arabic kaf
396 ("Th") ;; ta marbuteh
397 ("Y")
398 ("YY")
399 ("Yh")
401 ;;;;;;;;;;; isiri-6219 Table 4 -- جدول ۴ - ارقام و علائم ریاضی
402 ("0")
403 ("1")
404 ("2")
405 ("3")
406 ("4")
407 ("5")
408 ("6")
409 ("7")
410 ("8")
411 ("9")
413 ("\\/" ?\u066B) ;; (ucs-insert #x066B)٫ named: ممیزِ فارسی
414 ("\\," ?\u066C) ;; (ucs-insert #x066C)٬ named: جداکننده‌ی هزارهای فارسی
415 ("%" ?\u066A) ;; (ucs-insert #x066A)٪ named: درصدِ فارسی
416 ("+" ?\u002B) ;; (ucs-insert #x002B)+ named: علامتِ به‌اضافه
417 ("-" ?\u2212) ;; (ucs-insert #x2212)− named: علامتِ منها
418 ("\\*" ?\u00D7) ;; (ucs-insert #x00D7)× named: علامتِ ضرب
419 ("\\%" ?\u007F) ;; (ucs-insert #x00F7)÷ named: علامتِ تقسیم
420 ("<" ?\u003C) ;; (ucs-insert #x003C)< named: علامتِ کوچکتر
421 ("=" ?\u003D) ;; (ucs-insert #x003D)= named: علامتِ مساوی
422 (">" ?\u003E) ;; (ucs-insert #x003E)> named: علامتِ بزرگتر
425 ;;;;;;;;;;; isiri-6219 Table 2 -- جدول ۲ - علائم نقطه گذاریِ مشترک
426 ;;; Space
427 ("." ?.) ;;
428 (":" ?\u003A) ;; (ucs-insert #x003A): named:
429 ("!" ?\u0021) ;; (ucs-insert #x0021)! named:
430 ("\\." ?\u2026) ;; (ucs-insert #x2026)… named:
431 ("\\-" ?\u2010) ;; (ucs-insert #x2010)‐ named:
432 ("-" ?\u002D) ;; (ucs-insert #x002D)- named:
433 ("|" ?|)
434 ;;("\\\\" ?\)
435 ("//" ?/)
436 ("*" ?\u002A) ;; (ucs-insert #x002A)* named:
437 ("(" ?\u0028) ;; (ucs-insert #x0028)( named:
438 (")" ?\u0029) ;; (ucs-insert #x0029)) named:
439 ("[" ?\u005B) ;; (ucs-insert #x005B)[ named:
440 ("[" ?\u005D) ;; (ucs-insert #x005D)] named:
441 ("{" ?\u007B) ;; (ucs-insert #x007B){ named:
442 ("}" ?\u007D) ;; (ucs-insert #x007D)} named:
443 ("\\<" ?\u00AB) ;; (ucs-insert #x00AB)« named:
444 ("\\>" ?\u00BB) ;; (ucs-insert #x00BB)» named:
447 ;;;;;;;;;;; isiri-6219 Table 3 -- جدول ۳ - علائم نقطه گذاریِ فارسی
448 (",") ;; farsi
449 (";") ;;
450 ("?") ;; alamat soal
451 ("_") ;;
454 ;;;;;;;;;;; isiri-6219 Table 1 -- جدول ۱ - نویسه‌های کنترلی
455 ;; LF
456 ;; CR
457 ("&zwnj;" ?\u200C) ;; (ucs-insert #x200C)‌ named: فاصله‌ی مجازی
458 ("/" ?\u200C) ;;
459 ("&zwj;" ?\u200D) ;; (ucs-insert #x200D)‍ named: اتصالِ مجازی
460 ("J" ?\u200D) ;;
461 ("&lrm;" ?\u200E) ;; (ucs-insert #x200E)‎ named: نشانه‌ی چپ‌به‌راست
462 ("&rlm;" ?\u200F) ;; (ucs-insert #x200F)‏ named: نشانه‌ی راست‌به‌چپ
463 ("&ls;" ?\u2028) ;; (ucs-insert #x2028)
 named: جداکننده‌ی سطرها
464 ("&ps;" ?\u2028) ;; (ucs-insert #x2029)
 named: جداکننده‌ی بندها
465 ("&lre;" ?\u202A) ;; (ucs-insert #x202A)‪ named: زیرمتنِ چپ‌به‌راست
466 ("&rle;" ?\u202B) ;; (ucs-insert #x202B) named: زیرمتنِ راست‌به‌چپ
467 ("&pdf;" ?\u202C) ;; (ucs-insert #x202C) named: پایانِ زیرمتن
468 ("&lro;" ?\u202D) ;; (ucs-insert #x202D) named: زیرمتنِ اکیداً چپ‌به‌راست
469 ("&rlo;" ?\u202D) ;; (ucs-insert #x202E) named: زیرمتنِ اکیداً راست‌به‌چپ
470 ("&bom;" ?\uFEFF) ;; (ucs-insert #xFEFF) named: نشانه‌ی ترتیبِ بایت‌ها
473 ;;;;;;;;;;; isiri-6219 Table 7 -- جدول ۷ - نشانه‌هایِ فارسی
474 ("^") ;; zbar ;; زبر فارسى
475 ("e") ;; zir زير فارسى
476 ("o") ;; peesh ;; پيش فارسى -- ضمه
477 ("E") ;; eizan ;; دو زير فارسى -- تنوين جر
478 ("#") ;; دو زبر
479 ("O") ;; دو پيش فارسى -- تنوين رفع
480 ("~") ;; tashdid ;; تشديد فارسى
481 ("@") ;; ساکن فارسى
482 ("U" ?\u0653) ;; (ucs-insert #x0653)ٓ named: مدِ فارسی
483 ("`") ;; همزه فارسى بالا
484 ("C" ?\u0655) ;; (ucs-insert #x0655)ٕ named: همزه فارسى پایین
485 ("$" ?\u0670) ;; (ucs-insert #x0670)ٰ named: الفِ مقصوره‌ی فارسی
488 ;;;;;;;;;;; isiri-6219 Table 8 - Forbidden Characters -- جدول ۸ - نویسه‌هایِ ممنوع
489 ;; ;; he ye (ucs-insert 1728) kills emacs-24.0.90
490 ;; arabic digits 0-9
493 ;;;;;;; Latin Extensions
494 ("\\" ?\\) ;; خط اريب وارو
495 ("\\\\" ?\\)
496 ("\\~" ?~)
497 ("\\@" ?@)
498 ("\\#" ?#)
499 ("\\$" ?\uFDFC) ;; (ucs-insert #xFDFC)﷼ named:
500 ("\\^" ?^)
501 ("\\1" ?1)
502 ("\\2" ?2)
503 ("\\3" ?3)
504 ("\\4" ?4)
505 ("\\5" ?5)
506 ("\\6" ?6)
507 ("\\7" ?7)
508 ("\\8" ?8)
509 ("\\9" ?9)
510 ("\\0" ?0)
514 ;;; persian.el ends here