Subject: Re: bug#64696: 30.0.50; indent-to inherits preceding text properties, including 'invisible

From: Stefan Monnier <[email-masked]>
Date: Tue, 18 Jul 2023 10:15:48 -0400

>>> However, after un-commenting `put-text-property' line, no indentation is
>>> done "visually" because Finsert_char is called with INHERIT argument Qt.
>> Isn't that in general TRT?  When you indent text, you _want_ to
>> inherit the text properties, right?
>> Whether the inherited properties should also include the invisible
>> property could be subject to discussion, but it isn't 100% clear to me
>> that it should always be excluded.
>
> The problem is that inheriting 'invisible (if its value is actually
> hiding text) yields to cursor not moving to the target column.
> When I read the docstring:
[...]
>     Indent from point with tabs and spaces until COLUMN is reached.

That's a good point.

Could you give a bit of background about why you use set an `invisible`
property that is inherited when inserting chars after it?

I mean I understand it's the default behavior of the `invisible`
property, but when making a piece of text invisible, it's common
that we arrange for that invisible property not to leak to text inserted
after it (either by setting the marker type of the overlay's end
or via the `rear-nonsticky` text-property).
This is useful for when the users goes and types right after the
invisible text, otherwise their text becomes invisible.

Of course, the command loop also tries to move point away from such
positions, so it can be useful not to use `rear-nonsticky`, so as to
"force" point to go before the invisible text rather than after.  But in
that case I'd expect that you'd also want to call `indent-to` with point
before the invisible text rather than after.

>> In any case, I think you can bind text-property-default-nonsticky
>> around the indent-to call to control this, right?  Or use the
>> rear-sticky text property.
> That's what I did to fix things on Org side, but I believe that the
> current behaviour is a genuine bug.

I think the only non-ugly fix would be to make `indent-to` call
`insert-char` without the `inherit` argument.

The history of this code is simple: `indent-to` was changed to pass the
`inherit` arg back in Aug 1994 at the same time `insert-char` got its new
`inherit` argument (see commits 6d1bd1a58117 and e2eeabbbce46),
i.e. quite early on, around the time text-properties were added.

FWIW, I can't see any good reason to inherit properties here, other than
"we've always done that", but I'd be surprised if making this change
won't affect some other use elsewhere :-(

        Stefan