From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#11700: 24.1.50; Bad interaction between BiDi and org-tables Date: Sat, 23 Dec 2017 15:38:11 +0200 Message-ID: <83y3ltk1j0.fsf@gnu.org> References: <83mx46y4f5.fsf@gnu.org> <87mv2y6xx2.fsf@nicolasgoaziou.fr> <83374qxlwp.fsf@gnu.org> <877eu26wc7.fsf@nicolasgoaziou.fr> <83zi6twotx.fsf__4220.56812462888$1512725457$gmane$org@gnu.org> <87mv2trvti.fsf@nicolasgoaziou.fr> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1514036250 4412 195.159.176.226 (23 Dec 2017 13:37:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 23 Dec 2017 13:37:30 +0000 (UTC) Cc: dov.grobgeld@gmail.com, 11700@debbugs.gnu.org To: Nicolas Goaziou Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 23 14:37:26 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSjzL-0008Rc-L9 for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 14:37:19 +0100 Original-Received: from localhost ([::1]:42017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSk1F-0006v9-Fw for geb-bug-gnu-emacs@m.gmane.org; Sat, 23 Dec 2017 08:39:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSk15-0006u9-Ii for bug-gnu-emacs@gnu.org; Sat, 23 Dec 2017 08:39:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSk14-0003uN-Nx for bug-gnu-emacs@gnu.org; Sat, 23 Dec 2017 08:39:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40135) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eSk10-0003sU-BF; Sat, 23 Dec 2017 08:39:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eSk10-0000hw-57; Sat, 23 Dec 2017 08:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Sat, 23 Dec 2017 13:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11700 X-GNU-PR-Package: emacs,org-mode X-GNU-PR-Keywords: Original-Received: via spool by 11700-submit@debbugs.gnu.org id=B11700.15140363012668 (code B ref 11700); Sat, 23 Dec 2017 13:39:02 +0000 Original-Received: (at 11700) by debbugs.gnu.org; 23 Dec 2017 13:38:21 +0000 Original-Received: from localhost ([127.0.0.1]:48816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSk0L-0000gy-By for submit@debbugs.gnu.org; Sat, 23 Dec 2017 08:38:21 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43456) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eSk0J-0000gj-Cp for 11700@debbugs.gnu.org; Sat, 23 Dec 2017 08:38:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSk0A-0003Ie-Hm for 11700@debbugs.gnu.org; Sat, 23 Dec 2017 08:38:13 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSk0A-0003IR-Dv; Sat, 23 Dec 2017 08:38:10 -0500 Original-Received: from [176.228.60.248] (port=3846 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eSk09-0006Af-Pc; Sat, 23 Dec 2017 08:38:10 -0500 In-reply-to: <87mv2trvti.fsf@nicolasgoaziou.fr> (message from Nicolas Goaziou on Fri, 08 Dec 2017 18:08:57 +0100) 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" Xref: news.gmane.org gmane.emacs.bugs:141424 Archived-At: > From: Nicolas Goaziou > Date: Fri, 08 Dec 2017 18:08:57 +0100 > Cc: dov.grobgeld@gmail.com, 11700@debbugs.gnu.org > > For tests, we use `org-test-with-temp-text' macro, e.g., > > (org-test-with-temp-text "| a | b |\n| c | d |" > ... do something in that buffer ...) You didn't say that this macro is only available in the Org's Git repository... Anyway, since it's a very simple macro, I just used its guts below. I found both methods doing well, so I'm going to show both, and let you decide which one is better. The below provides a demonstration of each method by displaying a buffer with a table whose columns include both L2R and R2L text, such that the table columns are still laid out left to right, unlike when one just types the characters in the cells. Method 1: wrap each string with (invisible) bidi formatting control characters which isolate each string from the surrounding text. (defun bidi-isolate-string (str) (concat (propertize (string ?\x2068) 'invisible t) str (propertize (string ?\x2069) 'invisible t))) (with-current-buffer (get-buffer-create "bidi-org-table1") (org-mode) (insert (concat "| " (bidi-isolate-string "abcd") " | " (bidi-isolate-string "efgh") " |\n| " (bidi-isolate-string "אבגד") " | " (bidi-isolate-string "הוזח") " |")) (pop-to-buffer "bidi-org-table")) This has a minor issue: it fails to conceal the bidi control characters on display, although I used the 'invisible' property for that purpose. I'm guessing that Org takes control of the 'invisible' properties, in which case perhaps this method should use some other property, if possible. If it is not practical to conceal the bidi controls on display, the following method is preferable. Method 2: give the spaces around the cell text the display property which makes the spaces serve as segment separators for the purposes of the bidirectional reordering. (defun bidi-separator-space () (propertize " " 'display '(space :width 1))) (with-current-buffer (get-buffer-create "bidi-org-table2") (org-mode) (insert (concat "|" (bidi-separator-space) "abcd" (bidi-separator-space) "|" (bidi-separator-space) "efgh" (bidi-separator-space) "|\n|" (bidi-separator-space) "אבגד" (bidi-separator-space) "|" (bidi-separator-space) "הוזח" (bidi-separator-space) "|")) (pop-to-buffer "bidi-org-table2")) Let me know if I can help you further, or if you have additional questions.