unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Yuan Fu <casouri@gmail.com>
Cc: larsi@gnus.org, emacs-devel@gnu.org
Subject: Re: Line wrap reconsidered
Date: Fri, 29 May 2020 09:56:34 +0300	[thread overview]
Message-ID: <83r1v3qlel.fsf@gnu.org> (raw)
In-Reply-To: <5E75D1E2-8BFF-45DA-A643-40DBD5784508@gmail.com> (message from Yuan Fu on Thu, 28 May 2020 15:34:28 -0400)

> From: Yuan Fu <casouri@gmail.com>
> 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.



  parent reply	other threads:[~2020-05-29  6:56 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 18:13 Line wrap reconsidered Yuan Fu
2020-05-25 19:23 ` Eli Zaretskii
2020-05-25 19:31   ` Yuan Fu
2020-05-26  1:55   ` Ihor Radchenko
2020-05-26 12:55     ` Joost Kremers
2020-05-26 13:35       ` Yuan Fu
2020-05-26 14:47     ` Eli Zaretskii
2020-05-26 15:01       ` Ihor Radchenko
2020-05-26 15:29         ` Eli Zaretskii
2020-05-26 15:46           ` Ihor Radchenko
2020-05-26 16:29             ` Eli Zaretskii
2020-05-26 15:59       ` Stefan Monnier
2020-05-26 16:31         ` Eli Zaretskii
2020-05-26 16:43           ` Yuan Fu
2020-05-26 16:43             ` Ihor Radchenko
2020-05-26 18:57             ` Eli Zaretskii
2020-05-26 19:10               ` Yuan Fu
2020-05-26 19:59                 ` Eli Zaretskii
2020-05-26 19:12               ` Ihor Radchenko
2020-05-26 20:04                 ` Eli Zaretskii
2020-05-26 21:01                   ` Stefan Monnier
2020-05-25 19:31 ` Stefan Monnier
2020-05-25 19:51   ` Yuan Fu
2020-05-25 20:43 ` Lars Ingebrigtsen
2020-05-25 23:26   ` Yuan Fu
2020-05-25 23:32     ` Yuan Fu
2020-05-26  2:15       ` Yuan Fu
2020-05-26  3:30         ` Yuan Fu
2020-05-26  4:46           ` Yuan Fu
2020-05-26 15:14             ` Eli Zaretskii
2020-05-26 15:00           ` Eli Zaretskii
2020-05-26 14:54       ` Eli Zaretskii
2020-05-26 17:34         ` Yuan Fu
2020-05-26 19:50           ` Eli Zaretskii
2020-05-26 20:31             ` Yuan Fu
2020-05-26 22:29               ` Yuan Fu
2020-05-27 17:29                 ` Eli Zaretskii
2020-05-28 17:31                   ` Yuan Fu
2020-05-28 18:05                     ` Eli Zaretskii
2020-05-28 19:34                       ` Yuan Fu
2020-05-28 20:42                         ` Yuan Fu
2020-05-29  7:17                           ` Eli Zaretskii
2020-05-29  6:56                         ` Eli Zaretskii [this message]
2020-05-29 21:20                           ` Yuan Fu
2020-05-30  6:14                             ` Eli Zaretskii
2020-05-31 17:39                               ` Yuan Fu
2020-05-31 17:55                                 ` Eli Zaretskii
2020-05-31 18:23                                   ` Yuan Fu
2020-05-31 18:47                                     ` Eli Zaretskii
2020-06-18 21:46                                       ` Yuan Fu
2020-06-19  6:17                                         ` Eli Zaretskii
2020-06-19 12:04                                           ` Yuan Fu
2020-06-19 12:38                                             ` Eli Zaretskii
2020-06-19 17:22                                               ` Yuan Fu
2020-06-19 17:47                                                 ` Eli Zaretskii
2020-06-19 18:03                                                   ` Yuan Fu
2020-06-19 18:34                                                     ` Eli Zaretskii
2020-07-12 17:25                                                       ` Yuan Fu
2020-07-12 18:27                                                         ` Eli Zaretskii
2020-07-12 19:28                                                           ` Yuan Fu
2020-07-13 19:46                                                             ` Yuan Fu
2020-07-18  8:15                                                               ` Eli Zaretskii
2020-07-18 17:14                                                                 ` Yuan Fu
2020-07-18 19:49                                                                   ` Yuan Fu
2020-07-18 20:25                                                                   ` Stefan Monnier
2020-07-19 14:52                                                                   ` Eli Zaretskii
2020-07-19 16:16                                                                     ` Yuan Fu
2020-07-19 16:17                                                                       ` Yuan Fu
2020-08-13 19:35                                                                         ` Yuan Fu
2020-08-14  5:55                                                                           ` Eli Zaretskii
2020-08-14 15:08                                                                             ` Yuan Fu
2020-08-15  9:10                                                                               ` Eli Zaretskii
2020-08-15 13:10                                                                                 ` Fu Yuan
2020-08-15 14:56                                                                                   ` Eli Zaretskii
2020-08-15 17:34                                                                                     ` Yuan Fu
2020-08-15 17:46                                                                                       ` Eli Zaretskii
2020-08-15 18:00                                                                                         ` Yuan Fu
2020-08-15 18:47                                                                                           ` Eli Zaretskii
2020-08-16  3:22                                                                                             ` Yuan Fu
2020-08-16 14:15                                                                                               ` Eli Zaretskii
2020-08-16 17:31                                                                                                 ` Yuan Fu
2020-08-22  7:42                                                                                                   ` Eli Zaretskii
2020-08-22 20:58                                                                                                     ` Yuan Fu
2020-08-23  7:12                                                                                                       ` Eli Zaretskii
2020-08-24 14:00                                                                                                         ` Yuan Fu
2020-05-27 15:20               ` Eli Zaretskii
2020-05-26  8:02 ` martin rudalics
2020-05-26 12:38   ` Yuan Fu

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83r1v3qlel.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=casouri@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).