unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Scrolling in buffers with inline images / point outside viewport
@ 2013-06-09 16:56 Klaus-Dieter Bauer
  2013-06-09 17:19 ` Eli Zaretskii
  2013-06-09 19:00 ` David Engster
  0 siblings, 2 replies; 8+ messages in thread
From: Klaus-Dieter Bauer @ 2013-06-09 16:56 UTC (permalink / raw)
  To: emacs help

Hello!

TL;DR: Is it possible to have point outside the visible portion of the
buffer?

Scrolling in buffers with inline images can be awfully jerky: Images
invalidate the linear relation between lines and height on the screen to
the point where scrolling the mouse down once may skip several screens. As
my org-mode files often contain a series of output plots, this makes them
very hard to navigate with the mouse wheel and inconvenient to navigate
with the keyboard.

It can partly be solved, as demonstrated in [1], by doing smart positioning
of point. However, I can't think of a solution how to scroll when there are
images that are larger than the buffer height if after every scroll
operation point must be visible. The solution from [1] for instances gets
stuck at large images, unless one scrolls continously in which case
presumable Emacs do a redisplay during the scrolling, that would force the
viewport into a position that makes point visible.

Is there some way to get emacs allow an "out-of-viewport" point as usual in
modern GUI programs? This would allow to implement smoother scrolling with
images and allow the modern behaviour, where I can put the cursor to a
position, scroll down a couple of pages with the mouse wheel and
shift-click to select the region in between.

kind regards, Klaus

PS: Reducing the size of images with `org-image-actual-width' would be a
work-around but won't work in Windows, where the binaries come without
ImageMagick support (by which I mean being linked to use the IM library,
not calling imagemagick binaries -- that misunderstanding came up before).

---------------------------------
[1] http://www.randomsample.de/dru5/node/25


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-09 16:56 Scrolling in buffers with inline images / point outside viewport Klaus-Dieter Bauer
@ 2013-06-09 17:19 ` Eli Zaretskii
  2013-06-09 19:12   ` David Engster
  2013-06-09 19:00 ` David Engster
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2013-06-09 17:19 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com>
> Date: Sun, 9 Jun 2013 18:56:07 +0200
> 
> Is it possible to have point outside the visible portion of the
> buffer?

Yes.  You need to use vscroll.

> Scrolling in buffers with inline images can be awfully jerky: Images
> invalidate the linear relation between lines and height on the screen to
> the point where scrolling the mouse down once may skip several screens. As
> my org-mode files often contain a series of output plots, this makes them
> very hard to navigate with the mouse wheel and inconvenient to navigate
> with the keyboard.
> 
> It can partly be solved, as demonstrated in [1], by doing smart positioning
> of point. However, I can't think of a solution how to scroll when there are
> images that are larger than the buffer height if after every scroll
> operation point must be visible. The solution from [1] for instances gets
> stuck at large images, unless one scrolls continously in which case
> presumable Emacs do a redisplay during the scrolling, that would force the
> viewport into a position that makes point visible.
> 
> Is there some way to get emacs allow an "out-of-viewport" point as usual in
> modern GUI programs? This would allow to implement smoother scrolling with
> images and allow the modern behaviour, where I can put the cursor to a
> position, scroll down a couple of pages with the mouse wheel and
> shift-click to select the region in between.

See bug #14567.  Perhaps the changes proposed there is what you have
in mind (it's hard to tell because you don't describe a precise recipe
or use case).



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-09 16:56 Scrolling in buffers with inline images / point outside viewport Klaus-Dieter Bauer
  2013-06-09 17:19 ` Eli Zaretskii
@ 2013-06-09 19:00 ` David Engster
  2013-06-09 21:57   ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: David Engster @ 2013-06-09 19:00 UTC (permalink / raw)
  To: help-gnu-emacs

Klaus-Dieter Bauer writes:
> It can partly be solved, as demonstrated in [1], by doing smart positioning
> of point. However, I can't think of a solution how to scroll when there are
> images that are larger than the buffer height if after every scroll
> operation point must be visible. The solution from [1] for instances gets
> stuck at large images, unless one scrolls continously in which case
> presumable Emacs do a redisplay during the scrolling, that would force the
> viewport into a position that makes point visible.

Yes, I'm the guy who did this stuff. It's tricky, and I agree it's never
been working as well as it should be. It's been a while since I worked
on this, but I think the main problem in the end was that you'd need to
know the height of lines *before* they are rendered, which I think is
impossible in Emacs.

There's another problem with set-window-vscroll, which I did not mention
there: the further you go via vscroll, the slower it becomes until it's
pretty much unbearable. Don't even think of scrolling through large
buffers with this.

-David




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-09 17:19 ` Eli Zaretskii
@ 2013-06-09 19:12   ` David Engster
  0 siblings, 0 replies; 8+ messages in thread
From: David Engster @ 2013-06-09 19:12 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii writes:
> See bug #14567.  Perhaps the changes proposed there is what you have
> in mind (it's hard to tell because you don't describe a precise recipe
> or use case).

I've made two videos which can be downloaded here:

http://www.randomsample.de/dru5/node/26

It shows scrolling through an emacs-w3m buffers, which is horribly jerky
using normal Emacs scrolling. The second video shows scrolling which is
smoother, by keeping the point upwards of larger images and use vscroll
to scroll smoothly through them. The code is described here:

http://www.randomsample.de/dru5/node/25

-David




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-09 19:00 ` David Engster
@ 2013-06-09 21:57   ` Eli Zaretskii
  2013-06-10 15:53     ` David Engster
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2013-06-09 21:57 UTC (permalink / raw)
  To: help-gnu-emacs

> From: David Engster <deng@randomsample.de>
> Date: Sun, 09 Jun 2013 21:00:48 +0200
> 
> There's another problem with set-window-vscroll, which I did not mention
> there: the further you go via vscroll, the slower it becomes until it's
> pretty much unbearable. Don't even think of scrolling through large
> buffers with this.

I see no slowdown at all.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-09 21:57   ` Eli Zaretskii
@ 2013-06-10 15:53     ` David Engster
  2013-06-10 17:01       ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: David Engster @ 2013-06-10 15:53 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii writes:
>> From: David Engster <deng@randomsample.de>
>> Date: Sun, 09 Jun 2013 21:00:48 +0200
>> 
>> There's another problem with set-window-vscroll, which I did not mention
>> there: the further you go via vscroll, the slower it becomes until it's
>> pretty much unbearable. Don't even think of scrolling through large
>> buffers with this.
>
> I see no slowdown at all.

Well, it's been 5 years, maybe things have changed. I used to test it
this way: I opened my pretty long init file "~/.emacs" in a split frame
alongside the *scratch* buffer. In *scratch*, I evaluated this:

(with-selected-window (get-buffer-window ".emacs")
  (setq times-to-vscroll nil)
  (let (newval oldval)
    (setq oldval (float-time (current-time)))
    (dotimes (i 500)
      (setq newval (float-time (current-time)))
      (push (- newval oldval) times-to-vscroll)
      (setq oldval newval)
      (set-window-vscroll nil (+ (window-vscroll) 1))
      (redisplay t))))

I remember that this started quite fast with times well under a second
per scroll, but then grew up to 2 seconds or more at the end.

However, when I try this now, this code simply does not work; as soon as
the cursor leaves the viewport, it somehow resets back to the original
position. I have no idea what's going on.

-David




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-10 15:53     ` David Engster
@ 2013-06-10 17:01       ` Eli Zaretskii
  2013-06-11 19:40         ` David Engster
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2013-06-10 17:01 UTC (permalink / raw)
  To: help-gnu-emacs

> From: David Engster <deng@randomsample.de>
> Date: Mon, 10 Jun 2013 17:53:52 +0200
> 
> (with-selected-window (get-buffer-window ".emacs")
>   (setq times-to-vscroll nil)
>   (let (newval oldval)
>     (setq oldval (float-time (current-time)))
>     (dotimes (i 500)
>       (setq newval (float-time (current-time)))
>       (push (- newval oldval) times-to-vscroll)
>       (setq oldval newval)
>       (set-window-vscroll nil (+ (window-vscroll) 1))
>       (redisplay t))))
> 
> I remember that this started quite fast with times well under a second
> per scroll, but then grew up to 2 seconds or more at the end.
> 
> However, when I try this now, this code simply does not work; as soon as
> the cursor leaves the viewport, it somehow resets back to the original
> position. I have no idea what's going on.

Emacs won't let you use vscroll if the line with the cursor isn't at
least partially visible -- it will reset the vscroll to bring point
into view.

Try making the window with .emacs as tall as you can, and put the
cursor on its last line, before invoking the code above.  It works.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Scrolling in buffers with inline images / point outside viewport
  2013-06-10 17:01       ` Eli Zaretskii
@ 2013-06-11 19:40         ` David Engster
  0 siblings, 0 replies; 8+ messages in thread
From: David Engster @ 2013-06-11 19:40 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii writes:
>> From: David Engster <deng@randomsample.de>
>> However, when I try this now, this code simply does not work; as soon as
>> the cursor leaves the viewport, it somehow resets back to the original
>> position. I have no idea what's going on.
>
> Emacs won't let you use vscroll if the line with the cursor isn't at
> least partially visible -- it will reset the vscroll to bring point
> into view.
>
> Try making the window with .emacs as tall as you can, and put the
> cursor on its last line, before invoking the code above.  It works.

You are right, of course. This is why I did all this point-movement in
my visual scroll routines. I don't know why I was thinking this would
work.

I tried to reproduce the slowdown on scrolling very large images, but
failed, which is good. But instead of working on those old scroll
routines, I'll first try your patches in bug #14567 and follow-up there
if necessary.

-David




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2013-06-11 19:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-09 16:56 Scrolling in buffers with inline images / point outside viewport Klaus-Dieter Bauer
2013-06-09 17:19 ` Eli Zaretskii
2013-06-09 19:12   ` David Engster
2013-06-09 19:00 ` David Engster
2013-06-09 21:57   ` Eli Zaretskii
2013-06-10 15:53     ` David Engster
2013-06-10 17:01       ` Eli Zaretskii
2013-06-11 19:40         ` David Engster

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).