GNU bug report logs - #57551
29.0.50; hide-show in python-mode selects the current block imperfectly

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Fri, 2 Sep 2022 21:26:01 UTC

Severity: normal

Found in version 29.0.50

Full log


View this message in rfc822 format

From: Andreas Röhler <andreas.roehler <at> easy-emacs.de>
To: 57551 <at> debbugs.gnu.org
Subject: bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly
Date: Sun, 4 Sep 2022 19:01:53 +0200
Am 04.09.22 um 17:15 schrieb kobarity:
> 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,
>
>
> Hi,

IMO the if-block starts at column 4, with "if". It ends at any column 
lower than 4 below that number 22.

Assume everything between with no regard of column as part of that block.

Best,

Andreas








This bug report was last modified 2 years and 335 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.