[[!meta title="Perso-Arabic Input Methods And BIDI Aware Apps"]]
[[!meta copyright="Copyright © 2021 Mohsen BANAN"]]
[[!inline pages="internal(2021/info/bidi-nav)" raw="yes"]]

<!-- You can manually edit this file to update the abstract, add links, etc. --->


# Perso-Arabic Input Methods And BIDI Aware Apps
Mohsen BANAN -- <mailto:emacs@mohsen.1.banan.byname.net> --  محسن بنان  
pronouns: he/him, pronunciation: MO-HH-SS-EN  
<http://mohsen.1.banan.byname.net>

[[!inline pages="internal(2021/info/bidi-schedule)" raw="yes"]]

## About The Video

The video is a screen capture of a [reveal](https://revealjs.com) presentation
prepared with Beamer XeLaTeX and [HaVeA](http://hevea.inria.fr). So, the
[original reveal
presentation](http://web.by-star.net/lcnt/PLPC/180063/current/pres/PLPC-180063-pres.html)
allows you to click on links that you see in the video and also navigate through
the slide. In html, it is also availble as a [Presenation-As-Article
format](http://web.by-star.net/lcnt/PLPC/180063/current/presArt/PLPC-180063-presArt.html)
which includes complete text of the audio. [The traditional beamer slides](
http://web.by-star.net/lcnt/PLPC/180063/current/pres/PLPC-180063-pres.pdf) are
also available. The Access Page for
[PLPC-180063](http://www.by-star.net/PLPC/180063) points to all available forms
and formats.

## About This Presentation

Emacs is a multilingual user environment. A true multilingual editor must
support bidirectionality and shaping of characters. Perso-Arabic scripts require
both of these features.

Starting with Emacs 24, full native bidi
(bidirectional) support became available.  For
many years prior to that Unicode support was
available and by around year 2000, reasonable
open-source shaping libraries were also available.

With these in place at around 2012, I developed
two Persian input methods for emacs. These input
methods or variations of them can also be used for
Arabic and other Perso-Arabic scripts.

With all of these in place, Emacs has now become
the ne plus ultra Libre-Halaal and Convivial usage
environment for Perso-Arabic users.

Since emacs comes loaded with everything (Gnus
for email, Bbdb for address books, XeLaTeX modes
for typesetting, org-mode for organization, spell
checkers, completion systems, calendar, etc.), all basic
computing and communication needs of Perso-Arabic
users can be addressed in one place and
cohesively.

In this talk I will demonstrate what a wonderful
environment that can be.
    
My talk will be in two parts.
    
In Part 1, I cover Persian input methods. With an emphasis on "Banan
Multi-Character (Reverse) Transliteration Persian Input Method". The
software is part of base emacs distribution. Full documentation is available
at: 

    
           Persian Input Methods
           For Emacs And More Broadly Speaking
           شیوه‌هایِ درج به فارسی‌
<http://mohsen.1.banan.byname.net/PLPC/120036>
    
In Part 2, I'll demonstrate that Emacs is far more than an editor. Emacs can be
a complete Perso-Arabic usage environment. I will also cover the ramifications
of bidi on existing emacs applications, including:
    
-   Spell Checking, Dictionaries And Completion Frameworks:
    - Existing emacs facilities can be extended to cover Perso-Arabic.
    
-   Gnus:
    -   Perso-Arabic rich email sending in HTML.
    -   Ramifications of bidi on from:, to: and subject: lines.
    
-   Bbdb: Ramifications of bidi on display and completion.
    
-   Calendar:
    -   Ramifications of bidi on display.
    -   Use of Persian text for Persian (solar) calendar.
    -   Use of Arabic text for Muslim (lunar)  calendar.
    
-   AUCTeX: Persian typesetting with XeLaTeX
    -   Option of having right-to-left  Perso-Arabic aliases for all latex commands.

# References:

## Persian Input Methods:
<http://mohsen.1.banan.byname.net/PLPC/120036>
<http://www.persoarabic.org/PLPC/120036> -- Persian Input Methods Access Page
<http://www.persoarabic.org> -- Various Perso-Arabic resources
<http://www.freeprotocols.org/Repub/fpf-isiri-6219> -- Re-Publication Of 
          Persian Information Interchange and Display Mechanism, using Unicode
<https://github.com/bx-blee/persian-input-method> -- Git repo for
          persian.el -- Quail package for inputting Persian/Farsi keyboards
      
## BIDI:
<http://www.unicode.org/reports/tr9/> -- Annex #9 of the Unicode standard
<https://www.gnu.org/software/emacs/manual/html_node/elisp/Bidirectional-Display.html>   
          Emacs Bidirectional Display   
<http://www.persoarabic.org/answers>   
          Paragraph Directionality Results Into Serious Communication Problems 

## Blee and Persian-Blee:
<https://github.com/bx-blee/env2> -- Very messy work-in-progress git repo for:  
          Blee: By* Libre-Halaal Emacs Environment   
<http://www.by-star.net> -- A Moral Alternative To The Proprietary American Digital Ecosystem  
<http://mohsen.1.banan.byname.net/PLPC/120033> --   
            Nature of Polyexistentials:   
            Basis for Abolishment of The Western Intellectual Property Rights Regime   
<http://mohsen.1.banan.byname.net/PLPC/120039> -- Defining The Libre-Halaal Label  
          
## Mohsen BANAN -- محسن بنان:
<http://mohsen.1.banan.byname.net/> -- Globish  
<http://mohsen.1.banan.byname.net/persian> -- Farsi  
<http://mohsen.1.banan.byname.net/french> -- French  

# Discussion

Pad:

-   Q1: is there any additions that you have to add to emacs for using
    non-English/latin characters or does it work mostly out of the box? 
    -   A: [Prot] :  I only set the default-input-method to "greek".
        Then switch to it with C- (toggle-input-method)
-   Q2: One stuggle I have with this input method option is, why not use
    an IME that's installed on the host OS?
    -   A:I live inside Emacs, and that the host OS typically provides
        an unintelligent keyboard, and Farsi and transliterate BANAN
        provides multi-character input, which is a lot more powerful.
-   Q3: Do you write any lisp or other code/markup with these scripts?
    (Sorry if I missed you mentioning this.)
    -   A:No, everything is in pure Elisp.
-   Q4: What alternatives have you looked into for solving the problem
    related to your markup language idea? What isn't achieved by them?
    -   A:The way that Emacs has evovled about properties about string
        and text. And I suggest we adopt the "web" model for Emacs
        application development. If you step back and look at where we
        are, there's no such thing as no 'emacs native markup language
        mode' similar to HTML for web.  Emacs's display engine is
        capable of doing everything, but we're not exposing ....
        (sorry, missed this part)
    -   Makes sense to me, thanks!
-   Q5: bandali: genenrally curious about the state of writing/reading
    Persian in the TTY
-   Q6: Does your input method also solves problems with exporting
    doctuments ? usually when  you exporting a Persian-Enlight doc it
    redirects the Persian scripts to LTR

Questions/comments:

- Thanks for giving such a nice presentation of the Emacs input method framework! I'm just curious about if you've made any plans for setting up your markup language? I know you said you hadn't written any code for it yet.
- That makes sense. Do you think you could use org more exclusively, and just add portions to implement your idea? As-in, there's nothing within org mode that would need to be fundamentally changed, correct?
- I wonder about that. Org doesn't quite support all the expressivness that you see in some buffers/modes.
- I agree. Finding a way to reach a happy medium without having to go "full elisp" would be quite powerful.
- Potentially the tui.el system mentioned earlier in the conference could mix will with your idea as well.
- I have one last, quick question. If you've used a version of Emacs 28, how have you found the new feature of doing a quick switch into a different IME? I know John Wiegly mentioned it in his talk earlier.
- Does OS-level stuff work when you have to change character direction on the same line, like LtR numbers in a RtL script?

Feedback:

- This is great. I've done a demo like this for a few friends in the past as well.
- Whoever did the captions for this was spot on, the unicode characters would be challenging.
- I just love the Emacs input method framework, and I don't think a lot of latin script users know about it.
- This is really cool, it's something that I never think about from other users in other countries using Emacs.
- The captions for this conference have has an impressive amount of work put into them.
- omg! this is great. farsi 101 in emacs 
- ++ to all that stuff.  Great job on the captions, and the demonstrated functionality is very impressive.
- Yay for the captions!
- This has been really slick. Kudos for the captions including the Farsi characters and latin text.
- At first, I thought the captions would be unnecessary, but over time, understanding the accents for various individuals has been challenging, so the captions helped.
- One struggle I have with this input method option is, why not use an IME that's installed on the host OS? I mean, I do that with Japanese, but that may no longer work easily with qubes, so maybe it's more of a thing that'd benefit me now.
  - though, I'm thinking that certain input methods don't actually simulate key-presses on virtual keyboards ... ?
  - Not a primary reason, but since I'm used to configuring Emacs, I've found it a lot easier to learn to configure the integrated IMF than to configure an external one.
  - I used SCIM/uim for japanese input at one put, but that was before I used emacs, it was a nightmare to set up
- I may have to try this, the IMEs I've used haven't been an issue too much in the past, but...maybe this would be better, at least I wouldn't have to worry about config on each qube.
- Banan's work on BIDI support is an eye-opener...
- yeah absolutely. it's a really great point that Emacs can always be expanded to be more inclusive to other languages in ways that are more than just Unicode related.
- bidi destorying irssi, time to find a good emacs irc client ...
- thanks for the talk...another example how Emacs is inclusive catering for all forms of text.
- Lots to think about. Thanks for the talk and inspiration!
- Awesome. Thanks again for such a great talk and a great q&amp;a!

[[!inline pages="internal(2021/captions/bidi)" raw="yes"]]
[[!inline pages="internal(2021/info/bidi-nav)" raw="yes"]]