4

I have set the variable bidi-paragraph-direction to nil in my init.el so that lines starting with (strong) Arabic letters are displayed from right to left, and lines with English are displayed from left to right.

It works fine except that I have to insert an empty line between lines with different directionality so that the next line won't be affected by the previous line directionality. I'm not sure if this is a bug or an expected behavior:

أبجد هوز
ABCD

*******************************************

أبجد هوز

ABCD

Problem illustration

Is there a way to limit the scope of directionality to a single line? or redefine the number of lines in a single paragraph? (GTK+ is doing it right).

4

You're going to want to set both bidi-paragraph-start-re and bidi-paragraph-separate-re to "^":

(setq bidi-paragraph-separate-re "^"
      bidi-paragraph-start-re "^")

The documentation for these variables says:

If you change the value of this variable, be sure to change the value of ‘bidi-paragraph-separate-re’ accordingly. For example, to have a single newline behave as a paragraph separator, set both these variables to "^".

I don't know much about Emacs's bidirectional display, but I found these variables and the above line in the documentation by using describe-variable with helm-mode and searching for "bidi" after I suspected there might be a built in way to control this behavior. You can also use the built in M-x commands apropos and apropos-variable and friends to search for variables and functions that might be relevant.

  • This does not seem to work (I am using emacs 25). <del>Are you using emacs 26?</del> OK, these controls were introduced in emacs 26. – user6026299 Jan 30 '18 at 14:41
  • @user6026299, Ah, yes I am! Sorry about that! – nanny Jan 30 '18 at 15:15
  • I have compiled and installed emacs 26, it works like charm :)! – user6026299 Jan 30 '18 at 15:47

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.