all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: dov.grobgeld@gmail.com, 11700@debbugs.gnu.org
Subject: bug#11700: 24.1.50; Bad interaction between BiDi and org-tables
Date: Sat, 23 Dec 2017 15:38:11 +0200	[thread overview]
Message-ID: <83y3ltk1j0.fsf@gnu.org> (raw)
In-Reply-To: <87mv2trvti.fsf@nicolasgoaziou.fr> (message from Nicolas Goaziou on Fri, 08 Dec 2017 18:08:57 +0100)

> From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
> 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.





  reply	other threads:[~2017-12-23 13:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-13 19:26 bug#11700: 24.1.50; Bad interaction between BiDi and org-tables Dov Grobgeld
2012-06-14  3:10 ` Eli Zaretskii
2012-06-14 18:10   ` Dov Grobgeld
2012-06-14 19:37     ` Eli Zaretskii
2012-06-14 19:37     ` Eli Zaretskii
2012-06-15  6:39       ` bug#11700: " Dov Grobgeld
2012-06-15  6:39       ` bug#11700: [O] " Dov Grobgeld
2012-06-15  8:38         ` bug#11700: " Eli Zaretskii
2012-06-15  8:38         ` bug#11700: [O] " Eli Zaretskii
2012-06-14 18:10   ` Dov Grobgeld
2017-12-04 20:27   ` Nicolas Goaziou
2017-12-04 20:27   ` Nicolas Goaziou
2017-12-04 20:35     ` Dov Grobgeld
2017-12-04 20:35     ` Dov Grobgeld
2017-12-04 20:43       ` Eli Zaretskii
2017-12-04 20:53         ` Eli Zaretskii
2017-12-04 20:53         ` Eli Zaretskii
2017-12-04 20:43       ` Eli Zaretskii
2017-12-04 20:45     ` Eli Zaretskii
2017-12-04 20:45     ` Eli Zaretskii
2017-12-04 21:02       ` Nicolas Goaziou
2017-12-08  9:28         ` Eli Zaretskii
2017-12-08 17:08           ` Nicolas Goaziou
2017-12-08 17:08           ` Nicolas Goaziou
2017-12-23 13:38             ` Eli Zaretskii [this message]
2017-12-23 13:48               ` Eli Zaretskii
2017-12-23 13:48               ` Eli Zaretskii
2017-12-23 22:51               ` Nicolas Goaziou
2017-12-23 22:51               ` Nicolas Goaziou
2017-12-23 13:38             ` Eli Zaretskii
2017-12-08  9:28         ` Eli Zaretskii
2017-12-04 21:02       ` Nicolas Goaziou

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=83y3ltk1j0.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=11700@debbugs.gnu.org \
    --cc=dov.grobgeld@gmail.com \
    --cc=mail@nicolasgoaziou.fr \
    /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.