Subject: bug#23546: 25.1.50; scroll-restore-mode breaks comint-mode

From: Dmitry Alexandrov <[email-masked]>
Date: Sun, 22 May 2016 04:34:30 +0300

On 19/05/16 15:56, martin rudalics wrote:
>> Hmm...  Probably I completely missed the point, but is not
>> ‘scroll-restore-jump-back’ an option that enables the title
>> functionality of scroll-restore-mode — restoring the point position
>> after scrolling, thus simulating the behaviour of most editors, which
>> does not have that limitation of Emacs — that cursor position can be
>> on-screen only.
>
> The aim of ‘scroll-restore-mode’ was much more modest: To move the
> cursor to the position of ‘window-point’ after a sequence of scroll
> commands have made that position invisible and then visible again.
>
> ‘scroll-restore-jump-back’ is much more aggressive: It forces the
> position of ‘window-point’ to become visible again and move the cursor
> to it after the first command which is not part of a sequence of scroll
> commands that have made that position invisible.  If you are used to the
> behavior of "most editors" where such behavior is the default, you might
> like this.
>
> Note, however, that the behavior I just described is not precisely the
> behavior of these editors because, in addition to moving window-point
> when it is scrolled off-screen, Emacs may also move window-point when it
> enters the scroll margin.  Such movement is left alone by my algorithm.

Thank you for explanation.

>> How would you recommend to use it?  To write an advice around ‘keyboard-quit’ (like below), so scrolling would be ‘cancelled’ only with ‘C-g’?
>>
>> (defadvice keyboard-quit (before scroll-restore-jump-back activate)
>>    (scroll-restore-jump-back))
>>
>
> It depends on what precisely you want to accomplish (or what you are
> used to).  But why on earth would you want to advise ‘keyboard-quit’?

To make ‘C-g’ and other keys that I bound to ‘keyboard-quit’ to ‘quit’ 
scrolling (if I may say so) too, of course.  Should I redefine these 
keys instead?

>>> I'll attach my latest version of ‘scroll-restore-mode’.  Please try it.
>>> If you confirm that this version works
>>
>> Yes.  My appreciations to you.
>>
>>> and doesn't break anything else,
>>
>> I could not try anything, of course, but at first sight it does not.
>
> All you have to do is use it for a sufficient amount of time.  I'm
> confident that there are unresolved issues left.

And you are right.  There is one of them: now it breaks macros that 
involve isearch.  Suppose that macro:

C-x ( C-s sit RET SPC bar C-x )

By executing it on a line:

¦Lorem ipsum dolor sit amet.

instead of:

Lorem ipsum dolor sit bar¦ amet.

I get:

r¦ab Lorem ipsum dolor sit amet.

(‘¦’ denotes point).