all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Lars Magne Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: Bidirectional text and URLs
Date: Sun, 30 Nov 2014 19:53:32 +0200	[thread overview]
Message-ID: <831toka82r.fsf@gnu.org> (raw)
In-Reply-To: <m3wq6c7iyu.fsf@stories.gnus.org>

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Date: Sun, 30 Nov 2014 17:26:33 +0100
> 
> Just a point of clarification: When people embed URLs in paragraphs with
> mainly right-to-left script (like Hebrew)

Let's clear up terminology first, OK?

There's no distinction in bidi display and bidi scripts between
"paragraphs with mainly right-to-left scripts" and "paragraphs with
mainly left-to-right scripts".  Instead, there's "the base direction
of a paragraph", which can be either left-to-right (LTR) or
right-to-left (RTL).  The former is displayed with the first character
(in the _visual_ order!) at the left edge of the window, while the
latter at the right edge.

It is true that the LTR paragraphs make most sense when most of the
paragraph text is made of LTR characters, and the RTL paragraphs in
the opposite case.  But nothing prevents me from having a paragraph
whose base direction is LTR which is nevertheless full of RTL
characters.  It is entirely legitimate and sometimes even necessary.

Emacs determines the base direction of a paragraph by searching for
the first strong directional character in the paragraph (this is a
simplification, the actual rules described in the UBA are more
complex).  Buffer-local variable bidi-paragraph-direction overrides
this dynamic calculation and forces a specific base direction on all
paragraphs of the buffer.

With this out of our way, I will assume that you were asking about
URLs that are part of paragraphs whose base direction is RTL.  Now
let's go back to your question:

> do they expect to see http://myspace.com or ‮?http://myspace.com

The answer to your question is "it depends".  Here are 3 examples, to
see them as I intended, make sure you are viewing them in a buffer
whose bidi-paragraph-direction is set to nil:

abc http://אבג.דהוזחט.קום

אבג http://foo.bar.com

אבג http://אבג.דהוזחט.קום

The leading 3 letters (1 would be enough) cause Emacs to decide that
the paragraph has LTR base direction in the 1st example and RTL base
direction in the last 2 examples.

Now move the cursor with C-f from the beginning of each of these three
lines (you can get to the beginning of a line with C-a or Home, as
usual), and I hope you will see what's going on: cursor movement with
C-f follows the "reading order", i.e. the order in which a human is
supposed to read these URLs.

To summarize: Latin characters are displayed left to right, even in
RTL paragraphs, while right-to-left characters are always displayed
right to left.  Neutral characters (slash, period) take the direction
of the surrounding text.

> (If I did that correctly, the latter URL should have an RLO character
> preceding it so that it reads right to left.)

As you see above, there's no need to use any directional overrides to
see what users expect: Emacs does that automatically, by following the
Unicode Bidirectional Algorithm (UBA).  You just need to arrange for
the paragraph to have a RTL base direction, which is very easy, as
shown above.

RLO and LRO (and the other directional control characters) are needed
when you need to override the normal reordering for some reason,
typically because you want punctuation characters to take a different
directionality from its default.  This is rarely needed when rendering
URLs.

HTH

May I ask why you came up with the question?




  parent reply	other threads:[~2014-11-30 17:53 UTC|newest]

Thread overview: 133+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-28  2:51 Bidirectional text and URLs Lars Magne Ingebrigtsen
2014-11-28  3:27 ` Stephen J. Turnbull
2014-11-28 14:54   ` Eli Zaretskii
2014-11-29  6:09     ` Stephen J. Turnbull
2014-11-29  8:22       ` Eli Zaretskii
2014-11-29 17:05         ` Richard Stallman
2014-11-29 17:13           ` Lars Magne Ingebrigtsen
2014-11-29 17:49             ` Lars Magne Ingebrigtsen
2014-11-29 17:54               ` Lars Magne Ingebrigtsen
2014-11-29 18:24                 ` Eli Zaretskii
2014-11-29 18:29                   ` Lars Magne Ingebrigtsen
2014-11-30  9:38                   ` Richard Stallman
2014-11-30 15:21                     ` Eli Zaretskii
2014-11-29 18:18               ` Eli Zaretskii
2014-11-29 18:33                 ` Lars Magne Ingebrigtsen
2014-11-29 18:47                   ` Eli Zaretskii
2014-11-29 19:12                     ` Andreas Schwab
2014-11-29 19:31                       ` Lars Magne Ingebrigtsen
2014-11-29 19:39                         ` Andreas Schwab
2014-11-29 20:13                       ` Eli Zaretskii
2014-11-30 16:26                 ` Lars Magne Ingebrigtsen
2014-11-30 17:29                   ` Yuri Khan
2014-11-30 17:57                     ` Lars Magne Ingebrigtsen
2014-11-30 18:18                       ` Eli Zaretskii
2014-11-30 17:53                   ` Eli Zaretskii [this message]
2014-11-30 18:13                     ` Lars Magne Ingebrigtsen
2014-11-30 19:06                       ` Lars Magne Ingebrigtsen
2014-11-30 19:10                         ` Lars Magne Ingebrigtsen
2014-11-30 20:41                           ` Eli Zaretskii
2014-11-30 19:19                       ` Lars Magne Ingebrigtsen
2014-11-30 21:05                       ` Eli Zaretskii
2014-11-30 21:36                         ` Lars Magne Ingebrigtsen
2014-12-01  3:45                           ` Eli Zaretskii
2014-12-01 16:19                             ` Lars Magne Ingebrigtsen
2014-12-01 17:39                               ` Eli Zaretskii
2014-12-01 17:49                                 ` Lars Magne Ingebrigtsen
2014-12-01 18:22                                   ` Eli Zaretskii
2014-12-01 18:28                                     ` Lars Magne Ingebrigtsen
2014-12-02 14:17                                       ` Eli Zaretskii
2014-12-02 16:31                                         ` Lars Magne Ingebrigtsen
2014-12-01 19:15                         ` Richard Stallman
2014-12-01 19:15                         ` Richard Stallman
2014-12-01 19:34                           ` Eli Zaretskii
2014-12-01 20:21                             ` Eli Zaretskii
2014-12-01 20:30                               ` David Kastrup
2014-12-01 20:45                                 ` Eli Zaretskii
2014-12-02 14:45                                   ` Richard Stallman
2014-12-02 14:45                               ` Richard Stallman
2014-12-02 15:03                                 ` Eli Zaretskii
2014-12-03  8:39                                   ` Richard Stallman
2014-12-03 17:39                                     ` Eli Zaretskii
2014-12-04  9:41                                       ` Eli Zaretskii
2014-12-05 11:16                                         ` Richard Stallman
2014-12-05 11:28                                           ` Eli Zaretskii
2014-12-05 22:43                                             ` Richard Stallman
2014-12-05 23:15                                               ` Eli Zaretskii
2014-12-06 12:06                                                 ` Richard Stallman
2014-12-06 12:59                                                   ` Eli Zaretskii
2014-12-05 22:43                                             ` Richard Stallman
2014-12-05 23:17                                               ` Eli Zaretskii
2014-12-06 12:06                                                 ` Richard Stallman
2014-12-02 14:44                             ` Richard Stallman
2014-12-02 15:00                               ` Eli Zaretskii
2014-12-03  8:39                                 ` Richard Stallman
2014-11-30  9:38               ` Richard Stallman
2014-11-30 15:27                 ` Eli Zaretskii
2014-12-01 10:17                   ` Richard Stallman
2014-12-01 16:17                     ` Eli Zaretskii
2014-12-02 14:42                       ` Richard Stallman
2014-12-02 14:48                         ` Eli Zaretskii
2014-12-03  8:38                           ` Richard Stallman
2014-12-03 11:56                             ` Nicolas Richard
2014-12-03 17:12                               ` Richard Stallman
2014-12-03 17:38                             ` Eli Zaretskii
2014-12-04 14:30                               ` Richard Stallman
2014-12-04 15:53                                 ` Stefan Monnier
2014-12-04 17:30                                   ` Eli Zaretskii
2014-12-04 20:25                                   ` Paul Eggert
2014-12-02 14:42                       ` Richard Stallman
2014-12-02 14:52                         ` Eli Zaretskii
2014-12-02 18:05                           ` Eli Zaretskii
2014-12-03 17:13                             ` Richard Stallman
2014-12-03 18:14                               ` Eli Zaretskii
2014-12-05 22:44                                 ` Richard Stallman
2014-12-05 23:19                                   ` Eli Zaretskii
2014-12-07  9:20                                     ` Richard Stallman
2014-12-07 15:50                                       ` Eli Zaretskii
2014-12-08  0:26                                         ` Richard Stallman
2014-12-08 15:46                                           ` Eli Zaretskii
2014-12-03 17:13                           ` Richard Stallman
2014-12-03 17:13                           ` Richard Stallman
2014-11-29 17:14         ` Ted Zlatanov
2014-11-30 13:42         ` Stephen J. Turnbull
2014-11-30 15:36           ` Eli Zaretskii
2014-12-01 10:18           ` Richard Stallman
2014-12-01 16:18             ` Eli Zaretskii
2014-12-01 18:32               ` Stephen J. Turnbull
2014-12-01 19:12                 ` Eli Zaretskii
2014-12-01 20:08                   ` Stephen J. Turnbull
2014-12-01 20:42                     ` Eli Zaretskii
2014-12-02 14:42               ` Richard Stallman
2014-12-02 14:54                 ` Eli Zaretskii
2014-12-03  8:39                   ` Richard Stallman
2014-11-28 11:19 ` Ted Zlatanov
2014-11-28 13:58   ` Lars Magne Ingebrigtsen
2014-11-28 19:49     ` Ted Zlatanov
2014-11-28 21:02       ` Stefan Monnier
2014-11-29  0:26         ` Ted Zlatanov
2014-11-28 22:26       ` Eli Zaretskii
2014-11-28 14:24   ` Stefan Monnier
2014-11-28 14:57   ` Eli Zaretskii
2014-11-29  6:17   ` Stephen J. Turnbull
2014-11-28 14:45 ` Eli Zaretskii
2014-11-28 17:09 ` Richard Stallman
2014-11-28 18:28   ` Eli Zaretskii
2014-11-29 17:03     ` Richard Stallman
2014-11-29 17:06       ` Eli Zaretskii
2014-11-30  9:37         ` Richard Stallman
2014-11-30 15:16           ` Eli Zaretskii
2014-12-01 10:18             ` Richard Stallman
2014-12-01 16:02               ` Eli Zaretskii
2014-11-28 19:28   ` Andreas Schwab
2014-11-29 17:04     ` Richard Stallman
2014-11-29 17:11       ` Eli Zaretskii
2014-11-30  9:38         ` Richard Stallman
2014-11-30 15:20           ` Eli Zaretskii
2014-11-30 23:39             ` chad
2014-12-01  3:49               ` Eli Zaretskii
2014-12-01  8:01                 ` chad
2014-12-01 15:58                   ` Eli Zaretskii
2014-12-02 14:41                     ` Richard Stallman
2014-12-01 19:17                   ` Richard Stallman
2014-12-01 10:18             ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=831toka82r.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.