From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Line wrap reconsidered Date: Fri, 29 May 2020 09:56:34 +0300 Message-ID: <83r1v3qlel.fsf@gnu.org> References: <92FF4412-04FB-4521-B6CE-52B08526E4E5@gmail.com> <878shfsq35.fsf@gnus.org> <83imgivjak.fsf@gnu.org> <83lfletr03.fsf@gnu.org> <4895C6EE-5E1F-44BF-93C1-CC5F7C096F73@gmail.com> <9766BA3D-B8F9-456B-9F59-60D21B86E390@gmail.com> <83sgfls2ul.fsf@gnu.org> <83v9kgq6jy.fsf@gnu.org> <5E75D1E2-8BFF-45DA-A643-40DBD5784508@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="15043"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 29 08:57:17 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jeYxB-0003oY-Kb for ged-emacs-devel@m.gmane-mx.org; Fri, 29 May 2020 08:57:17 +0200 Original-Received: from localhost ([::1]:48390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeYxA-0005it-K2 for ged-emacs-devel@m.gmane-mx.org; Fri, 29 May 2020 02:57:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeYwe-0005JP-6W for emacs-devel@gnu.org; Fri, 29 May 2020 02:56:44 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49710) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeYwd-0002rC-Rh; Fri, 29 May 2020 02:56:43 -0400 Original-Received: from [176.228.60.248] (port=2020 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jeYwb-0007oF-6b; Fri, 29 May 2020 02:56:42 -0400 In-Reply-To: <5E75D1E2-8BFF-45DA-A643-40DBD5784508@gmail.com> (message from Yuan Fu on Thu, 28 May 2020 15:34:28 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:251606 Archived-At: > From: Yuan Fu > Date: Thu, 28 May 2020 15:34:28 -0400 > Cc: larsi@gnus.org, > emacs-devel@gnu.org > > In the current code IT_DISPLAYING_WHITESPACE can check for can_wrap_before and can_wrap_after in the same time, but in my new code, we have to perform two checks in the same iteration, because some char can wrap before but now after, and some can wrap after but not before, etc. Then you'll need to augment the test else if (may_wrap) with a test that the current character can be at BOL. Maybe you should also make may_wrap a tristate instead of just a boolean YES/NO. > > Which "continue" are you alluding to here? Do you mean "lines are > > continued"? because if lines are not being wrapped, we have only one > > choice: go back to the last wrap point we found, end the screen line > > (a.k.a. "break the line") there, and continue with the text on the > > next screen line. > > I think there is another option where we wrap at current point. On line 23356: > > /* If line-wrap is on, check if a > previous wrap point was found. */ > else if (wrap_row_used > 0 > /* Even if there is a previous wrap > point, continue the line here as > usual, if (i) the previous character > was a space or tab AND (ii) the > current character is not. */ > && (!may_wrap > || IT_DISPLAYING_WHITESPACE (it))) > goto back_to_wrap; > > I was alluding to this “continue”: “continue the line here as usual”. What does it mean? Does it mean we insert a line break here? I think your response below confirms my guess. Yes, "continue the line" here means we break the line here instead of going back to the wrap point. This code handles the case when there's a previous wrap point, but the current character fits exactly on the line, and that current character is a TAB or SPC. > > I mean the indentation: the original code used TABs and spaces, but > > your code uses only spaces. > > How do I fix it? Any guideline file? Just make sure indent-tabs-mode is non-nil when you edit C files. > >> and the redisplay iterator will still go through them LTR > > > > Not sure what you mean by "go through them LTR". The iterator can > > move forward or backward, or even jump to a far-away place. You > > cannot assume that the next character examined will be the next > > character in the buffer. > > Essentially I want to ask “if may_wrap == true, what does that mean? (In bidi context)” Did the character to the left of me (on glass) set it or the character to the right of me set it? The one to the left. But it is not necessarily the "previous" character in buffer position order. > Actually, I just tried again and the code works for bidi. Maybe last time I didn’t turned on word-wrap while thinking I did. You need to try both with bidi-paragraph-direction set to left-to-right and right-to-left. If both work, then the code is OK.