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

From: Ihor Radchenko <[email-masked]>
Date: Tue, 18 Jul 2023 13:25:55 +0000

Eli Zaretskii <[email-masked]> writes:

>> More generally, `indent-to' implementation assumes that it is sufficient
>> to insert "COLUMN - (current-column)" spaces in order to reach COLUMN
>> (let me ignore tabs for simplicity).
>
> But ignoring the tabs is not a valid "trick" here, because it exactly
> means that your interpretation is too naïve: there's more in
> indentation to a certain column than meets the eye, precisely because
> of stuff like tabs, display properties, composed characters, and other
> calamities.

Ok. More precisely, `indent-to' implementation assumes that it is
sufficient to insert COLUMN/tab_width - (current-column))/tab_width tabs
and then add (COLUMN - (current-column) - N_tabs * tab_width) spaces.
(when indent-tabs-mode is active)

Still not taking into account display and invisible properties. Just
assuming that width of the inserted tabs and spaces is fixed.

At the same time, `current_column' does take into account display
properties. And thus we have one part of `indent-to' considering
invisible and display properties, while other part ignoring them.

>> And the actual scenario for Org is even more complex because
>> Org fontification is what is adding that problematic invisible text
>> property, leading to race condition between redisplay and indentation.
>> When I sprinkled (redisplay) calls to different places in Org's
>> tag alignment code, the results varied depending on where the
>> (redisplay) call was inserted.
>
> there couldn't be any race condition here, because indent-to is not
> run when redisplay runs.  I guess you mean that one could see the
> indentation appear, then disappear as result of JIT fontifications, or
> not appear at all, depending on the details?

No. I mean that (current-column) may change after fontification is
applied. We had a similar issue recently in
https://list.orgmode.org/als4q47p4dt4iva4s73sihe75qjdz4ni554h55e63o6izogzst@vs3olesw6da3/T/#m8d85b510def4163f8401988aaa44bf935027745f

Though this part may or may not be considered a bug. I am more concerned
about 'invisible property.

>> That's what I did to fix things on Org side, but I believe that the
>> current behaviour is a genuine bug.
>
> "Bug" in what sense?

In a sense that `indent-to' does not do what it is documented to do.
So, either documentation should be corrected or the implementation
should be changed.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>