Subject: Re: bug#51095: 28.0.50; Counter-intuitive `cursor-intangible-mode' behavior

From: Stefan Monnier <[email-masked]>
Date: Sun, 14 Nov 2021 17:25:35 -0500

> Let's start with the following example:
> emacs -Q
> M-: (insert "|" (propertize "xxxxx" 'cursor-intangible t) "|")
> M-x cursor-intangible-mode
>
> Result:
> |xxxxx|
>   ^^^^^ You can't move the cursor here
>
> What I expected:
> |xxxxx|
>  ^^^^^ You can't move the cursor here
>
> To clarify, although all the `X's are set to be intangible, you can still move
> your cursor to the first one.  Furthermore, even though neither `|' has a text
> property, you cannot move your cursor to the last one.

If you want `xxxxx` to be intangible, that means you presumably still
want to be able to move the cursor between the two `|` but the cursor
movement should be "as if" the `xxxxx` was absent (so the `xxxxx` will
be either attached to the first `|` or to the second).

If so, where do you want to place the cursor when it's between the two `|`?
One choice is to place it right after the first `|`, another is to place
it right before the second `|`.  Both choices make sense, AFAICT, and
you haven't explicitly specified which you want (other than in this bug
report, that is), so the behavior you see looks OK to me.

You can control this behavior via the stickiness property.

> Basically, make the first character front-sticky, and the last character
> rear-nonsticky.  Now it works as expected.

But now you allow the cursor to be either before the `xxxxx` or after
the `xxxxx`, so they're not really intangible any more.  It seems you
want them to be "atomic" instead, which we do not directly support (you
can simulate it by marking the first four `x` as `intangible`, for
example).

> The question is: Is this behavior intuitive?

Depends what you want, obviously.

        Stefan