So the issue is that some 3rd party themes (like org-modern with
'org-modern-hide-stars' set) turn the initial stars of a heading
invisbile which confuses `org-at-heading-p' and
`org-back-to-heading'.
This issue was created by commit:
"d1e8023eb Do not assume that folded == invisible"
That commit was in response to a report of folding mishaps when
things get unfolded by a non-interactive isearch.
That commit modifies 7 functions so this behavior might be present
in more places then what has been reported.
Looking at this I believe we should change the logic to check if
the entire line is invisible or not. So instead of
'(org-invisible-p)' we could do '(org-region-invisible-p (point)
(pos-eol))'. We might also want to wrap this logic in a new
function like 'org-heading-invisible-p'.
Now Org actually has a feature builtin to hide leading stars. See
the variable 'org-hide-leading-stars'. The way this feature is
implemented is not by using invisible text but by turning the text
color white or black depending on the background. Notably, this
doesn't actually make the stars invisible if your background isn't
white or black. In a way that might actually be a feature but it
doesn't really feel hidden like "hide" would suggest.
Maybe we should allow 'org-hide-leading-stars' to have a value of
'invisible and then implement that version of hiding the stars
within Org itself? Does the org-modern theme maintain the
indentation of the stars? I'm not sure how to make text invisible
while maintaining it's width