unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: E Sabof <esabof@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 18923@debbugs.gnu.org
Subject: bug#18923: Alternative scrolling model
Date: Sun, 02 Nov 2014 18:25:28 +0000	[thread overview]
Message-ID: <87oaspa293.fsf@gmail.com> (raw)
In-Reply-To: <838ujty6ns.fsf@gnu.org>


Eli Zaretskii <eliz@gnu.org> writes:

>> From: E Sabof <esabof@gmail.com>
>> Date: Sun, 02 Nov 2014 02:31:28 +0000
>>
>> > Sounds nice.  Do you imagine it as a replacement for the existing
>> > scroll-up/down functions?  Or rather (at least at first) as a separate
>> > package?
>> > Also, if something's missing for st-height to get more accurate
>> > measurements, I suggest you make it a bug report asking for that missing
>> > info/feature.
>>
>> I was mostly thinking the first.
>
> If this is intended as a replacement for the existing functionality,
> then it needs to support all the features that the current code
> supports.  The list of those features should include at least the
> following:
>
>  . the argument to the commands can be nil, which means "almost the
>    full window", where "almost full" depends on the value of
>    next-screen-context-lines

Easy to implement naively, and heuristics should probably be considered.

>  . the auto-window-vscroll variable

I think the variable would no longer be useful with this approach.

>  . the scroll-preserve-screen-position option

Ideally I'd measure the pixel distance from the top and try to restore
it, but alternatives can be considered if this affects performance.

>  . signal an error at beginning and end of buffer, subject to the
>    value of scroll-error-top-bottom

I think I already have the code that determines this case, I just need
to throw errors.

>  . don't let point enter the scroll margin as result of scrolling
>
>  . the window's old_point marker needs to be set after scrolling

I don't fully understand these, but they don't seem too complicated.

> There's also a bug when scrolling near the end of buffer: the result
> is that the cursor us shown on a line beyond EOB, which should never
> happen.

I've noticed this. The point flashes at a wrong position, and then goes
back to "legal" position. I thought this was a display engine bug.

>> The only potentially downside I can think of
>> is that it might be slower -- then again I'm just measuring line-heights, and
>> of these there is (at most) only one line that won't eventually be displayed.
>
> It is indeed much slower.  I timed it on xdisp.c using Dmitry's
> scroll-up-benchmark function, and found this code to be 3 times slower
> than the current implementation.  Turning off font-lock slashes about
> 40% of the benchmark time, so CC mode fontifications are not the main
> reason for the slowdown.  If I compare the existing implementation
> with this one on xdisp.c with font-lock-mode turned off in both cases,
> this implementation is 16 times slower than what we have now.
>
> For the record, my timings are from an unoptimized build of a recent
> trunk, with your code byte-compiled.
>
> The general algorithm seems to be the same as in the current C
> implementation, so I doubt an ELisp implementation could match what we
> have in speed, let alone be faster.
>
> Now, I personally don't regard the scrolling command as something that
> needs to be lightning-fast (although others obviously do, see the
> on-going discussions on emacs-devel about that).  But in this case, a
> single PageDown keypress takes close to a second to execute, which is
> slow enough to annoy.  By contrast, the current implementation is
> almost instantaneous.  (Again, this is in an unoptimized build; an
> optimized build should be about twice faster, but I think 0.4 sec for
> a single scroll might still annoy.)

I'm aware of some inefficiencies in my code. My guess probably doesn't
mean much, but maybe something along 2X could be achieved.

> Finally, it looks like this code forces Emacs to display every single
> screen it scrolls through, even when it cannot keep up.  I guess
> that's due to the 'redisplay' calls.  This makes the situation where
> someone leans on the PageDown key and then releases it very
> unpleasant: Emacs keeps scrolling for a long time, and I didn't find a
> way of interrupting that.

st-move probably shouldn't call (redisplay) at all. I'll see if I can convert my comments to reproducible bugs.

>> If it were to remain mostly elisp, it would need a reliable way to measure the
>> height of a line (essentially a `st-height' replacement), irrespective of
>> whether it's displayed.
>
> Did you try to use pos-visible-in-window-p?  AFAIU, it gives you what
> you want, including for lines that are taller than the window.
>
>> It has also proven rather difficult to set the window
>> start "absolutely". I've documented my findings in `st-move'.
>
> Does this happen only when point is on an image?  (The comments in
> st-move seem to talk only about this situation.)  If so, could you
> show a simple test case to demonstrate the problem?

I think there are ~3 different bugs involved (vscroll not being displayed, vscroll being nullified, and the point-on-image cases). I'll see if I can describe
them better.

Evgeni





  reply	other threads:[~2014-11-02 18:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-02  1:15 bug#18923: Alternative scrolling model E Sabof
     [not found] ` <jwv61ey5qfb.fsf-monnier+emacsbugs@gnu.org>
     [not found]   ` <87vbmy9wdx.fsf@gmail.com>
2014-11-02  2:31     ` E Sabof
2014-11-02 15:16       ` Eli Zaretskii
2014-11-02 18:25         ` E Sabof [this message]
2014-11-02 18:36           ` Eli Zaretskii
     [not found]     ` <jwvioiy416g.fsf-monnier+emacsbugs@gnu.org>
     [not found]       ` <87sii1ahy9.fsf@gmail.com>
     [not found]         ` <jwvppd538tu.fsf-monnier+emacsbugs@gnu.org>
2014-11-02 23:10           ` E Sabof
2014-11-03  2:35             ` Stefan Monnier
2014-11-03 16:03               ` Eli Zaretskii
2014-11-03 19:02                 ` E Sabof
2014-11-02 15:14 ` Eli Zaretskii
2014-11-02 15:56   ` Stefan Monnier
2014-11-02 16:06     ` Eli Zaretskii
2014-11-02 16:21   ` E Sabof
2014-11-02 16:31     ` Eli Zaretskii
2014-11-02 17:43       ` E Sabof
2014-11-02 18:22         ` Eli Zaretskii
2014-11-02 19:09           ` E Sabof
2014-11-02 19:29             ` Eli Zaretskii
2014-11-03  3:45               ` Eli Zaretskii
2019-11-04  9:14 ` Stefan Kangas
2022-04-22 12:16 ` Lars Ingebrigtsen

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=87oaspa293.fsf@gmail.com \
    --to=esabof@gmail.com \
    --cc=18923@debbugs.gnu.org \
    --cc=eliz@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).