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