unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly
@ 2022-09-02 21:25 Dima Kogan
  2022-09-04 15:15 ` kobarity
  0 siblings, 1 reply; 6+ messages in thread
From: Dima Kogan @ 2022-09-02 21:25 UTC (permalink / raw)
  To: 57551; +Cc: Lars Ingebrigtsen, kobarity

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!





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-10 13:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 21:25 bug#57551: 29.0.50; hide-show in python-mode selects the current block imperfectly Dima Kogan
2022-09-04 15:15 ` kobarity
2022-09-04 17:01   ` Andreas Röhler
2022-09-05  7:44   ` Dima Kogan
2022-09-05  9:42     ` Andreas Röhler
2022-09-10 13:20     ` kobarity

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).