Subject: bug#56837: 28.1.90; `current-indentation' sometimes returns zero inside invisible text

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Jul 2022 13:08:18 +0300

> From: Ihor Radchenko <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 30 Jul 2022 17:08:12 +0800
> 
> > Bottom line: I think you are hitting undefined behavior here.
> 
> Maybe. But then I'd like to be able to get the "hard" indentation
> information for the underlying text in buffer, accounting for tab-width,
> and disregarding overlays and other font-lock staff.

I guess you should temporarily remove the invisible property?  Like
this:

  (let ((invis-spec buffer-invisibility-spec)
        indent)
     (remove-from-invisibility-spec '(outline . t))
     (setq indent
           (save-excursion (search-forward " a") (current-indentation)))
     (setq buffer-invisibility-spec invis-spec) indent)