1

Consider the following two files, identical but for the filename:

$ md5sum emacs-test-file.txt emacs-test-file.org
43305dbeb954094f63709b2889fc8e02  emacs-test-file.txt
43305dbeb954094f63709b2889fc8e02  emacs-test-file.org

Opening the former in Emacs opens in normal mode, and the text displays as expected:

Normal mode, text displayed fine.

However, opening the second file in Emacs opens in Org mode, and the text is displayed with two problems:

  1. Left-directionality.
  2. Lines wrap up instead of down:

Org mode, text displayed with left-directionality and lines wrapping up instead of down.

Though I expect that most of the fine audience does not speak Hebrew, the first issue can be confirmed by noting that the first screenshot's text is properly aligned to the right, and that the period at the end is properly to the left of the text. Contrast with the second screenshot, which is improperly aligned to the left and has the period to the right of the text.

The second issue can be confirmed by noting that the first screenshot properly has the word אִימֶקְס on the right of the top-most line of the first paragraph, because that is where Right-To-Left languages begin their paragraphs. Contrast with the second screenshot, in which the same word אִימֶקְס is found on the right of the bottom-most line of the first paragraph, because each successive line is wrapped up. It would be akin to writing the famous poem:

And some don't.
Some poems rhyme.
Violets are blue.
Roses are red.

Do note that even in the incorrect display of Org mode, the characters do properly flow from Right to Left and the text is readable.

This is on GNU Emacs 27.1 with Spacemacs, in KDE on Kubuntu 20.04, with Emacs installed from the kelleyk/emacs repo. I also had the exact same issue on my previous machine which was running Emacs 27.0 from the distro package (same distro and version) with only Evil installed.

Here is the original text of the two (identical) files:

אִימֶקְס היא משפחה של עורכי טקסט שנודעו בעיקר בזכות האפשרות להרחיב אותם לשימושים חדשים. רק גרסה אחת, זו המכונה גְנוּ אִימֶקְס, שנוצרה על ידי ריצ'רד סטולמן עבור מיזם גנו, נפוצה עדיין בשימוש ולמעשה נחשבת לתוכנה החופשית הוותיקה ביותר בפיתוח פעיל. 

אימקס זמינה במגוון רחב מאוד של מערכות הפעלה (היסטוריות ומודרניות) וזכתה למעמד מיתולוגי בקהילת התוכנה החופשית והקוד הפתוח, בין השאר בזכות היותה צד ב"מלחמת העורכים" המיתולוגית בינה ובין עורך טקסט חופשי וותיק אחר, וואי.
0

1 Answer 1

5

org-mode expressly sets bidi-paragraph-direction when the major-mode is enabled: (setq bidi-paragraph-direction 'left-to-right) Here is a link to the org-mode code section: https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org.el#L4838 To change that value in org-mode, consider using the org-mode-hook that runs right after the other major-mode settings.

If a user will generally be using a certain direction, he/she may wish to set bidi-paragraph-direction -- "If this is nil (the default), the direction of each paragraph is determined by the first strong directional character of its text. The values of right-to-left and left-to-right override that. Any other value is treated as nil." Note that this is a buffer-local variable, so if the user wishes it to be set as a default for all buffers (that are not expressly set otherwise), then consider using setq-default. The variable may also be set locally for a particular buffer in the same manner as org-mode does it.

1
  • Thank you! Setting (add-hook 'org-mode-hook (lambda() (setq bidi-paragraph-direction nil) ) ) did the trick.
    – dotancohen
    Commented Apr 17, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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