From: Eli Zaretskii <eliz@gnu.org>
To: Platon Pronko <platon7pronko@gmail.com>
Cc: 62540@debbugs.gnu.org
Subject: 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 [thread overview]
Message-ID: <83zg7u4b4z.fsf@gnu.org> (raw)
In-Reply-To: <608539f1-df76-c667-ed13-57ef31b0d081@gmail.com> (message from Platon Pronko on Thu, 30 Mar 2023 18:59:15 +0800)
tags 62540 notabug
thanks
> Date: Thu, 30 Mar 2023 18:59:15 +0800
> From: Platon Pronko <platon7pronko@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.
next prev parent reply other threads:[~2023-03-30 13:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 10:59 bug#62540: 30.0.50; incorrect cursor positioning after overlay when put-text-property 'cursor t Platon Pronko
2023-03-30 13:33 ` Eli Zaretskii [this message]
2023-09-03 10:36 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83zg7u4b4z.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=62540@debbugs.gnu.org \
--cc=platon7pronko@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).