I have very annoying problem, after I run M-x compile
time to time
cursor jump from middle of buffer to the first line.
I want to find out culprit (I found mode who responsible for this, but I want to know what exactly function is causing this).
At first I just replace goto-char
with my-goto-char
, but it didn't show culprit - nobody calls (goto-char 1)
,
after that I set hook on scrolling:
(defun my-bad()
(message "something bad happens")
)
(defun debug--on-window-scroll (wnd new-start)
(if wnd
(progn (message "wnd %s, new-start %d %s" wnd new-start (buffer-name (window-buffer wnd)))
(when (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1))
(my-bad)))))
(add-hook 'window-scroll-functions 'debug--on-window-scroll)
my-bad
was called, but debuger show only:
Debugger entered--entering a function:
* my-bad()
(progn (my-bad))
(if (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1)) (progn (my-bad)))
(progn (message "wnd %s, new-start %d %s" wnd new-start (buffer-name (window-buffer wnd))) (if (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1)) (progn (my-bad))))
(if wnd (progn (message "wnd %s, new-start %d %s" wnd new-start (buffer-name (window-buffer wnd))) (if (and (string= (buffer-name (window-buffer wnd)) "parsing.rs") (= new-start 1)) (progn (my-bad)))))
debug--on-window-scroll(#<window 3 on parsing.rs> 1)
redisplay_internal\ \(C\ function\)()
so I still have no idea who scroll buffer to the first line, any idea how to find culprit who responsible for scrolling to the first line of specific buffer?