From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: emacs 24's forward-char vs right-char behavior Date: Wed, 25 Apr 2012 11:21:04 +0300 Message-ID: <83ehrcfci7.fsf@gnu.org> References: <379c8837-79c2-4692-8103-0bfa473f221e@wp13g2000pbb.googlegroups.com> <6251ec09-a82e-4843-9b52-1074dc20eaf1@a8g2000pbe.googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: dough.gmane.org 1335342089 16369 80.91.229.3 (25 Apr 2012 08:21:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 25 Apr 2012 08:21:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Apr 25 10:21:29 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SMxTZ-0003jl-7c for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Apr 2012 10:21:25 +0200 Original-Received: from localhost ([::1]:60000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMxTY-0001Lr-Ed for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Apr 2012 04:21:24 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:37938) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMxTP-0001LZ-Qz for help-gnu-emacs@gnu.org; Wed, 25 Apr 2012 04:21:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMxTJ-00086g-KY for help-gnu-emacs@gnu.org; Wed, 25 Apr 2012 04:21:15 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:41200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMxTJ-00086c-C3 for help-gnu-emacs@gnu.org; Wed, 25 Apr 2012 04:21:09 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0M31005000FN5800@a-mtaout23.012.net.il> for help-gnu-emacs@gnu.org; Wed, 25 Apr 2012 11:20:48 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([84.229.249.186]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M31005P20IO1S50@a-mtaout23.012.net.il> for help-gnu-emacs@gnu.org; Wed, 25 Apr 2012 11:20:48 +0300 (IDT) In-reply-to: <6251ec09-a82e-4843-9b52-1074dc20eaf1@a8g2000pbe.googlegroups.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.175 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:84625 Archived-At: > From: Xah Lee > Date: Wed, 25 Apr 2012 00:43:22 -0700 (PDT) >=20 > Now, paste this sentence in emacs =E2=80=9C(=D9=83=D8=AA=D8=A7=D8= =A8 =D8=A3=D9=84=D9=81 =D9=84=D9=8A=D9=84=D8=A9 =D9=88 =D9=84=D9=8A= =D9=84=D8=A9)=E2=80=9D. Then, hold > down right arrow key (which is bound to =E2=80=9Cright-char=E2=80= =9D), then when > cursor moves into the Arabic text, it'll suddenly reverse direction= , > and move right to left, until it reaches the left most arabic char > sequence, it'll jump back to the english text and continue move rig= ht. >=20 > Now, do the same but using =E2=80=9Cforward-char=E2=80=9D =E3=80= =90Ctrl+f=E3=80=91. Actually, the same > behavior is observed visually! >=20 > from Eli's post, it seems to be the expected behavior. Indeed, expected behavior. > But then what's the difference of forward-char and right-char? Am > totally confused now. Don't feel bad: this bidi business is complicated, especially for someone who is not a native speaker of one of the bidi languages. To see the difference between forward-char and right-char, do this: emacs -Q C-x b foo RET Now paste the string "(=D9=83=D8=AA=D8=A7=D8=A8 =D8=A3=D9=84=D9=81 = =D9=84=D9=8A=D9=84=D8=A9 =D9=88 =D9=84=D9=8A=D9=84=D8=A9)" into the b= uffer "foo" you just created, and then try both C-f and . See the difference now? Explanation: the difference only shows up in paragraphs whose "base direction" is right-to-left. (See the Emacs manual's "Bidirectional Editing" node for more about this.) In the *scratch* buffer, all paragraphs are forced to be left-to-right, because *scratch* is mostl= y used for code snippets. When you create a new buffer "foo", its default value of bidi-paragraph-direction is nil, which means Emacs determines the direction from the text of the paragraph. Pasting Arabic text causes Emacs to treat the paragraph as right-to-left and render it starting at the right margin of the window. As a side effect, that affects the behavior of vs forward-char. > In emacs 23, holding right arrow (or Ctrl+f) simply move cursor to = the > right, ALWAYS. I was expecting this from emacs 24's =E2=80=9Cright-= char=E2=80=9D. Type "C-h k ", and you will see that the commands bound to thi= s key in Emacs 23 and Emacs 24 are different. Then follow the link to the code of right-char in Emacs 24, and look at its definition. I think the code is self-explanatory.