unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: emacs-devel@gnu.org
Subject: Cursor positioning with `after-string' overlays
Date: Thu, 01 Apr 2010 16:15:12 +0300	[thread overview]
Message-ID: <83bpe3xqjj.fsf@gnu.org> (raw)

Evaluate the following form in some buffer:

    (let ((pos (goto-char (point-max))))
      (insert "foobar")
      (overlay-put 
	(make-overlay (+ pos 2) (+ pos 3))
	'after-string (propertize "-" 'cursor t)))

This displays "foo-bar", with the "-" coming from the `after-string'
property of the overlay.  Now go to `f' at the beginning of "foo-bar",
type C-f repeatedly, and watch where the cursor is placed when you
type C-f on the second `o' in "foo".  Emacs-23 branch (and Emacs 22)
places the cursor on `-', and jumps over `b' to `a' on the next C-f.
The trunk version, by contrast, jumps from `o' directly to `b', and
then continues to `a' on the next C-f.

The trunk version of the cursor positioning, which was rewritten for
support of bidirectional editing, behaves like that because it always
tries to find an exact match for point, and if found, puts the cursor
on the corresponding glyph.  It only considers positioning the cursor
on glyphs whose position is different if an exact match could not be
found.  IOW, exact match wins over all other considerations.  Since
C-f from the second `o' moves point to buffer position to which `b'
corresponds exactly, that is where the trunk version puts the cursor.

The old version puts the cursor on `-' because it examines the glyphs
from left to right, and finds the glyph with a `cursor' property
_before_ it has a chance to see that `b' has the required character
position.

Does anyone think that the version on the trunk is wrong and the old
one is right?

More generally, what are the use-cases for putting the `cursor'
property on a `before-string' or `after-string' overlay, and what is
expected from cursor positioning in those use-cases?




             reply	other threads:[~2010-04-01 13:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-01 13:15 Eli Zaretskii [this message]
2010-04-01 21:54 ` Cursor positioning with `after-string' overlays Kim F. Storm
2010-04-02  7:53   ` Eli Zaretskii
2010-04-02  8:54     ` Eli Zaretskii
2010-04-02 10:24       ` Kim F. Storm
2010-04-01 22:06 ` Stefan Monnier
2010-04-02  8:16   ` Eli Zaretskii
2010-04-02 18:17     ` Stefan Monnier
2010-04-02 18:38       ` Eli Zaretskii
2010-04-02 20:35         ` Stefan Monnier
2010-04-02 21:16           ` Eli Zaretskii
2010-04-03  1:21             ` Stefan Monnier
2010-04-03  7:26               ` Eli Zaretskii
2010-04-03  7:30               ` redisplay code is ugly (was: Cursor positioning with `after-string' overlays) Eli Zaretskii
2010-04-03 10:42               ` Cursor positioning with `after-string' overlays Eli Zaretskii
2010-04-03 10:28       ` Eli Zaretskii

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=83bpe3xqjj.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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).