From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r105429: New function `string-mark-left-to-right' for handling LRMs. Date: Thu, 11 Aug 2011 15:01:16 -0400 Message-ID: <87aabfojr7.fsf@stupidchicken.com> References: <83ei0sy7jk.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1313089299 30520 80.91.229.12 (11 Aug 2011 19:01:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 11 Aug 2011 19:01:39 +0000 (UTC) Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 11 21:01:35 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 1QraVZ-0006sz-OU for ged-emacs-devel@m.gmane.org; Thu, 11 Aug 2011 21:01:33 +0200 Original-Received: from localhost ([::1]:52579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QraVZ-0005Yn-CL for ged-emacs-devel@m.gmane.org; Thu, 11 Aug 2011 15:01:33 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:39212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QraVT-0005Yc-8c for emacs-devel@gnu.org; Thu, 11 Aug 2011 15:01:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QraVP-0002MA-Hp for emacs-devel@gnu.org; Thu, 11 Aug 2011 15:01:27 -0400 Original-Received: from vm-emlprdomr-03.its.yale.edu ([130.132.50.144]:59509) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QraVL-0002Ly-Fb; Thu, 11 Aug 2011 15:01:19 -0400 Original-Received: from furball (dhcp-128-36-14-148.central.yale.edu [128.36.14.148]) (authenticated bits=0) by vm-emlprdomr-03.its.yale.edu (8.14.4/8.14.4) with ESMTP id p7BJ1H2H013430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Thu, 11 Aug 2011 15:01:17 -0400 In-Reply-To: (Eli Zaretskii's message of "Thu, 11 Aug 2011 00:48:39 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-Scanned-By: MIMEDefang 2.71 on 130.132.50.144 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 130.132.50.144 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:143146 Archived-At: Eli Zaretskii writes: >> This algorithm (which the code implements) is wrong: the unwanted >> reordering can happen even if the string does not end in a strong R >> character. It could end in a series of weak characters, if the strong >> character preceding that is R, for example. OK, so basically we have to scan the entire string like this, right? (let ((len (length str)) (n 0) rtl-found) (while (and (not rtl-found) (< n len)) (setq rtl-found (memq (get-char-code-property (aref str n) 'bidi-class) '(R AL)) n (1+ n))) (if rtl-found (concat str (propertize (string ?\x200e) 'invisible t)) str))) > And since buffer-menu.el was already modified to use this function, it > is easy to see how this algorithm fails: make a buffer whose name is > made of all R2L characters with the "<1>" tail appended, then type > "C-x C-b" and watch the messed-up display. The original code treated > this case correctly. Actually, it looks as though the <1> is not treated properly, even with the old code. If I do (rename-buffer (concat "=D8=A7=D9=84=D8=B3=D9=91=D9=84=D8=A7=D9=85 =D8= =B9=D9=84=D9=8A=D9=83=D9=85" "<1>")) then the buffer is displayed as 1>[some Arabic text]>, both in the mode-line and in the buffer menu. I guess the code that appends the "" needs to use string-mark-left-to-right as well. For extra hilarity, get rid of the newline in this code fragment and watch as the redisplayed Emacs Lisp code turns into gibberish...