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

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

bug#18739: 24.3; Request for a hook to be provided when scrolling will m


From: Josh
Subject: bug#18739: 24.3; Request for a hook to be provided when scrolling will move the cursor
Date: Thu, 16 Oct 2014 07:53:22 -0600

>>> The usual technique in Emacs is to put the mark where you were before
>>> scrolling.  Then "C-x C-x" will get you back.

>> This requires the forethought to set the mark before scrolling.

> No, you can do it always.

I don't understand. If I don't set the mark, how will "C-x C-x" know
where to jump back to?  I have experimented to see if I can replicate
the behavior that you are describing, but I cannot:

 (Copy many paragraphs of lorem ipsum text to the OS clipboard)
 $ emacs -Q
 C-y
 C-x h
 M-q
 C-u 12 C-n
 M-f
 M-f
 SPC
 H
 E
 R
 E
 <wheel-down> (until the cursor is forced to move)
 <wheel-up> (until the word "HERE" is visible again)
 C-x C-x

This does not jump the cursor back to the word "HERE" which is the
behavior that I am looking for.  I have also tried setting
transient-mark-mode to nil, but it does not do what I want either.

So again, I assert my claim that using "C-x C-x" requires that I have
the forethought to set the mark before I scroll.  Please tell me if I
am misunderstanding.

On Thu, Oct 16, 2014 at 7:44 AM, Stefan Monnier
<monnier@iro.umontreal.ca> wrote:
>>> >> It would be helpful to have a hook that would be called before any
>>> >> scrolling command moves the cursor.  In other words, I want to be
>>> >> notified when an update to the display will force the location of
>>> >> `point' to change in the current buffer.
>>> > What's wrong with window-scroll-functions?
>>> But these are also called when point is not affected, right?
>> Yes.  But it's easy to detect that situation, I think.
>
> Is it?
>
> I think the main reason why I ask is because I truly have no idea when
> window-scroll-functions is called.  You seem to be somewhat familiar
> with it, so could you try and clarify it in the docstring?
>
> Currently I see "List of functions to call before redisplaying a window
> with scrolling" and "Note that these functions are also called by
> `set-window-buffer'".
>
> Here are some of the questions this brings up for me:
> - is it called during set-window-buffer itself, or is it called in the
>   first redisplay after set-window-buffer?
> - what means "redisplaying a window with scrolling" exactly?  Does it
>   mean "redisplay with a different window-start then during the last
>   redisplay"?  Does that include the case where window-start is changed
>   so as to follow point or is it only the cases where window-start was
>   changed explicitly by a scrolling command?
> - how could a window-scroll-function distinguish the 3 cases:
>   "set-window-buffer", "used a scroll command", "moved point out of viewport".
>
> I tried already a few times to understand window-scroll-functions, but
> so far it has eluded me.  FWIW, I found 3 kinds of uses:
> - A crutch from when jit-lock didn't exist (in linum and lazy-lock).
> - A way to try and keep a window fully empty showing only point-max by
>   calling set-window-start with the same window-start (in follow-mode).
>   Not clear exactly why this should work, and arguably goes against the
>   warning in window-scroll-functions's docstring.
> - Do fancy auto-scrolling in eshell/em-smart (which does exactly what
>   window-scroll-functions's docstring warns not to do, AFAICT), calling
>   redisplay internally.
>
>
>         Stefan





reply via email to

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