From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eli Zaretskii 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__38038.7992634953$1514036271$gmane$org@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 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34556) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSk13-0006td-Kc for emacs-orgmode@gnu.org; Sat, 23 Dec 2017 08:39:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSk10-0003sd-Fk for emacs-orgmode@gnu.org; Sat, 23 Dec 2017 08:39:05 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <87mv2trvti.fsf@nicolasgoaziou.fr> (message from Nicolas Goaziou on Fri, 08 Dec 2017 18:08:57 +0100) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: dov.grobgeld@gmail.com, 11700@debbugs.gnu.org > 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.