Subject: bug#76193: 30.0.93; Wrong type argument in outline-minor-mode

From: Juri Linkov <[email-masked]>
Date: Thu, 13 Feb 2025 09:38:31 +0200

>> Thanks for the bug report.  outline-minor-mode was not intended
>> to work for left-margin-width set to a non-zero value from outside.
>
> Thanks, I wasn't sure what the intent of the code was, but that makes
> sense. However, the condition on line 552, which only holds if the
> margin width is zero, seems to make some of the following code
> redundant.

The intention was to avoid conflicts with other modes that use
the same margin.  But the problem is that other modes such as
flymake-mode can be enabled AFTER outline-minor-mode is
already enabled.  So outline-minor-mode has no control
over such situation.  Therefore this condition is not needed
in outline-minor-mode.

> Lines 566-569 add the current margin width to
> outline--margin-width, which is unnecessary if the current margin
> width has to be zero to get to that point. The reverse happens when
> the mode is disabled, in lines 616-619.

These lines were intended for the perfect case possibly achievable
in the future when different packages don't have to compete for
the space in the margins, but each of them will update just
own column.  I still believe we need to try to make this possible.

>> I wonder do you know a case where the same margin is successfully shared
>> between outline-minor-mode and some other package?
>
> It seems to work reasonably well as long as the margins are wide
> enough to show all the margin indicators. However, the other packages
> I use (flymake-mode and git-gutter-mode) unilaterally set the margin
> size to whatever they need without accounting for other packages' use
> of the margin. The final margin ends up depending on the order that modes
> are activated.
>
> In my case, flymake-mode (which defaults to margin indicators on
> graphical displays) was setting the margin width to 2, and by pure
> coincidence that is wide enough to show the outline-minor-mode and
> git-gutter symbols if there isn't a flymake indicator on that line.

Ideally, each package should increase the width of the margin
as much as it needs, and then update only own columns.

>> In any case this information is not required for fixing outline-minor-mode
>> that should support any value of left-margin-width.
>
>> Do you agree that the right fix would be just do nothing
>> when outline--margin-width is nil?
>
> That is one approach, but the other one would be to just remove the (>
> 1 *-margin-width) condition on line 552. If I understand correctly,
> the effect would be to increase the existing margin to accommodate the
> outline-minor-mode buttons, and then decrease the margins by the same
> amount when the mode is disabled.

I agree, so this condition will be removed from outline-minor-mode.

> I feel this change would play better with other packages that use the
> margin, and ideally those packages (e.g. flymake-mode) would be
> patched to do the same thing. What do you think?

Ok, I will try to modify both outline-minor-mode and flymake-mode
to respect each other in regard to the shared margin.