From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: bidi reordering in program source buffers (was: bidi-display-reordering is now non-nil by default) Date: Sat, 20 Aug 2011 11:14:28 +0300 Message-ID: <83obzkqz2z.fsf@gnu.org> References: <4E48D309.6050503@acdlabs.ru> <83hb5jujjs.fsf@gnu.org> <874o1j10zv.fsf@fencepost.gnu.org> <8362lyvcli.fsf@gnu.org> <87fwl2r0l4.fsf@stupidchicken.com> <83zkjatnkz.fsf@gnu.org> <877h6et8oi.fsf@stupidchicken.com> <83vctxua2y.fsf@gnu.org> <87r54le4rd.fsf@stupidchicken.com> <8362lxtfeb.fsf@gnu.org> <87d3g56llz.fsf@stupidchicken.com> <8339h0tur0.fsf@gnu.org> <87ippvwtwx.fsf@stupidchicken.com> <83liurruz4.fsf@gnu.org> <87k4aaej7f.fsf@stupidchicken.com> <83ippusjej.fsf@gnu.org> <87vctuz6eb.fsf@stupidchicken.com> <837h69sw0h.fsf@gnu.org> <87liuptbmp.fsf@stupidchicken.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1313828077 5797 80.91.229.12 (20 Aug 2011 08:14:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 20 Aug 2011 08:14:37 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 20 10:14:33 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QughM-000453-EW for ged-emacs-devel@m.gmane.org; Sat, 20 Aug 2011 10:14:32 +0200 Original-Received: from localhost ([::1]:49691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QughL-0001sg-K6 for ged-emacs-devel@m.gmane.org; Sat, 20 Aug 2011 04:14:31 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:35798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QughI-0001sY-Qo for emacs-devel@gnu.org; Sat, 20 Aug 2011 04:14:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QughH-0006Zb-Gx for emacs-devel@gnu.org; Sat, 20 Aug 2011 04:14:28 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:43621) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QughH-0006ZQ-AZ for emacs-devel@gnu.org; Sat, 20 Aug 2011 04:14:27 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0LQ700900VZBK000@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Sat, 20 Aug 2011 11:14:25 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.126.49.191]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LQ7005TGW7Z6NU3@a-mtaout20.012.net.il>; Sat, 20 Aug 2011 11:14:25 +0300 (IDT) In-reply-to: <87liuptbmp.fsf@stupidchicken.com> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:143449 Archived-At: I've started a new topic, and suggest to have a separate one for each issue that was discussed under the old name. > From: Chong Yidong > Cc: Stefan Monnier , emacs-devel@gnu.org > Date: Fri, 19 Aug 2011 16:00:30 -0400 > > Here is one example: in Emacs Lisp source code, I want every Lisp string > to be treated as a single bidi segment (paragraph). The example of strings in program source was on the table since the beginning of this discussion, so it's obvious it should be supported. I actually meant to have a discussion about HTML/XML buffers. But even strings have some aspects that we never considered in enough detail. What about this use case (from C-like programming languages, but similar problems exist with `format' in Lisp)? printf ("ABCDEF %d\n", foo); If all we do is reorder the string as a single R2L paragraph, we get this jumble: printf ("d\n% FEDCBA", foo); which is simply illegible. And if we reorder it as a single L2R paragraph, we get this: printf ("FEDCBA %d\n", foo); which is a bit better, but still wrong. The correct display, that corresponds to how this will look on any bidi-aware display, would be this: printf ("%d FEDCBA\n", foo); Note that the correct rendering depends not only on the bidi types of characters in ABCDEF, but also in the characters produced by the format specifier. %d tells us exactly what these characters would be, but what if we had a %s specifier, which could be anything? Evidently, just following the cues from font-lock is not nearly enough to DTRT even in this very simple use case. For example, even if we want to decide whether to reorder as R2L or L2R paragraph, font-lock gives no clues. Also, Stefan mentioned Lisp symbols. Do we want to support symbols that use R2L characters? (One use case where it could be necessary are those Lisp packages that store arbitrary words as symbols.) If we do, just following font-lock will flood any Lisp buffer with text properties, with the net effect of slowing redisplay, even if none of the symbols use R2L characters, which will happen in the absolute majority of use cases. Again, following font-lock sounds like a design that doesn't scale well, and punishes the absolute majority of use cases for the benefit of a tiny fraction of them. That doesn't sound right to me.