Subject: Re: bug#56635: 29.0.50; [PATCH] hide-show in python-mode supports ONLY function and class blocks

From: Dima Kogan <[email-masked]>
Date: Sat, 23 Jul 2022 13:41:27 -0700

Thanks for taking the time to look at this. After a big more dogfooding,
I've a small tweak to the first piece of the patch:

  diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
  index 1c99937c4b9..2b2b0900bee 100644
  --- a/lisp/progmodes/python.el
  +++ b/lisp/progmodes/python.el
  @@ -4819,9 +4819,7 @@ python-describe-at-point
   (defun python-hideshow-forward-sexp-function (_arg)
     "Python specific `forward-sexp' function for `hs-minor-mode'.
   Argument ARG is ignored."
  -  (python-nav-end-of-defun)
  -  (unless (python-info-current-line-empty-p)
  -    (backward-char)))
  +  (python-nav-end-of-block))

   
   ;;; Imenu

So (python-hideshow-forward-sexp-function) should call
(python-nav-end-of-block) and do nothing else. I think the extra
(backward-char) stuff was intended to handle the closing brace of the
block, which doesn't exist in Python. If you leave the (backward-char)
stuff there, the collapsed blocks still display the last character in
the block, which in Python has no special syntactical meaning.