bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#57551: 29.0.50; hide-show in python-mode selects the current block i


From: kobarity
Subject: bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly
Date: Mon, 05 Sep 2022 00:15:40 +0900
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (Gojō) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.0.50 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

Dima Kogan wrote:
> But what if the point is at the start of the "elif 2:" line? Currently
> emacs considers this to be INSIDE this block also, so (hs-hide-block)
> there also hides the "elif 2" block, but should it? Would it not make
> more sense if the START of the "elif 2:" line was considered in the "def
> f():" block, but outside all the "if" blocks? Then (hs-hide-block) at
> the start of that line would collapse the whole "def f():" block.
> Currently the only point where this can be done is at the end of the
> "def f():" line.

Hi.  I think current hideshow behavior is in line with block
navigation in Python mode.  For example, if the point is at the start
of the "elif 2:" line, M-x python-nav-beginning-of-block moves the
point to "e" of "elif 2:".  This implies that Emacs Python mode
considers spaces before "elif 2:" to belong to the "elif 2:" block.
So I think this is not a matter of hideshow, but of how the block
should be recognized.

The current implementation seems to assume that the block boundary is
always at the end of the line, as shown in the following figure.

_______________
|def f():      |
|_____________ |
||    if 1:   ||
||________11__||
||    elif 2: ||
||________22__||
|______________|

On the other hand, Dima seems to expect the block boundary to be as
shown in the following figure.

_______________
|def f():      |
|    _________ |
| ___|if 1:  _||
||_______ 11|_ |
| ___|elif 2:_||
||_______ 22|  |
|______________|

Although both models may have pros and cons, the current
implementation seems more natural to me.  In particular, it would be
more natural for "elif" or "else" block to be adjacent to "if" block
with nothing else in between.

Regards,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]