help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .emacs to keep cursor stationary when scrolling with mouse


From: JohnF
Subject: Re: .emacs to keep cursor stationary when scrolling with mouse
Date: Sun, 31 May 2015 04:03:52 +0000 (UTC)
User-agent: tin/2.2.1-20140504 ("Tober an Righ") (UNIX) (NetBSD/6.1.5 (i386))

Damien Wyart <damien.wyart@free.fr> wrote:
>> [...] This is what it does with keyboard. Mouse wheel and drag bar
>> always scroll text, but point gets dragged along with the scrolling
>> text, and jumps back towards center when it nears window top/bottom.
>> Instead, I'd like point to just remain stationary on screen, as yexy
>> scrolls "underneath" it.
> 
> I could get what you want for the wheel by using this:
>    (global-set-key (kbd "<mouse-4>") 'scroll-down-command)
>    (global-set-key (kbd "<mouse-5>") 'scroll-up-command)
> Can you confirm this is OK?

Absolutely confirmed! Thanks Damien, works like a charm.
I guess the guy who replied "You can't..." to one of the
stackoverflow questions you referred me to earlier was wrong.
Looks like "You can". And now "I can", too :)  Thanks.
I guess you could post this solution there, though it's
maybe a bit late for that op.

> About the scrollbar, I do not use it myself (many users of emacs use
> "(scroll-bar-mode -1)" in their .emacs and only use keyboard and mouse
> wheel),

Yeah, no problem. I use the scrollbar mostly for large moves within
the buffer, where M->,< don't get close. The wheel is way more
important to me. I'd have mentioned that if it had occurred to
me that it might make a difference.

> but looking at the code this is more difficult to get the exact
> behavior you want.

Thanks again for your time and effort looking at it.

> When testing, this seems most of the time to do what
> you want, but a few jumps apear from time to time, depending on the
> content of the buffer.

It's perfect. Those jumps occur when the point starts at a column
beyond the end-of-line for text passing underneath it as you scroll.
Then it jumps left to the end of that line, and jumps back to the
original column when text passing underneath it is again long enough.
-- 
John Forkosh  ( mailto:  j@f.com  where j=john and f=forkosh )


reply via email to

[Prev in Thread] Current Thread [Next in Thread]