emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allowing point to be outside the window?


From: Po Lu
Subject: Re: Allowing point to be outside the window?
Date: Thu, 09 Dec 2021 08:23:28 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Po Lu <luangruo@yahoo.com>
>> Cc: emacs-devel@gnu.org
>> Date: Wed, 08 Dec 2021 09:17:13 +0800
>> 
>>       /* We used to issue a CHECK_MARGINS argument to try_window here,
>>       but this causes scrolling to fail when point begins inside
>>       the scroll margin (bug#148) -- cyd  */
>>       clear_glyph_matrix (w->desired_matrix);
>>       if (!try_window (window, startp, 0))
>>      {
>>        w->force_start = true;
>>        clear_glyph_matrix (w->desired_matrix);
>>        goto need_larger_matrices;
>>      }
>> 
>> Why does it have to force start?
>
> Because the place for the window-start was given to us (this code is
> under the 'if (w->force_start)' condition), but we've reset the flag
> after checking the condition, so now we are putting the flag back, for
> the next redisplay cycle -- since we are abandoning this cycle.
>
>> Doesn't need_larger_matrices take care of resizing the matrix when,
>> for instance, fonts change?
>
> need_larger_matrices indeed resizes the glyph matrices, after aborting
> the redisplay cycle with the old matrices, but that doesn't mean that
> window-start is invalid, it just means the previous glyph matrices
> were not large enough, e.g., because some part of the displayed text
> now has a different face that uses a smaller font.
>
> Basically, the strategy of redisplay_window, after some initial
> bookkeeping, is to go through a series of steps, whereby if a step
> succeeds, we are done, otherwise we go to the next step.  The steps
> are:
>
>   . if nothing's changed except point, and point is still inside the
>     same window, no need to do anything except redisplay the cursor;
>   . try using the window-start that someone else told us to use
>   . try using the same window-start as the previous redisplay, reusing
>     as much of the current glyph matrix as possible
>   . try using the same window-start as the previous redisplay, after
>     correcting it in small ways (like, for example, to move point out
>     of the scroll margin)
>   . recompute the window-start anew using point as the reference
>   . in each case, redisplay the parts of the window using the
>     window-start we found
>
> So, as you see, a lot of the processing is dedicated to finding a good
> window-start point, which is why if someone told us where to put it,
> we prefer to stick to that.  Besides, that someone could be the user
> via one of the scroll commands, and in that case the window-start we
> were given is mandatory.

> That's not what I had in mind.  What I had in mind was the situation
> where point is outside of the window, and the portion of the buffer
> shown in the window changes due to something that Emacs does.  If you
> are saying that in all such situation we will bring point back into
> the window, then my concern is addressed; but if not, we will not be
> able to use the final fallback of recentering the window around point,
> because that would move the window instead of redrawing the visible
> portion of the buffer.

If point doesn't change, but something in the visible part of the buffer
does, that part will be redrawn, keeping point and window start in their
original locations.

But maybe we should make it move point back into the window under this
situation.  WDYT?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]