unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: "... the window start at a meaningless point within a line."
Date: Tue, 27 Oct 2015 20:23:07 +0200	[thread overview]
Message-ID: <83fv0w41dg.fsf@gnu.org> (raw)
In-Reply-To: <20151027134025.GA2401@acm.fritz.box>

> Date: Tue, 27 Oct 2015 13:40:25 +0000
> Cc: emacs-devel@gnu.org
> From: Alan Mackenzie <acm@muc.de>
> 
> I haven't managed to get anywhere with this.  The code in
> Fvertical_motion is already quite complicated, due to the variable
> it_overshoot_count, and the various things that make it necessary, like
> `before-string' or `after-string' overlays with LFs in them.  If we add
> in code to correct for "actual" WS into the melee, the code could not
> help becoming even more difficult to understand.
> 
> What makes me less enthusiastic about the approach is that it only
> covers one case, that with (nlines > 0) where point is already within
> the first text line in the window (not before it).

In that case, it probably means I will have to do this.  Please send
the smallest patch that allows window-start to be where you want it,
and doesn't involve vertical-motion, together with some simple test
case to show what doesn't work in the unmodified vertical-motion.  I
will then come up with a fix for that function.

> I still feel that my approach, of analysing the buffer after
> Fvertical_motion has moved the nlines and correcting it's position, is
> the right one.  It separates this complexity from the rest of Fv_m.

I don't want to separate it, because vertical-motion already does
almost everything you need, AFAICT.  What you suggest would mean
significant duplication of code that is already quite tricky.  (Please
note that you for now tried to handle only the relatively simple case
of screen lines produced entirely from buffer text, no display or
overlay strings, no images, no display tables, no composed characters.
Most of the hair in vertical-motion's code is because of these use
cases.)

> I've spent some time looking at bidi.c and SAVE_IT, RESTORE_IT.  In
> essence, IIUC, the bidi cache that SAVE_IT saves belongs conceptually to
> a struct it, but is too big to be included in it.

Not only is it big (and theoretically can be as big as the largest
buffer Emacs can support), its size is not fixed: while the display
engine iterates through buffer text, it constantly enlarges and
shrinks the cache as needed (assuming there's bidirectional text; if
not, the cache is always exactly 1 or 2 slots long).  So it cannot be
part of the it structure.

> Would the following strategy for maybe_move_to_exact_bol work?
> o - Execute SAVE_IT on *it just once, right at the start.
> o - Calculate the target position using several struct it's, as
>   currently coded, ignoring bidi aspects.
> o - Execute RESTORE_IT on *it.
> o - Move *it to our target position.
> o - Set it->current_x and it->hpos to zero.

No, you cannot ignore bidi aspects.  The move_it_* functions work in
visual order, not in logical order.  So the bidi aspects are
inherently part of your use of those functions.

> How about putting maybe_move_to_exact_bol into xdisp.c, allowing it to
> use SAVE_IT and RESTORE_IT without exporting these two macros?

That's OK (assuming we need that function -- it looks too large for
such a simple job).  But that is a relatively minor problem.

> In fact, why not put Fvertical_motion into xdisp.c, too?  It would
> appear to have quite a lot to do with display, and not a lot to do
> with indentation.

I don't like moving such important functions between files, it
complicates forensics ("git annotate" etc.).  We have functions
elsewhere that use xdisp.c functionality, so it's not like indent.c is
the only one.

> Another point I'd appreciate clarification on.  Some while back, for
> example, your mail of Fri, 16 Oct 2015 20:26:08 +0300, we were talking
> about the order of screen positions varying non-linearly with buffer
> positions.  Is it true that if a continuation line begins at buffer
> position A, then for x < A, buffer position x will be displayed on a
> previous line?

By "continuation line" do you mean the 2nd, 3rd, etc. screen line of a
long physical line?  If so, the answer is NO, not in general (although
in practice it's almost always like you describe, even when bidi text
is in the buffer).

> (And also for x > A, x will be displayed on this line or a
> subsequent one?)

Also no.

IOW, the visual order is non-linear both in X and in Y directions.



  parent reply	other threads:[~2015-10-27 18:23 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30 20:45 "... the window start at a meaningless point within a line." Alan Mackenzie
2015-10-01  8:48 ` Eli Zaretskii
2015-10-01  9:41   ` Alan Mackenzie
2015-10-01 10:16     ` Eli Zaretskii
2015-10-01 11:02       ` Alan Mackenzie
2015-10-01 12:03         ` Eli Zaretskii
2015-10-01 16:35           ` Alan Mackenzie
2015-10-15 18:16           ` Alan Mackenzie
2015-10-15 20:14             ` Eli Zaretskii
2015-10-16  9:55               ` Alan Mackenzie
2015-10-16 10:19                 ` Eli Zaretskii
2015-10-16 15:19                   ` Alan Mackenzie
2015-10-16 17:26                     ` Eli Zaretskii
2015-10-16 20:46                       ` David Kastrup
2015-10-17  7:15                         ` Eli Zaretskii
2015-10-17  7:56                           ` David Kastrup
2015-10-16 21:14                       ` Alan Mackenzie
2015-10-16 17:35                 ` Eli Zaretskii
2015-10-16 18:12                   ` Alan Mackenzie
2015-10-16 18:23                     ` Eli Zaretskii
2015-10-16 18:36                       ` Eli Zaretskii
2015-10-16 20:12                       ` Alan Mackenzie
2015-10-17  8:33                         ` Eli Zaretskii
2015-10-17 11:57                           ` Alan Mackenzie
2015-10-17 12:34                             ` Eli Zaretskii
2015-10-17 13:31                               ` Eli Zaretskii
2015-10-17 14:22                                 ` Eli Zaretskii
2015-10-18 15:00                                   ` Alan Mackenzie
2015-10-18 17:44                                     ` Eli Zaretskii
2015-10-19 10:27                                       ` Alan Mackenzie
2015-10-27 13:40                                         ` Alan Mackenzie
2015-10-27 17:35                                           ` Alan Mackenzie
2015-10-27 18:33                                             ` Eli Zaretskii
2015-10-27 18:23                                           ` Eli Zaretskii [this message]
2015-10-28  8:58                                             ` Alan Mackenzie
2015-10-28 13:15                                             ` Alan Mackenzie
2015-10-31 13:21                                               ` Eli Zaretskii
2015-10-31 21:17                                                 ` Alan Mackenzie
2015-11-01  3:40                                                   ` Eli Zaretskii
2015-11-01 14:45                                                     ` Alan Mackenzie
2015-11-01 15:23                                                 ` Alan Mackenzie
2015-11-01 17:45                                                   ` Eli Zaretskii
2015-11-01 18:07                                                     ` Eli Zaretskii
2015-11-01 18:46                                                     ` Alan Mackenzie
2015-10-18 14:53                                 ` Alan Mackenzie
2015-10-18 17:46                                   ` Eli Zaretskii
2015-10-19 10:45                                     ` Alan Mackenzie
2015-10-19 10:56                                       ` Eli Zaretskii
2015-10-19 11:24                                         ` Alan Mackenzie
2015-10-19 11:28                                           ` Eli Zaretskii
2015-10-19 12:02                                             ` Alan Mackenzie
2015-10-19 12:33                                               ` Eli Zaretskii
2015-10-19 13:11                                                 ` Alan Mackenzie
2015-10-19 13:27                                                   ` Eli Zaretskii
2015-10-19 19:15                                                     ` Alan Mackenzie
2015-10-27 13:46                                                       ` Alan Mackenzie
2015-10-17 15:30                               ` Alan Mackenzie

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=83fv0w41dg.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.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).