Subject: Re: bug#52587: 29.0.50; Wrong block header/footer background in Org

From: Kévin Le Gouguec <[email-masked]>
Date: Tue, 21 Dec 2021 08:29:10 +0100

Eli Zaretskii <[email-masked]> writes:

>> From: Kévin Le Gouguec <[email-masked]>
>> Cc: [email-masked],  [email-masked],  [email-masked]
>> Date: Mon, 20 Dec 2021 07:33:07 +0100
>> 
>> But I think this bug report shows that some users have different
>> expectations, rooted in an abstract sense of what is and is not "part"
>> of the subsection to hide.  Specifically, they consider that the
>> end-of-line decoration of a subsection's last line is "part" of the
>> subsection, and so expect it to be hidden when the subsection is folded.
>
> Which means the Lisp code which defines which parts are hidden should
> hide slightly different parts?  Because the display engine does its
> job perfectly here, and so do the faces: they do what you tell them to
> do.

That sounds about right; FWIW I'd imagine this to be fixed/worked around
either in outline-mode itself, or in derived modes which feature these
:extended :backgrounds.

> IOW, while I see your point, I don't think I understand how would you
> like this to be resolved.

I don't have a concrete implementation proposal yet (this itch has
remained stuck in my "minor enough that I'll let someone else file a
report" drawer ever since I discovered it; thanks Rudolf for the report
btw 😉).

On the "vague handwavy half-baked idea" front, I'd imagine that when
folding a headline's subsections, Outline could (1) check whether the
headline has :extended decorations at end-of-line (2) pull off some
shenanigans to "copy" these decorations onto the hidden content's final
newline (by hacking its {font-lock-,}face property or slapping a display
property on top of it maybe?), but that sounds pretty brittle.

On the "gazing at the other side of fence where the grass looks greener"
front, I wonder if there are things to learn from Jonas's
magit-section[1], which AFAICT quacks like outline-mode (i.e. lets users
define/show/hide/navigate arbitrarily nested hierarchies of subsections)
and does not seem to suffer from this problem despite making heavy use
of extended backgrounds.

The "actionable suggestion" front is late to the battlefield, sorry 😕

[1] Code:
    https://git.savannah.gnu.org/cgit/emacs/nongnu.git/plain/lisp/magit-section.el?h=elpa/magit-section
    Manual:
    https://magit.vc/manual/magit-section/