4

When the file (buffer) I have open in GNU Emacs (24) has fewer lines than can be displayed in the current window (frame), I can - by default - scroll down using the scroll bar and have the top lines disappear up ("overscroll").

How can I turn this off, so I can not scroll when the entire buffer is shown in the frame?

I can patch gtkutil.c in the Emacs sources but a more elegant solution would be nice.

3
  • I have clarified the question to mention scrolling using the scroll bar.
    – asjo
    May 27, 2012 at 18:11
  • 1
    You could just disable the scroll bar ;-) May 27, 2012 at 19:08
  • @Tass Then I don't have the nice visual gauge of how long the buffer is... :-)
    – asjo
    May 28, 2012 at 11:58

3 Answers 3

1

The behaviour of the scrollbar can now be modified by setting the variable scroll-bar-adjust-thumb-portion (to nil, for my purpose), here is the documentation:

scroll-bar-adjust-thumb-portion is a variable defined in `C source code'.
Its value is nil
Original value was t

Documentation:
Adjust thumb for overscrolling for Gtk+ and MOTIF.
Non-nil means adjust the thumb in the scroll bar so it can be dragged downwards
even if the end of the buffer is shown (i.e. overscrolling).
Set to nil if you want the thumb to be at the bottom when the end of the buffer
is shown.  Also, the thumb fills the whole scroll bar when the entire buffer
is visible.  In this case you can not overscroll.

[...] version 24.4 of Emacs.

Introduced with this commit: r111506.

-1

You need to add

(setq next-line-add-newlines nil)

to your init file.

2
  • No, that does not turn overscroll off. To see what I mean, open a new emacs, go to the scratch buffer and drag the scroll bar down - the first three/four lines scroll up. Setting next-line-add-newlines to nil does not change that (also, the default value is nil).
    – asjo
    May 27, 2012 at 18:08
  • Quite correct, I'm sorry to have misunderstood your question.
    – elemakil
    May 27, 2012 at 20:14
-1

AFAIK, you currently can't do that (tho you might be able to kludge it up, of course). Doing it right can be costly in CPU time, but more importantly it seems that it's more work to implement this "feature" than for people to get used to it and discover that it's really not a problem after all. So nobody has bothered to write a patch for it yet.

4
  • It confuses my eyes that a small file that is displayed in its entirety results in a scroll bar that is less than 100% tall - it is simply different from any other scroll bar in my life. Fixing that seems (from research into threads in emacs-devel in 2003 and 2009) to be a non-starter, so I was hoping that I could work around it by turning off overscroll.
    – asjo
    May 28, 2012 at 21:45
  • @asjo, actually this can be fixed easily, but only by introducing other downsides. E.g. by using another toolkit, or by making the thumb tiny while dragging it.
    – Stefan
    May 29, 2012 at 18:00
  • what happens when the scroll bar is dragged by the mouse doesn't matter much to me, I almost exclusively use it to gauge the size of the buffer (as in every other program with a scroll bar I use (I don't use vim :-))). I have patched gtkutil.c in my local Emacs to remove the *30 thing, but it would be nicer if the same effect could be achieved by configuration, I think. I don't know what the right way to that would be though (pointers welcome!)
    – asjo
    May 30, 2012 at 18:47
  • I have now whipped up a little patch to make the code block that the patch mentioned in my question optional depending on a variable: debbugs.gnu.org/cgi/bugreport.cgi?bug=1036#23
    – asjo
    Dec 2, 2012 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.