Subject: Re: bug#39967: 27.0.90; how to debug point moving erratically?

From: William Rankin <[email-masked]>
Date: Tue, 10 Mar 2020 20:29:09 +1000

On Sun, Mar 08 2020, Eli Zaretskii wrote:
> How about changing jit-lock-context-time to something like 1.5, and
> checking whether this affects the frequency of the jumps in any way?

Good idea. I think the difficulty with debugging this is how difficult it will
be for me to solve without reliably reproducing it.

> I looked at the code of the involved functions, and couldn't spot any
> place where they move point without wrapping that in save-excursion.
> But maybe I'm missing something -- can you see any suspects?

The only thing (I'm guessing here) is that the macro
with-buffer-prepared-for-jit-lock uses inhibit-point-motion-hooks which is
marked obsolete since Emacs-25.1; but there's nothing in the NEWS about this.

Also manually calling jit-lock-context-fontify or jit-lock-stealth-fontify
doesn't move point :/

> Also, do you have any features enabled which could perform a redisplay
> triggered by point movement?  If you do, perhaps they cause point to
> be displayed when Emacs doesn't expect that.

This would only be on post-command-hook or with cursor-sensor-mode activated
right? As far as I can tell I don't have any buffers with cursor-sensor-mode
active, and this is the value of post-command-hook in an elisp buffer:

  (jit-lock--antiblink-post-command eldoc-schedule-timer t)
  Local in buffer binder.el; global value is
  (global-font-lock-mode-check-buffers global-eldoc-mode-check-buffers
    global-page-break-lines-mode-check-buffers)

> Btw, in your original description you said when point jumps, it's
> outside of the current window -- but if so, how do you see that it
> jumps, when the cursor is not shown?

Sorry, I was unclear. I only meant that e.g. if the window shows buffer lines
500 - 580 then point may jump to position 250, i.e. beyond the window
boundaries, and the window scrolls to keep point visible. So essentially the
window jumps around to follow point jumping around.

> And finally, what happens if you disable the blink-cursor-mode?

Done. Still a waiting game...