From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#22429: Force character to be recognized as LTR inside RTL paragraph Date: Fri, 22 Jan 2016 10:08:06 +0200 Message-ID: <83mvry6nq1.fsf@gnu.org> References: <56a13f4844c61b5100000006@polymail.io> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1453450103 12423 80.91.229.3 (22 Jan 2016 08:08:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Jan 2016 08:08:23 +0000 (UTC) Cc: 22429@debbugs.gnu.org To: "Filipe Moreira" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 22 09:08:12 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aMWlQ-0002wP-2e for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Jan 2016 09:08:12 +0100 Original-Received: from localhost ([::1]:51213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMWlP-0006TH-3O for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Jan 2016 03:08:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMWlL-0006TA-55 for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2016 03:08:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMWlG-0004Te-9g for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2016 03:08:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40486) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMWlG-0004Ta-5w for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2016 03:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aMWlG-0007zG-0I for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2016 03:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 22 Jan 2016 08:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22429 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22429-submit@debbugs.gnu.org id=B22429.145345008030695 (code B ref 22429); Fri, 22 Jan 2016 08:08:01 +0000 Original-Received: (at 22429) by debbugs.gnu.org; 22 Jan 2016 08:08:00 +0000 Original-Received: from localhost ([127.0.0.1]:56939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMWlE-0007z0-4q for submit@debbugs.gnu.org; Fri, 22 Jan 2016 03:08:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:59499) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aMWlC-0007ym-Q1 for 22429@debbugs.gnu.org; Fri, 22 Jan 2016 03:07:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMWl4-0004SD-EA for 22429@debbugs.gnu.org; Fri, 22 Jan 2016 03:07:53 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMWl4-0004S9-Ar; Fri, 22 Jan 2016 03:07:50 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4923 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aMWl3-0001xY-N4; Fri, 22 Jan 2016 03:07:50 -0500 In-reply-to: <56a13f4844c61b5100000006@polymail.io> (famoreira@gmail.com) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:111846 Archived-At: > Date: Thu, 21 Jan 2016 13:14:22 -0800 > From: "Filipe Moreira" > > I’m using Emacs as a LaTeX editor, with the AUCTeX mode. One document I’m > authoring is written in English with some paragraphs in Hebrew or Greek. > > The issue I have is with mixing some neutral characters that need to be LTR, > inside a paragraph which is RTL. An example of this is the slash (i.e. ‘\’) > character used by LaTeX to signal its commands. Inside a RTL paragraph I > ideally want to force Emacs to always interpret the slash character, as well as > the open and close brackets (i.e. {}) as LTR. > > This is not what happens at the moment. Here I have a visual representation of > the problem: > http://emacs.stackexchange.com/questions/19696/handling-left-to-right-inside-right-to-left-paragraphs-using-emacs-and-auctex. > > Is it possible to whitelist some characters that should always be interpreted > as LTR? The directionality of characters is determined by their bidirectional class property as defined by the Unicode Character Database. Emacs uses those definitions in its implementation of the UBA, the Unicode Bidirectional Algorithm, when it lays out text for display. Punctuation characters, such as \, {, and } have "weak directionality": they take the directionality of the surrounding text, and if the directionality on either side is different, they default to the paragraph's base direction, which is RTL in your case. So that is what you see. Emacs being Emacs, you can programmatically change the bidirectional class of every character, but that change has global effect: it will affect the directionality of that character everywhere in the Emacs session. So this is not recommended. The correct solution to these problems is to wrap the footnote block in the LRE..PDF or LRI..PDI control characters, so that the footnote is rendered independently of the surrounding bidirectional context. See the example below. Not sure if LaTeX will DTRT with directional control characters, but if it doesn't, that's a bug/misfeature in LaTeX. \begin{hebrew} \pstart בְּרֵאשִׁ֖ית‪\footnoteA{This is a Hebrew related footnote}‬ בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ \pend \end{hebrew} Another possibility is to insert newlines between the footnote and the surrounding text, as shown below. Not sure if LaTeX will be happy with that, and I think it's uglier anyway. \begin{hebrew} \pstart בְּרֵאשִׁ֖ית \footnoteA{This is a Hebrew related footnote} בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ \pend \end{hebrew} I don't think there's a bug to fix here, so I'm going to close this bug report. Any objections?