emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cursor positioning with `after-string' overlays


From: Eli Zaretskii
Subject: Cursor positioning with `after-string' overlays
Date: Thu, 01 Apr 2010 16:15:12 +0300

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 via email to

[Prev in Thread] Current Thread [Next in Thread]