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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62540 in the body.
You can then email your comments to 62540 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62540; Package emacs. (Thu, 30 Mar 2023 11:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Platon Pronko <platon7pronko <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 30 Mar 2023 11:00:02 GMT) Full text and rfc822 format available.

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

From: Platon Pronko <platon7pronko <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; incorrect cursor positioning after overlay when
 put-text-property 'cursor t
Date: Thu, 30 Mar 2023 18:59:15 +0800
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

Workaround is to use the integer argument instead of t.


In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.37, cairo version 1.17.8) of 2023-03-29 built on the-big-maker
Repository revision: 2002ac376c97382cace161ef0832a6faf6f376e8
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101007
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-modules --without-libotf --without-m17n-flt --without-gconf
 --with-native-compilation=no --with-xinput2 --with-x-toolkit=gtk3
 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP
SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM
XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_TIME: en_SE.UTF-8
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  recentf-mode: t
  rainbow-delimiters-mode: t
  global-so-long-mode: t
  global-git-gutter-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  server-mode: t
  counsel-mode: t
  ivy-mode: t
  smartparens-strict-mode: t
  smartparens-mode: t
  shell-dirtrack-mode: t
  global-auto-revert-mode: t
  global-whitespace-mode: t
  whitespace-mode: t
  global-dvorak-mode: t
  dvorak-minor-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Features:
(shadow sort mail-extr emacsbug mule-util cal-move org-indent oc-basic
conf-mode make-mode yaml-mode scroll-lock sh-script smie executable
dabbrev pulse recentf magit-bookmark bookmark pp shortdoc ediff
ediff-merg ediff-mult ediff-wind ediff-diff ediff-help ediff-init
ediff-util ace-window smartparens-javascript js c-ts-common
typescript-mode smartparens-c cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs bs sql tramp-sh tramp-cache
time-stamp smartparens-scala scala-mode scala-mode-prettify-symbols
scala-mode-imenu scala-mode-map scala-mode-fontlock scala-mode-indent
scala-mode-paragraph scala-mode-syntax scala-mode-lib goto-addr vc
vc-dispatcher bug-reference magit-extras face-remap flymake-proc flymake
lsp-diagnostics company-oddmuse company-keywords company-etags
company-gtags company-dabbrev-code company-dabbrev company-files
company-clang company-capf company-cmake company-semantic
company-template company-bbdb lsp-modeline lsp-lens misearch
multi-isearch view lsp-zig lsp-tilt lsp-steep lsp-svelte lsp-sqls
lsp-ruby-syntax-tree lsp-ruby-lsp lsp-yaml lsp-xml lsp-vimscript
lsp-vhdl lsp-volar lsp-vetur lsp-html lsp-verilog lsp-vala lsp-v
lsp-typeprof lsp-ttcn3 lsp-toml lsp-terraform lsp-tex lsp-sorbet
lsp-solargraph lsp-rust lsp-rf lsp-ruff-lsp lsp-remark lsp-racket lsp-r
lsp-purescript lsp-pylsp lsp-pyls lsp-pwsh lsp-php lsp-pls
lsp-perlnavigator lsp-perl lsp-openscad lsp-ocaml lsp-magik lsp-nix
lsp-nim lsp-nginx lsp-mint lsp-marksman lsp-markdown lsp-lua lsp-kotlin
lsp-json lsp-javascript lsp-idris lsp-haxe lsp-groovy lsp-hack
lsp-graphql lsp-gleam lsp-go lsp-completion lsp-gdscript lsp-fsharp
lsp-fortran lsp-eslint lsp-erlang lsp-emmet lsp-elixir lsp-elm
lsp-dockerfile lsp-dhall lsp-d lsp-css lsp-csharp lsp-crystal lsp-cmake
lsp-clojure lsp-semantic-tokens lsp-clangd lsp-beancount lsp-bash
lsp-astro lsp-ansible lsp-angular lsp-ada lsp-actionscript
smartparens-python python treesit ffap rainbow-delimiters ol-w3m
ol-rmail ol-mhe ol-irc ol-info org-habit org-agenda org-element
org-persist org-id avl-tree org-refile ol-gnus nnselect gnus-art mm-uu
mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo
gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo
gnus-spec gnus-int gnus-range gnus-win ol-eww eww url-queue shr
pixel-fill kinsoku url-file svg xml dom mm-url gnus nnheader range
ol-docview doc-view jka-compr image-mode exif ol-bibtex bibtex ol-bbdb
copilot editorconfig editorconfig-core editorconfig-core-handle
editorconfig-fnmatch jsonrpc warnings so-long lsp lsp-mode lsp-protocol
tree-widget wid-edit spinner network-stream nsm smartparens-markdown
markdown-mode inline ht f f-shortdoc s ewoc company-box company-box-doc
frame-local company-box-icons company git-gutter-fringe fringe-helper
git-gutter magit-submodule magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func imenu
magit-diff smerge-mode diff diff-mode git-commit log-edit message
sendmail yank-media puny rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils
gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert
magit-margin magit-transient magit-process with-editor server magit-mode
transient magit-git magit-base magit-section crm compat org-archive
lispy lispy-inline avy etags fileloop generator edebug debug backtrace
help-fns radix-tree lispy-tags mode-local zoutline smartparens-org org
ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-src ob-comint
org-pcomplete org-list org-footnote org-faces org-entities ob-emacs-lisp
ob-core ob-eval org-cycle org-table ol org-fold org-fold-core org-keys
oc org-loaddefs find-func cal-menu calendar cal-loaddefs org-version
org-compat org-macs noutline outline icons counsel xdg xref project
dired dired-loaddefs swiper ivy delsel ivy-faces ivy-overlay colir color
cl-extra hydra lv edmacro kmacro smartparens-config smartparens-text
smartparens-rust smartparens advice loadhist dash tramp tramp-loaddefs
trampver tramp-integration files-x tramp-compat shell pcomplete
parse-time iso8601 time-date ls-lisp format-spec lpr rust-utils
thingatpt rust-mode rx rust-rustfmt rust-playpen rust-compile compile
text-property-search comint ansi-osc ansi-color ring rust-cargo
autorevert filenotify disp-table whitespace quail help-mode easy-mmode
darcula-theme finder-inf rust-mode-autoloads editorconfig-autoloads
web-mode-autoloads smartparens-autoloads magit-autoloads pcase
haskell-mode-autoloads wgrep-autoloads git-commit-autoloads
transient-autoloads php-mode-autoloads yaml-mode-autoloads
typescript-mode-autoloads solidity-mode-autoloads
magit-section-autoloads lsp-mode-autoloads markdown-mode-autoloads
ht-autoloads scala-mode-autoloads f-autoloads with-editor-autoloads
compat-autoloads git-gutter-autoloads lorem-ipsum-autoloads
go-mode-autoloads lispy-autoloads ace-window-autoloads
company-box-autoloads company-autoloads dash-autoloads counsel-autoloads
swiper-autoloads hydra-autoloads info ivy-autoloads s-autoloads
frame-local-autoloads avy-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs password-cache json subr-x
map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc
iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit xinput2 x multi-tty
make-network-process emacs)

Memory information:
((conses 16 904294 1544161)
 (symbols 48 56550 9)
 (strings 32 251815 84039)
 (string-bytes 1 7281465)
 (vectors 16 121863)
 (vector-slots 8 2259338 974086)
 (floats 8 633 12970)
 (intervals 56 40467 9510)
 (buffers 984 80))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62540; Package emacs. (Thu, 30 Mar 2023 13:34:01 GMT) Full text and rfc822 format available.

Message #8 received at 62540 <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.




Added tag(s) notabug. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 30 Mar 2023 13:34:02 GMT) Full text and rfc822 format available.

Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sun, 03 Sep 2023 10:38:02 GMT) Full text and rfc822 format available.

Notification sent to Platon Pronko <platon7pronko <at> gmail.com>:
bug acknowledged by developer. (Sun, 03 Sep 2023 10:38:02 GMT) Full text and rfc822 format available.

Message #15 received at 62540-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Platon Pronko <platon7pronko <at> gmail.com>, 62540-done <at> debbugs.gnu.org
Subject: Re: bug#62540: 30.0.50; incorrect cursor positioning after overlay
 when put-text-property 'cursor t
Date: Sun, 3 Sep 2023 03:36:55 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

> tags 62540 notabug
> thanks
[...]
> This is not a bug.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 01 Oct 2023 11:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 179 days ago.

Previous Next


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