GNU bug report logs - #62540
30.0.50; incorrect cursor positioning after overlay when put-text-property 'cursor t

Previous Next

Package: emacs;

Reported by: Platon Pronko <platon7pronko <at> gmail.com>

Date: Thu, 30 Mar 2023 11:00:02 UTC

Severity: normal

Tags: notabug

Found in version 30.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at control <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Platon Pronko <platon7pronko <at> gmail.com>
Cc: 62540 <at> debbugs.gnu.org
Subject: Re: bug#62540: 30.0.50;
 incorrect cursor positioning after overlay when put-text-property
 'cursor t
Date: Thu, 30 Mar 2023 16:33:16 +0300
tags 62540 notabug
thanks

> Date: Thu, 30 Mar 2023 18:59:15 +0800
> From: Platon Pronko <platon7pronko <at> gmail.com>
> 
> According to documentation, if a character in the overlay text string has 'cursor property set to t,
> then cursor should be shown on that character while point is in the overlay.
> 
> However, it seems that this doesn't work at the moment - cursor is still shown after the overlay.
> 
> Here's a test file to reproduce the problem:
> 
> ```
> AD
> 
> (defun test-overlay-cursor (completion pt)
>    (remove-overlays)
>    (save-excursion
>      (let* ((p-completion (propertize completion 'face 'error))
>             (ov (make-overlay pt pt nil t t)))
>        ;; doesn't work, cursor is shown after overlay
>        (put-text-property 0 1 'cursor t p-completion)
>        ;; works, cursor is shown before overlay
>        ;; (put-text-property 0 1 'cursor 1 p-completion)
>        (overlay-put ov 'display "")
>        (overlay-put ov 'after-string p-completion)))
>    (goto-char 2))
> (test-overlay-cursor "BC" 2)
> 
> ```
> 
> When I run the last sexp I observe the cusor being shown after the overlay:
> 
> ABC<cursor>D
> 
> While the expected position is:
> 
> A<cursor>BCD

Your overlay is "empty": it doesn't hide any buffer text characters
from being shown on display.  So Emacs has no reason to try to display
the cursor inside the overlay text: ity could simply show the cursor
on the character at point.  If you change the make-overlay call in
your test-overlay-cursor function to say this instead:

            (ov (make-overlay pt (1+ pt) nil t t)))
                                 ^^^^^^^
then it will work as you expect.  Note that the ELisp manual
explicitly talks about "when the overlay or display string make point
not visible on display".  This doesn't happen in your case.

> Workaround is to use the integer argument instead of t.

Yes, if you must use "empty" overlays.  But that is basically a side
effect of the implementation, and you should not rely on that too
much.  Better not use "empty" overlays at all if you want to show the
cursor inside the overlay string.

This is not a bug.




This bug report was last modified 1 year and 261 days ago.

Previous Next


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