GNU bug report logs -
#23510
Strange redisplay in global highlighted mode moving the scroll bar
Previous Next
Full log
Message #11 received at 23510 <at> debbugs.gnu.org (full text, mbox):
On Wed, 11 May 2016 11:13:05 +0300 Eli Zaretskii <eliz <at> gnu.org> wrote:
>> Date: Tue, 10 May 2016 21:31:26 +0200 (CEST)
>> From: "angelo.graziosi <at> libero.it" <angelo.graziosi <at> libero.it>
>>
>> (global-hl-line-mode 1)
>>
>>
>> Now, in the scratch buffer, copy and paste many times its text (;; This
>> buffer...) so that the scratch buffer has many lines, not all contained in the
>> Emacs window/frame. Move the cursor on a line, more or less at the center of
>> the window. The line is highlighted (in green, by default). Now move slowly
>> up/down the scroll bar, then the highlighted line seems to flicker as if it
>> were redrawn at (almost) each pixel movement of the scroll bar.
>>
>> Is this to be expected?
>
> I think so. HL-Line mode works by hooking both pre-command-hook and
> post-command-hook; it removes its highlight overlay in the former and
> reapplies it in the latter. When you move the scroll-bar thumb, the
> hooks are called several times (at least twice) per mouse drag event,
> and since Emacs tracks the mouse moves at pixel granularity, you
> usually have much more calls to the hooks. The result is constant
> redrawing of the highlighted line, and that causes flickering.
>
>> Other software with same feature do not show this
>> "flickering" and the highlight moves synchronously with the text.
>
> To reduce the number of redraws, hl-line.el should switch to a
> different method of moving the overlay, I think. I didn't try, so I
> cannot be sure this is doable with the existing facilities, but
> someone who is motivated enough should try using, e.g.,
> pre-redisplay-function.
>
> It could also be that hl-line should be smarter, and refrain from
> removing and reapplying the overlay if point didn't move, or stays
> within the same screen line. Again, I didn't try that, so perhaps it
> won't work for some reason.
What you say about the use of pre- and post-command-hook and moving
overlays may well be (perhaps the main) part of the problem here, but I
found out that there's an specific condition inducing it: I noticed that
the flickering only happens when global-hl-line-mode is enabled, but not
when hl-line-mode is enabled, and it turns out that the crucial
difference between them is that in the former,
global-hl-line-sticky-flag is nil by default, while in the latter,
hl-line-sticky-flag is t by default: when I set
global-hl-line-sticky-flag to t and then enable global-hl-line-mode, the
flickering no longer happens, and when I set hl-line-sticky-flag to nil
and then enable hl-line-mode, the flickering does happen.
Steve Berman
This bug report was last modified 8 years and 364 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.