[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: |
Dima Kogan |
Subject: |
bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly |
Date: |
Fri, 02 Sep 2022 14:25:39 -0700 |
Hi. I've been using the recently-committed hide-show functionality from:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56635
It's working well, but I just found a problem. Python lacks explicit
block-end characters that a language like C has. This creates some
ambiguity about what is intended, and I think emacs makes the wrong
choice in at least one spot. Let's say we have a tst.py:
def f():
if 1:
11
elif 2:
22
elif 3:
33
elif 4:
44
else:
5
If I want to collapse the "elif 2:" block, I move the point to somewhere
inside that block, and (hs-hide-block). Placing the point at the end of
the "elif 2:" line puts us unambiguously inside that block, so this does
the job.
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.
This also raises a question about what should happen if we
(hs-hide-block) with the point on the "i" in any of the "elif" lines.
Probably this should be outside the "elif" blocks too? Maybe?
Thanks!
- bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly,
Dima Kogan <=