unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Po Lu <luangruo@yahoo.com>
Cc: emacs-devel@gnu.org
Subject: Re: Allowing point to be outside the window?
Date: Sun, 06 Feb 2022 13:34:17 +0200	[thread overview]
Message-ID: <83h79cz0sm.fsf@gnu.org> (raw)
In-Reply-To: <878ruoqx0u.fsf@yahoo.com> (message from Po Lu on Sun, 06 Feb 2022 15:22:57 +0800)

> From: Po Lu <luangruo@yahoo.com>
> Cc: emacs-devel@gnu.org
> Date: Sun, 06 Feb 2022 15:22:57 +0800
> 
> Po Lu <luangruo@yahoo.com> writes:
> 
> > To be completely clear, the "recenter around point" fallback you allude
> > to is the code under the `recenter' label in `redisplay_window',
> > correct?
> >
> > Please forgive me if this has been answered before, but I haven't been
> > working on this in a while, and my memory is already getting rusty.
> >
> > Thanks.
> 
> How about this: we recenter around the position of the first modified
> character?  Point isn't moved at all during that process.

It's very hard to keep a discussion with such long pauses.  I don't
even remember what we were discussing the last time and what issues
remained unresolved.

> +@vindex keep-point-visible
> +  If @code{keep-point-visible} is nil, redisplay will not move recenter
> +the display when the window start is changed.
> +
> +@vindex scroll-move-point
> +  If @code{scroll-move-point} is nil, scrolling commands will not move
> +point to keep it inside the visible part of the window.

Why do we need 2 flags?  Are they indeed orthogonal, or can we have a
single variable (perhaps with more than 2 states)?

> +** New variable 'keep-point-visible'.
> +This variable controls if redisplay will try to keep point visible
> +inside the window.
> +
> ++++
> +** New variable 'scroll-move-point'.
> +This variable controls if scrolling moves point to stay inside the
> +window.

This is waaaay too terse for such a significant change...

> --- a/lisp/pixel-scroll.el
> +++ b/lisp/pixel-scroll.el

Why do we need to have changes in pixel-scroll.el be part of this
changeset?  It makes the changes harder to review, and is not really
related to the changes in the display code.

> --- a/src/window.c
> +++ b/src/window.c
> @@ -5578,7 +5578,8 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
>       something like (scroll-down 1) with PT in the line before
>       the partially visible one would recenter.  */
>  
> -  if (!pos_visible_p (w, PT, &x, &y, &rtop, &rbot, &rowh, &vpos))
> +  if (!pos_visible_p (w, PT, &x, &y, &rtop, &rbot, &rowh, &vpos)
> +      && scroll_move_point)

Don't you need to test keep_point_visible as well here?  If not, why
not?

> @@ -5659,8 +5660,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
>  		  w->start_at_line_beg = true;
>  		  wset_update_mode_line (w);
>  		  /* Set force_start so that redisplay_window will run the
> -		     window-scroll-functions.  */
> -		  w->force_start = true;
> +		     window-scroll-functions, unless scroll_move_point is false,
> +		     in which case forcing the start will cause recentering.  */
> +		  w->force_start = scroll_move_point;

Should the logic of whether and how to obey the force_start flag be
confined to the display code, instead of having part of it here?  What
does it mean when you set the w->start point, but do NOT set the
w->force_start flag?

> @@ -5844,8 +5846,9 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
>        w->start_at_line_beg = (pos == BEGV || FETCH_BYTE (bytepos - 1) == '\n');
>        wset_update_mode_line (w);
>        /* Set force_start so that redisplay_window will run the
> -	 window-scroll-functions.  */
> -      w->force_start = true;
> +	 window-scroll-functions, unless scroll_move_point is false,
> +	 in which case forcing the start will cause recentering.  */
> +      w->force_start = scroll_move_point;

Same here.

> @@ -5857,7 +5860,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
>       even if there is a header line.  */
>    this_scroll_margin = window_scroll_margin (w, MARGIN_IN_PIXELS);
>  
> -  if (n > 0)
> +  if (scroll_move_point)

This and the rest of changes in window_scroll_pixel_based are
impossible to review: you replaced the "n > 0" condition with a
different one, and now the rest of the diffs are completely
unreadable.

I also don't understand how come the exact same code which was
previously run only for n > 0 is now run for any value of 'n', and
_by_default_ (since scroll_move_point is non-zero by default)?  How
can that be TRT??

> +  if (!keep_point_visible && window_outdated (w))
> +    {
> +      /* If some text changed between window start, then recenter the
> +	 display around the first character that changed, to avoid
> +	 confusing the user by not updating the display to reflect the
> +	 changes.  */
> +      ptrdiff_t last_changed_charpos, first_changed_charpos;
> +
> +      /* Make sure beg_unchanged and end_unchanged are up to date.  Do it
> +	 only if buffer has really changed.  The reason is that the gap is
> +	 initially at Z for freshly visited files.  The code below would
> +	 set end_unchanged to 0 in that case.  */
> +      if (GPT - BEG < BEG_UNCHANGED)
> +	BEG_UNCHANGED = GPT - BEG;
> +      if (Z - GPT < END_UNCHANGED)
> +	END_UNCHANGED = Z - GPT;

I'm not sure I understand this part.  Why do you need to change the
values of BEG_UNCHANGED and END_UNCHANGED -- those are supposed to be
changed only by code that modifies the buffer text.

> -	    /* -1 means we need to scroll.
> -	       0 means we need new matrices, but fonts_changed
> -	       is set in that case, so we will detect it below.  */
> -	    goto try_to_scroll;
> +	    {
> +	      /* -1 means we need to scroll.
> +		 0 means we need new matrices, but fonts_changed
> +		 is set in that case, so we will detect it below.  */
> +	      goto try_to_scroll;
> +	    }

These braces are redundant.

> +  /* Determine the window start relative to where we want to recenter
> +     to.  */
> +
> +  if (need_recenter_even_if_point_can_be_invisible)
> +    init_iterator (&it, w, that_recentering_position,
> +		   that_recentering_byte, NULL, DEFAULT_FACE_ID);
> +  else
> +    init_iterator (&it, w, PT, PT_BYTE, NULL, DEFAULT_FACE_ID);
>    it.current_y = it.last_visible_y;
> +

You want to display window around the change, but not bring point
there?  Is that a good idea?

> + maybe_try_window:

Why do we need this maybe_try_window stuff?  It seems to repeat
existing code, doesn't it?

Thanks.



  reply	other threads:[~2022-02-06 11:34 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ilwd7zaq.fsf.ref@yahoo.com>
2021-11-28  3:07 ` Allowing point to be outside the window? Po Lu
2021-11-28  8:03   ` Eli Zaretskii
2021-11-28  8:13     ` Po Lu
2021-11-28  8:41       ` Eli Zaretskii
2021-11-28 12:47         ` Po Lu
2021-11-28 12:58           ` Eli Zaretskii
2021-11-28 13:10             ` Po Lu
2021-11-28 13:44               ` Eli Zaretskii
2021-11-29  1:47                 ` Po Lu
2021-11-29 13:00                   ` Eli Zaretskii
2021-11-29 13:22                     ` Po Lu
2021-11-29 13:43                       ` Eli Zaretskii
2021-11-30  1:40                         ` Po Lu
2021-11-30 16:49                           ` [External] : " Drew Adams
2021-11-30 17:26                             ` Eli Zaretskii
2021-11-30 18:10                               ` Lars Ingebrigtsen
2021-11-30 18:32                                 ` Eli Zaretskii
2021-11-30 18:49                                 ` Stefan Kangas
2021-11-30 19:21                                   ` Eli Zaretskii
2021-11-30 20:57                                     ` Drew Adams
2021-11-30 23:41                                 ` Daniel Martín
2021-12-01  8:30                                   ` martin rudalics
2021-12-01  9:10                                     ` Juri Linkov
2021-11-30 23:20                               ` Stefan Monnier
2021-12-04 11:18                           ` Po Lu
2021-12-04 12:55                             ` Eli Zaretskii
2021-12-04 13:13                               ` Po Lu
2021-12-04 16:24                                 ` Eli Zaretskii
2021-12-05  0:40                                   ` Po Lu
2021-12-04 17:15                                 ` Eli Zaretskii
2021-12-05  0:45                                   ` Po Lu
2021-12-05  9:03                                     ` Eli Zaretskii
2021-12-06  2:11                                       ` Po Lu
2021-12-06 14:13                                         ` Eli Zaretskii
2021-12-07  2:18                                           ` Po Lu
2021-12-07 13:42                                             ` Eli Zaretskii
2021-12-08  1:17                                               ` Po Lu
2021-12-08 17:14                                                 ` Eli Zaretskii
2021-12-09  0:23                                                   ` Po Lu
2021-12-09  8:02                                                     ` Eli Zaretskii
2021-12-09  9:22                                                       ` Po Lu
2021-12-09 10:02                                                         ` Eli Zaretskii
2021-12-25  6:45                                                       ` Po Lu
2021-12-25  7:07                                                         ` Eli Zaretskii
2022-02-06  7:22                                                         ` Po Lu
2022-02-06 11:34                                                           ` Eli Zaretskii [this message]
2022-02-06 11:46                                                             ` Po Lu
2022-02-06 11:55                                                               ` Eli Zaretskii
2022-02-06 12:21                                                                 ` Po Lu
2022-02-06 16:15                                                                   ` Eli Zaretskii
2022-02-07  1:21                                                                     ` Po Lu
2022-02-07  7:21                                                                       ` Po Lu
2022-02-07 13:41                                                                         ` Eli Zaretskii
2022-02-07 13:57                                                                           ` Po Lu
2022-02-07 14:24                                                                             ` Eli Zaretskii
2022-02-08  0:58                                                                               ` Po Lu
2022-02-08 17:08                                                                                 ` Eli Zaretskii
2022-02-09  1:57                                                                                   ` Po Lu
2022-02-10 13:04                                                                                     ` Eli Zaretskii
2022-02-10 13:09                                                                                       ` Po Lu
2021-12-09 11:45                                         ` Eli Zaretskii
2021-12-09 12:19                                           ` Po Lu
2021-12-09 12:45                                             ` Eli Zaretskii
2021-12-04 13:00                             ` dick
2021-12-04 13:14                               ` tomas
2021-12-04 13:19                               ` Po Lu
2021-12-04 13:41                                 ` Eli Zaretskii
2021-12-05  0:46                                   ` Po Lu
2021-12-05  7:12                                     ` Eli Zaretskii
2021-12-05  7:16                                       ` Po Lu
2021-12-05  8:48                                         ` Eli Zaretskii
2021-12-05  9:15                                           ` Po Lu
2021-12-05  9:25                                             ` Eli Zaretskii
2021-12-05  9:31                                               ` Po Lu
2021-12-05 10:34                                                 ` Eli Zaretskii
2021-12-05 10:37                                                   ` Po Lu
2021-12-04 14:17                                 ` dick
2021-12-04 16:33                                   ` Eli Zaretskii
2021-12-04 17:13                                     ` dick
2021-12-05  0:48                                       ` Po Lu
2021-11-28 14:03       ` Alan Mackenzie
2021-11-28 14:28         ` Eric S Fraga
2021-11-28 14:39           ` Eli Zaretskii
2021-11-28 16:55             ` Eric S Fraga
2021-11-28 14:42         ` dick
2021-11-28 15:39         ` Kévin Le Gouguec
2021-11-28 15:45           ` Eli Zaretskii
2021-11-28 17:14             ` Kévin Le Gouguec
2021-11-28 16:59           ` Eric S Fraga
2021-11-28 17:30             ` Kévin Le Gouguec
2021-11-29  0:34             ` Dmitry Gutov
2021-11-29  0:34         ` Po Lu
2021-12-08  1:45           ` John Ankarström
2021-12-08 12:45             ` Eli Zaretskii
2021-12-08 13:33               ` John Ankarström
2021-12-08 13:38                 ` Po Lu
2021-12-08 13:52                   ` John Ankarström
2021-12-08 14:26                 ` Eli Zaretskii
2021-12-08 16:57                   ` Stefan Monnier
2021-12-08 19:29                     ` Yuri Khan
2021-12-09  0:16                     ` Po Lu
2021-12-08 19:21                 ` Rudolf Schlatte
2021-12-08 19:56                   ` Juri Linkov
2021-12-08 20:05                     ` André A. Gomes
2021-12-08 20:31                     ` Linux console scrollback [ Was: Allowing point to be outside the window? ] Alan Mackenzie
2021-12-09  0:17                   ` Allowing point to be outside the window? Po Lu
2021-12-08 22:25                 ` Kévin Le Gouguec
2021-12-08 23:17                   ` John Ankarström
     [not found] <9603C99D-97E7-4285-A1C1-022191B6F5CC@univie.ac.at>
2021-12-08 18:43 ` Konrad Podczeck
2021-12-08 20:47   ` John Ankarström
2021-12-09 15:34 Konrad Podczeck

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=83h79cz0sm.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    /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).