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

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

bug#23510: Strange redisplay in global highlighted mode moving the scrol


From: Stephen Berman
Subject: bug#23510: Strange redisplay in global highlighted mode moving the scroll bar
Date: Wed, 11 May 2016 11:25:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.93 (gnu/linux)

On Wed, 11 May 2016 11:13:05 +0300 Eli Zaretskii <address@hidden> wrote:

>> Date: Tue, 10 May 2016 21:31:26 +0200 (CEST)
>> From: "address@hidden" <address@hidden>
>> 
>> (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





reply via email to

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