all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* scroll-margin - does it work as advertized?
@ 2009-02-15 20:29 Drew Adams
  2009-02-15 21:37 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2009-02-15 20:29 UTC (permalink / raw
  To: 'Emacs-Devel devel'; +Cc: andre.riemann

I've read the doc (Emacs and Elisp manuals, and doc string) for `scroll-margin',
and what I understand from that doc doesn't seem to correspond to the behavior I
see. If others don't think there is a bug, then perhaps someone can help me
understand better how this option works.

My understanding from the doc is that you cannot move the window point to within
`scroll-margin' lines of the top or bottom of the window - as soon as you try to
do so, the window is scrolled to move the window point `scroll-margin' lines
from the top or bottom.

What I see, however, is that the effective margin as I (mis?)understand it is
sometimes much smaller than the value of `scroll-margin'. And any
`scroll-margin' value greater than about 1/3 of the window height seems to give
the same effective margin. I see this in both Emacs 22 and 23 (which supports my
guess that I'm misunderstanding the doc).

If I set `scroll-margin' to 5 or 10, then, with a window-height of 39
(window-text-height of 38), I can move the window point to within 6 or 10 lines
of the top or bottom, but not to within 5 or 9 lines. That's about what I would
expect (I'd expect 10 instead of 9).

But if I set `scroll-margin' to 20 or 15 (same window height), then I can move
the window point to within 10 lines of the top or bottom, but not to within 8
(bottom) or 9 lines (top).

Similarly, with a window-height of 27 and a `scroll-margin' of 20, 15, or 10, I
can move the window point to within 7 lines of the top or bottom, but not to
within 6 lines. With a `scroll-margin' of 5, I get the behavior I'd expect:
can't get within 5 lines of the top/bottom.

That the window-height affects the behavior of `scroll-margin' doesn't surprise
me (though that fact and just how it affects it do not seem to be documented).
It's how it seems to affect it that puzzles me. I would expect that if the value
`scroll-margin' is >= half of the window height, then the cursor would just stay
in the middle of the window, since Emacs would try to keep the window point at
least `scroll-margin' from both top and bottom.

In one particular context, keeping the window point in the middle of the window
is the behavior I was looking for: keep the window point fixed relative to the
window, while scrolling the text relative to the window, when I move point.

That is somewhat like what `scroll-preserve-screen-position' does, but for
point-movement commands, not scroll commands. I wanted the window point's line
to remain fixed wrt the window, regardless of how I move point relative to the
buffer. IOW, in this particular context, I want the window to follow the cursor
as I move point, and I want the window point's line to remain constant.

What is a good way to get that behavior using vanilla Emacs? I've since found a
couple of things on Emacs Wiki that offer this behavior, in particular this
library:
http://www.emacswiki.org/cgi-bin/emacs/centered-cursor-mode.el, by Andre
Riemann. It keeps the cursor centered in the window, as you move point.

That library does what I was looking for. But beyond meeting that particular use
case, I wonder what I'm missing wrt how `scroll-margin' works, or should work.






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

* Re: scroll-margin - does it work as advertized?
  2009-02-15 20:29 scroll-margin - does it work as advertized? Drew Adams
@ 2009-02-15 21:37 ` Stefan Monnier
  2009-02-15 21:51   ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2009-02-15 21:37 UTC (permalink / raw
  To: Drew Adams; +Cc: andre.riemann, 'Emacs-Devel devel'

> I've read the doc (Emacs and Elisp manuals, and doc string) for
> `scroll-margin', and what I understand from that doc doesn't seem to
> correspond to the behavior I see.  If others don't think there is
> a bug, then perhaps someone can help me understand better how this
> option works.

I don't have time to dig into it, but IIUC this part of the code has
historically been difficult to implement correctly (as well as to figure
out the detailed meaning of each such option and how it should interact
with others).

So, my money's on the "bug" or "misfeature" explanation.


        Stefan




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

* RE: scroll-margin - does it work as advertized?
  2009-02-15 21:37 ` Stefan Monnier
@ 2009-02-15 21:51   ` Drew Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Drew Adams @ 2009-02-15 21:51 UTC (permalink / raw
  To: 'Stefan Monnier'; +Cc: andre.riemann, 'Emacs-Devel devel'

> > I've read the doc (Emacs and Elisp manuals, and doc string) for
> > `scroll-margin', and what I understand from that doc doesn't seem to
> > correspond to the behavior I see.  If others don't think there is
> > a bug, then perhaps someone can help me understand better how this
> > option works.
> 
> I don't have time to dig into it, but IIUC this part of the code has
> historically been difficult to implement correctly (as well 
> as to figure out the detailed meaning of each such option and how it 
> should interact with others).
> 
> So, my money's on the "bug" or "misfeature" explanation.

Thanks for the confirmation, at least.

Too bad about the buggy behavior and the doc mismatch. Apparently this has been
a problem since the introduction of the feature (`scroll-margin' etc.) in Emacs
22. If no one has the time to understand it and fix it, perhaps this code should
be reverted to pre-Emacs 22?





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

end of thread, other threads:[~2009-02-15 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-15 20:29 scroll-margin - does it work as advertized? Drew Adams
2009-02-15 21:37 ` Stefan Monnier
2009-02-15 21:51   ` Drew Adams

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.