unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: lekktu@gmail.com, 6671@debbugs.gnu.org
Subject: bug#6671: moving point and scroll-conservatively
Date: Thu, 24 Mar 2011 03:23:44 -0400	[thread overview]
Message-ID: <E1Q2etU-00085t-Hi@fencepost.gnu.org> (raw)
In-Reply-To: <87tyetb258.fsf@stupidchicken.com> (message from Chong Yidong on Wed, 23 Mar 2011 23:58:27 -0400)

> From: Chong Yidong <cyd@stupidchicken.com>
> Date: Wed, 23 Mar 2011 23:58:27 -0400
> Cc: 6671@debbugs.gnu.org
> 
> After playing around with the "C-n in xdisp.c" testcase with the changes
> in revision 100619/100620 reverted, I think I know the problem.
> 
> In this test case, recentering seems to be triggered by redisplay-time
> fontification.  To demonstrat this, set fontification-functions to nil
> in xdisp.c, before initiating the C-n testcase.  For me, at least, the
> anomalous recentering then does not occur.

Sorry, but phenomenological explanations shouldn't be accepted in this
case.  We need specific evidence, and the only way to show that is by
adding the necessary tracing code and showing the results.

For example, I suggest to try introducing artificial delays (with
`nanosleep' or some such) into redisplay, and trying then, with
fontification-functions disabled.  You may find out (as I did at the
time) that fontification is just a trigger, not the cause itself; the
cause is more computations done during redisplay, which cause the
display engine bail out prematurely (unless you turn on
redisplay-dont-pause), which is yet another cause of recentering.

> The precise mechanism by which the fontification functions screw things
> up is by narrowing the buffer.  This is why, in last year's thread, the
> buffer's clip_changed flag was found to be set.  That forces recentering
> in redisplay_window (xdisp.c:14159).

Well, it shouldn't.  Instead of "fixing" the code by preventing this
flag to be set based on some heuristics, we should make the code DTRT
even if the flag is set (assuming that this indeed is the root cause
of the recentering in its all incarnations, which I'm not sure about).

Please note that I'm not convinced that the issue of fontification and
the clip_changed flag is relevant to the issue at hand.  Recentering
has more than one reason, so you could be seeing one of the other
ones.  We shouldn't mix them, if we want to remain sane and leave our
display code maintainable.

> So, a good fix might be to check whether redisplay-time fontification
> changes the buffer's restrictions, and, if so, reset the clip_changed
> flag.  That should make the 100619/100620 changes unnecessary.

Please don't revert these changes.  They took a lot of effort to
arrive at, and generally DTRT in a way that is easy to understand and
maintain.

The problem with performance for large moves of point is IMO
straightforward to fix: when point is "far away" (which could be set
back to those proverbial 10 screen lines), then, instead of moving one
line at a time, move to point in one go, and then compute the window
start so that point is at the proper place relative to window start.
That proper place depends on the variables that try_scrolling
considers already, like scroll-conservatively etc.  The problem is, it
considers them too early, before we realize that point is too far
away.  When we do realize that, we are already past the code that
computes the scroll according to those variables, and all we do is
punt and recenter.

So the fix would be to re-arrange the code in try_scrolling so that
the decision to move far away and the move itself are done _before_ we
consider the adjustments of window start according to the
scroll-related variables.

IOW, we are suffering from historical legacy in redisplay here.
Originally, Emacs always recentered.  Then the various scrolling
options were introduced, but the code is still structured so that it
eventually falls back on recentering.  We should change that so that
whatever happens, after catching up with point we compute the window
start according to user expectations expressed through the scroll-*
options.  That would eliminate the recentering fallback completely,
and finally put this issue to rest.





  reply	other threads:[~2011-03-24  7:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <83pqzec9i8.fsf@gnu.org>
2010-07-19 20:25 ` bug#6671: moving point and scroll-conservatively Juanma Barranquero
2010-08-02  0:29   ` Juanma Barranquero
2011-03-24  0:42   ` Chong Yidong
2011-03-24  2:07     ` Juanma Barranquero
2011-03-24  3:58       ` Chong Yidong
2011-03-24  7:23         ` Eli Zaretskii [this message]
2011-03-24 15:14           ` Chong Yidong
2011-03-24 20:01             ` Chong Yidong
2011-03-24 20:25               ` Eli Zaretskii
2011-03-24 20:57                 ` Juanma Barranquero
2011-03-24 21:36                 ` Chong Yidong
2011-03-25  9:13                   ` Eli Zaretskii
2011-03-25 15:58                     ` Chong Yidong
2011-03-24 20:56               ` Juanma Barranquero
2011-03-24 21:47                 ` Chong Yidong
2011-03-24 23:06                   ` Juanma Barranquero
2011-03-25  2:09                     ` Chong Yidong
2011-03-25  8:48                       ` Eli Zaretskii
2011-03-25  9:45                         ` Eli Zaretskii
2011-03-25 11:10                         ` Juanma Barranquero
2011-03-25  9:44                       ` Eli Zaretskii
2011-03-25  9:32             ` Eli Zaretskii
2011-03-26 12:32         ` Eli Zaretskii
2011-03-27  2:39           ` Juanma Barranquero
2011-03-27  3:59             ` Eli Zaretskii
2011-03-28 23:00               ` Juanma Barranquero
2011-03-29  4:03                 ` Eli Zaretskii
2011-03-29 10:54                   ` Juanma Barranquero
2011-03-29 12:42                     ` Eli Zaretskii
2011-03-31 19:19                 ` Eli Zaretskii
2011-03-24  7:25     ` Eli Zaretskii

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=E1Q2etU-00085t-Hi@fencepost.gnu.org \
    --to=eliz@gnu.org \
    --cc=6671@debbugs.gnu.org \
    --cc=cyd@stupidchicken.com \
    --cc=lekktu@gmail.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).