GNU bug report logs - #80007
hl-line-mode vs. cursor-intangible-mode race condition

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Stéphane Marks <shipmints@HIDDEN>; dated Sun, 14 Dec 2025 19:02:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 80007 <at> debbugs.gnu.org:


Received: (at 80007) by debbugs.gnu.org; 15 Dec 2025 07:04:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 15 02:04:29 2025
Received: from localhost ([127.0.0.1]:35659 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vV2dB-0004tz-EG
	for submit <at> debbugs.gnu.org; Mon, 15 Dec 2025 02:04:29 -0500
Received: from mout-p-201.mailbox.org ([80.241.56.171]:51092)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <juri@HIDDEN>) id 1vV2d7-0004tU-Fj
 for 80007 <at> debbugs.gnu.org; Mon, 15 Dec 2025 02:04:28 -0500
Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
 (No client certificate requested)
 by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4dV9z44Q89z9tLQ;
 Mon, 15 Dec 2025 08:04:16 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linkov.net; s=MBO0001; 
 t=1765782256;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 in-reply-to:in-reply-to:references:references;
 bh=DZxt1ZWpcE1S2amgRwjwz1wlQX1n57nnHzgk0qVq9/w=;
 b=Jf5PN8zJLRRqQPZI0p/4sCsq0UpLITgPqOomkDEuE8BjeP3MESsDgECENlfsW+52v5zgOK
 OorMePJFaYDBY0IwUePsi/FTz9sOGyGGWgLaMOrHoLaaLu1o0AdkHxwRcbHN8zAp89FuaC
 fxa7SagUfBiBJ7JSeHlAXHzVUFfbLX2k3y01I1YZMpjkJjUrrbjncFvlwAB6IYHqP3dXIA
 y0GeKkvkjkFsqhQR6RiC5XVkKsuNI1s3B6kLSGeoVZ+Ud1qa/wecEYwqOfy0vMNLQVqE3A
 2CtBcR85QxbeYeHsyDyvB+1I1HspsxpZ9FsC4UO+yiTY9pZm2KGGwrRWFhShhQ==
From: Juri Linkov <juri@HIDDEN>
To: =?iso-8859-1?Q?St=E9phane?= Marks <shipmints@HIDDEN>
Subject: Re: bug#80007: hl-line-mode vs. cursor-intangible-mode race condition
In-Reply-To: <CAN+1HbqgSmKMeJx-FfnStMHJpoPVufDVhdgJxaxpWkGrkDkp7Q@HIDDEN>
Organization: LINKOV.NET
References: <CAN+1HbqgSmKMeJx-FfnStMHJpoPVufDVhdgJxaxpWkGrkDkp7Q@HIDDEN>
Date: Mon, 15 Dec 2025 09:03:37 +0200
Message-ID: <87bjk0fdae.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 80007
Cc: 80007 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

>   (hl-line-mode)

Please note that recently 'hl-line-mode' was obsoleted by the new value
of 'global-hl-line-sticky-flag' that uses 'pre-redisplay-functions'.

So please try with these settings:

  (setopt global-hl-line-sticky-flag 'window)

and enable 'global-hl-line-mode' instead of 'hl-line-mode'.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#80007; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 14 Dec 2025 19:01:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 14 14:01:39 2025
Received: from localhost ([127.0.0.1]:56384 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1vUrLf-0003bw-2n
	for submit <at> debbugs.gnu.org; Sun, 14 Dec 2025 14:01:39 -0500
Received: from lists.gnu.org ([2001:470:142::17]:52442)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <shipmints@HIDDEN>)
 id 1vUrLc-0003bj-F7
 for submit <at> debbugs.gnu.org; Sun, 14 Dec 2025 14:01:37 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <shipmints@HIDDEN>)
 id 1vUrLW-0005Ry-UE
 for bug-gnu-emacs@HIDDEN; Sun, 14 Dec 2025 14:01:30 -0500
Received: from mail-vk1-xa2c.google.com ([2607:f8b0:4864:20::a2c])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <shipmints@HIDDEN>)
 id 1vUrLV-0007qf-Fd
 for bug-gnu-emacs@HIDDEN; Sun, 14 Dec 2025 14:01:30 -0500
Received: by mail-vk1-xa2c.google.com with SMTP id
 71dfb90a1353d-55b0af02ddeso323949e0c.3
 for <bug-gnu-emacs@HIDDEN>; Sun, 14 Dec 2025 11:01:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1765738888; x=1766343688; darn=gnu.org;
 h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=L1cv0lwf9GJUUqWOOHcF40ud3jpUXEg43/X1netp2RI=;
 b=dX8LFIsIxekbC8A8wWadN/QEoRojkdkwosRssw1W6chn1LWr7nrE43F5Pthf5jIxrj
 zeTJy+IGR4pLkDR5vUNFgDPbYP7IhydclP5aj0RhxJ15JvpR/a4wo/0M3WL/iMlVLSnR
 sTIi5d+S9Pzva/Ft3Kn19hntqB0ANWPloTfvLzGn2h2xHd9GQAbwCRmPMnMKOliBj89U
 JhKo7EvwHWkSoopswWl85OTTFVXrqOmP+FtPSEWuZUXe+eNCmld0peefArLsBZh+hqQE
 B+bDwQhT8s5zUXvRA2QlDyO/dHnVN4IidfwqB2HdeIbktF9/KgBrl+ZSaRPNAUVMKlKy
 EOhw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1765738888; x=1766343688;
 h=to:subject:message-id:date:from:mime-version:x-gm-gg
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=L1cv0lwf9GJUUqWOOHcF40ud3jpUXEg43/X1netp2RI=;
 b=knh365nqb6u1uOKLapR8N7Ip3uHDa89crzmhiJjDdYDdZkpy4EZezDjUrWg3dZ30LI
 qhM3fCqPhhbLZXeaOhKa+bRBwBHZRZwiAqC7j27uccUe639HO4dQgR2/76R8MSKYR9Y5
 41mOCfLwaI2jOUOc1OgIm4iUVy01TS6ReVAiXN4Xo89dKR6hydsPrjzasYSBEU5b4C2B
 RNT8ghjOdvqxMS7MsqEJ/TndreWnSrZG+rfEdCnBnivCE3rHMcE0X9XYGbN42tNTD3c5
 ilJlfsBc0Hultw9iNALOyKgFiYaHAMWzLG4iBEQ56fcinoKvtiyZfUK0I6OMPm4EW8WK
 jKOA==
X-Gm-Message-State: AOJu0YwD4kHJ8V4VC1J0YnxmGgJ0ue1upK7dKxF5rUyctAFArvYTufpI
 LUoRw2NZ7nP7V8DLugGzUfYXwQUtrAd5m0cDXDioSX3mEquKqYb+l1TTyul5yBsQLk4hU1jZvWR
 MZHcLxOkNdVbY1qG2+irIvPYzwoSfuizAp4JE
X-Gm-Gg: AY/fxX50yLtB2fbQufLz3G8F75UVuM5Llbixo+bXvUyYRBB3/HYS6Q6RAx/Ay/QXBCK
 ih0/PCvkonKBFvsaJtO4go/Yaue5RYhrQ5/fBn1xWkdY8BcAZcCXNdqBUZcZtFz9uobskbndMhv
 /2NWkSDJKDgWToxN/Z6foHC56k0+GS620c/8uUl0+djHGKjcISGMgFWRL2B6YZWHIKLprnZmJgr
 FpPnaCrafQUFKzGdt+BWZHJjVt/n2RYv/cpN6ZnWOHGUFOCL0a5OeVKSHoAxFIfbL2fYqrn
X-Google-Smtp-Source: AGHT+IHudOLowKmvigp4IrXkq8NoUaetYVvf1dIhZMKZ5HkgwE/8NgyfKkT3X/THdmAPoQdsotpm02uFwTyl37m2P8U=
X-Received: by 2002:a05:6122:4faa:b0:55e:64d7:ae76 with SMTP id
 71dfb90a1353d-55fed66949bmr2603171e0c.20.1765738888011; Sun, 14 Dec 2025
 11:01:28 -0800 (PST)
MIME-Version: 1.0
From: =?UTF-8?Q?St=C3=A9phane_Marks?= <shipmints@HIDDEN>
Date: Sun, 14 Dec 2025 14:01:16 -0500
X-Gm-Features: AQt7F2p9PonbQ15NFH9sfui6HXtfZgLH4nfh5p6VOmfQ2-Lafy3kIGfJH3GfOxM
Message-ID: <CAN+1HbqgSmKMeJx-FfnStMHJpoPVufDVhdgJxaxpWkGrkDkp7Q@HIDDEN>
Subject: hl-line-mode vs. cursor-intangible-mode race condition
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/alternative; boundary="0000000000002fa4760645ee1f8b"
Received-SPF: pass client-ip=2607:f8b0:4864:20::a2c;
 envelope-from=shipmints@HIDDEN; helo=mail-vk1-xa2c.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.0 (+)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.0 (/)

--0000000000002fa4760645ee1f8b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

The reproducer, below, finds point winding up on the first line, yet
hl-line highlights the second line.  I believe this is due to hl-line
updating via post-command-hook and cursor-intangible-mode
(cursor-sensor--move-to-tangible) updating via. pre-redisplay-functions.
Hence the race which hl-line loses where the highlighted line is
"incorrect" if cursor-sensor--move-to-tangible moved point after hl-line
thought it was highlighting the correct line.

Not precisely sure how to deal with this but here are a couple of, perhaps
silly, ideas that come to mind and might spawn a better approach.

- hl-line could check if cursor-intangible-mode is enabled and defer its
update

- Schedule hl-line update via an immediate timer that runs after redisplay
ends

(let ((buffer (get-buffer-create "hl-line-cursor-intangible-test")))
  (switch-to-buffer buffer)
  (set-buffer buffer)
  (hl-line-mode)
  (cursor-intangible-mode)
  (insert
   "TANGIBLE\n"
   (propertize "INTANGIBLE\n"
               'face '(:weight bold)
               'cursor-intangible t
               'front-sticky t))
  (goto-char (point-min))
  (next-line))

-St=C3=A9phane

--0000000000002fa4760645ee1f8b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:monospac=
e">The reproducer, below, finds point winding up on the first line, yet hl-=
line highlights the second line.=C2=A0 I believe this is due to hl-line upd=
ating via post-command-hook and cursor-intangible-mode (cursor-sensor--move=
-to-tangible) updating via. pre-redisplay-functions.=C2=A0 Hence the race w=
hich hl-line loses where the highlighted line is &quot;incorrect&quot; if c=
ursor-sensor--move-to-tangible moved point after hl-line thought it was hig=
hlighting the correct line.</div><div class=3D"gmail_default" style=3D"font=
-family:monospace"><br></div><div class=3D"gmail_default" style=3D"font-fam=
ily:monospace">Not precisely sure how to deal with this but here are a coup=
le of, perhaps silly, ideas that come to mind and might spawn a better appr=
oach.</div><div class=3D"gmail_default" style=3D"font-family:monospace"><br=
></div><div class=3D"gmail_default" style=3D"font-family:monospace">- hl-li=
ne could check if cursor-intangible-mode is enabled and defer its update</d=
iv><div class=3D"gmail_default" style=3D"font-family:monospace"><br>- Sched=
ule hl-line update via an immediate timer that runs after redisplay ends</d=
iv><div class=3D"gmail_default" style=3D"font-family:monospace"><br></div><=
div class=3D"gmail_default" style=3D"font-family:monospace">(let ((buffer (=
get-buffer-create &quot;hl-line-cursor-intangible-test&quot;)))</div><div c=
lass=3D"gmail_default" style=3D"font-family:monospace">=C2=A0 (switch-to-bu=
ffer buffer)<br>=C2=A0 (set-buffer buffer)<br>=C2=A0 (hl-line-mode)<br>=C2=
=A0 (cursor-intangible-mode)<br>=C2=A0 (insert<br>=C2=A0 =C2=A0&quot;TANGIB=
LE\n&quot;<br>=C2=A0 =C2=A0(propertize &quot;INTANGIBLE\n&quot;<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&#39;face &#39;(:weight bol=
d)<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&#39;cursor-in=
tangible t<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&#39;f=
ront-sticky t))<br>=C2=A0 (goto-char (point-min))<br>=C2=A0 (next-line))<br=
></div><div class=3D"gmail_default" style=3D"font-family:monospace"><br></d=
iv><div class=3D"gmail_default" style=3D"font-family:monospace">-St=C3=A9ph=
ane=C2=A0</div></div>

--0000000000002fa4760645ee1f8b--




Acknowledgement sent to Stéphane Marks <shipmints@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#80007; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 15 Dec 2025 07:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.