9

TL;DR: how can I use Hindi digits (١٢٣...) when writing in Arabic?


Emacs is arguably hailed as the best editor, but when it comes to using numerals in the context of writing there are no satisfactory solutions to this problem for multilingual users compared to that afforded by Microsoft Word, namely the contextual numeral writing.

In Microsoft Word 2010 go to drop down menu --> More Commands --> Advanced --> under show document content you can select context for Numeral out of (Arabic or Hindi or Context or System). The context option allows you write numerals according to the context of your writing if it were English numerals would be Arabic 1,2,3,4,5,6,7,8,9,0 -- sounds strange! but it is so named (a misnomer maybe), and if you write in Arabic then numerals will be Hindi numerals, written like this:
enter image description here

For Windows, I found that changing the input-method while writing is the way to go if I am to write a multilingual document in Emacs say English and Arabic or any other language with a totally different alphabet. Changing language or keyboard layout from the language bar in Windows IMHO won't give you the same effect since that will destroy all of your key bindings of your Emacs editor (especially in case of two different languages like English and Arabic). The solution is posted here.

In Microsoft Word, after setting numerals to context you can seamlessly write English with Arabic numerals, and when you shift to write in Arabic by cycling through (ALT+R SHFT) you will write Arabic text with Hindi numerals in no time as shown in the image below. In Emacs after shifting the input-method to Arabic language, numerals will still be Arabic (1,2,3,etc) and not the desired Hindi numerals.

enter image description here

I don't think solution to this problems is related to Microsoft Windows as changing the language of regional settings will change the numerals of the Windows interface as well and will be system-wide undesired effect.

I do believe that the extension potential of Emacs holds the key to this problem. To be more specific; I suggest Emacs should detect the input-method and if it is in Arabic it should automatically remap all Arabic digits into Hindi ones. OR somehow customizing the Arabic keyboard layout to have Hindi instead of Arabic numerals.

Listed blow are some related posts to this problem but I couldn't translate these bits of info into an actual solution suitable to the specifics of this post:

https://tex.stackexchange.com/q/191040/26295

Below is an approach to extend the input-method in Emacs. https://emacs.stackexchange.com/a/3404/2443

Typing Hindi numerals can be a tedious task in Emacs if you want to enter the Hindi digits one at a time C-x 8 RET these are mapped in Unicode to the following codes: 0661 for number 1, 0662 for number 2, 0663 for number 3, 0664 for number 4, 0665 for number 5 and so on.

Question
What is the best customization to Emacs 24 and shortest keystrokes in order to replicate the seamless contextual writing experience provided by Microsoft Word?

  • I think there is some confusion here, the numbers you are calling hindi are actually arabic numerals! – Iqbal Ansari Dec 23 '14 at 9:56
  • @IqbalAnsari Hi, ironically not -- I know it might seem confusing for the first time but if you were a Microsoft Word user and you write in Arabic you will soon be accustomed to this jargon. If you have Microsoft Word you can check it out. – doctorate Dec 23 '14 at 10:00
  • 1
    As an aside: publication-norms in some Arabic-speaking countries default to Hindi numerals (١٢٣...), such as Egypt, while others default to Arabic numerals (123...), such as Lebanon. – Dan Dec 23 '14 at 11:07
  • @Dan, Egypt and Lebanon are both Arabic speaking countries they should use Hindi in their publications or any other writings. Based on that, Emacs' default Arabic layout would be better off changing numerals from Arabic into Hindi. – doctorate Dec 23 '14 at 12:10
  • What they should or should not do is not as relevant as what they actually do. And, for what it's worth, the major online publications mostly use Arabic numerals -- cf. al-Jazeera, al-Hayat (pan-Arab daily), al-Nahar (flagship Lebanese daily), al-Ahram (flagship Egyptian daily). I also prefer the aesthetics of Hindi numerals, but it looks like quail makes the proper choice to default to Arabic numerals since they appear to be the default in the Arab world as well. – Dan Dec 23 '14 at 12:18
10

So the requirement is: When I'm using the arabic input method, and I type a digit, I want Emacs to insert the Hindi character for that digit.

To do this, we can adapt your linked approach to extend an input-method like so:

(eval-after-load "quail/arabic"
  '(let ((quail-current-package (assoc "arabic" quail-package-alist)))
     (quail-define-rules ((append . t)) ;; don't clobber the existing rules
                         ("0" "\u0660")
                         ("1" "\u0661")
                         ("2" "\u0662")
                         ("3" "\u0663")
                         ("4" "\u0664")
                         ("5" "\u0665")
                         ("6" "\u0666")
                         ("7" "\u0667")
                         ("8" "\u0668")
                         ("9" "\u0669"))))

Then when you use C-uC-\ arabic (or just C-\ if it's your default), and type a digit, it inserts the specified translation instead.

  • Great! problem fixed. Emacs is really the best editor. – doctorate Dec 23 '14 at 10:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.