Subject: Re: bug#75387: 29.4; hideshow: hs-hide-level hides multiple top-level blocks as one

From: Eli Zaretskii <[email-masked]>
Date: Sun, 12 Jan 2025 11:42:58 +0200

> From: Christoph Groth <[email-masked]>
> Date: Sun, 05 Jan 2025 19:53:04 +0100
> 
> I noticed the following problem when using a homemade function that
> allows me to cycle hideshow visibility in a way similar to org-mode.
> The issue, however, is independent of any customization (it appears with
> emacs -Q as well).
> 
> I can reproduce the issue with the following source file
> 
> https://gitlab.kwant-project.org/kwant/kwant/-/raw/0d679b3efecd145d13e3174c60d829a7c3cd4374/kwant/builder.py
> 
> I tried simplifying that file to isolate the issue, but did not arrive at
> something more useful than the original.  To demonstrate the issue:
> 
> (1) Download the above file.
> (2) Open it with emacs -Q builder.py.  Point is not moved.
> (3) M-x hs-minor-mode RET
> (4) M-x hs-hide-level RET
> 
> The result is that the buffer shows only two hidden blocks, with the
> buffer ending in
> 
> @total_ordering
> class SiteFamily(metaclass=abc.ABCMeta):...
> 
> This is incorrect, since there are many other classes and top-level
> functions in the file.  Each should appear as a separate top-level
> block.

Hm... the doc string of hs-hide-level says:

  Hide all blocks ARG levels below this block.

So what is "this block" when point is at position 1 in this buffer?

If I move point to here:

  @total_ordering
  class SiteFamily(metaclass=abc.ABCMeta):

and invoke hs-hide-level, then all the "def" blocks inside this one
are hidden, as expected.  And note that the command only hides blocks
that are inside the current block, not those inside other blocks of
the same level.

So this could be a documentation issue, whereby the doc string doesn't
explain clearly enough what the command does.

kobarity, any comments?