all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: kobarity <kobarity@gmail.com>
To: lorniu <lorniu@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 71170@debbugs.gnu.org
Subject: bug#71170: 30.0.50; hs-hide-all in python mode not works as expected
Date: Sun, 26 May 2024 17:31:05 +0900	[thread overview]
Message-ID: <eke7zfsd9dpy.wl-kobarity@gmail.com> (raw)
In-Reply-To: <87fru512ne.fsf@gmail.com>

lorniu wrote:
> 
> 
> > Is this what you want?
> 
> What I want is, for example, this python code:
> 
>   ```
>   if TYPE_CHECKING:
>       Base64FileInput = Union[IO[bytes], PathLike[str]]
>       FileContent = Union[IO[bytes], bytes, PathLike[str]]
>   else:
>       Base64FileInput = Union[IO[bytes], PathLike]
>       FileContent = Union[IO[bytes], bytes, PathLike]  # PathLike is not  subscriptable in Python 3.8.
> 
> 
> 
> 
>   class aaa:
>       ...
> 
> 
> 
>   class bbb:
>       ...
>   ```
> 
> will fold as:
> 
>   ```
>   if TYPE_CHECKING:...
>   else:...
> 
>   class aaa:...
> 
>   class bbb:...
>   ```
> 
> instead of:
> 
>   ```
>   if TYPE_CHECKING:...
>   else:...
> 
> 
> 
> 
>   class aaa:...
> 
> 
> 
>   class bbb:...
>   ```
> 
> That is too much newlines between hidden blocks.
> 
> Maybe the patch I suggested is not well enough. Some update like this
> may be better?
> 
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index 79e383a1c1a..009e0c4fb3a 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -5734,7 +5734,13 @@ 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-block))
> +  (python-nav-end-of-block)
> +  (end-of-line)
> +  (let ((pt (point)))
> +    (skip-chars-forward " \n\t")
> +    (re-search-backward "\n\n" pt t)
> +    (unless (eolp) (goto-char (1- (line-beginning-position))))
> +    (when (< (point) pt) (goto-char pt))))
> 
>  (defun python-hideshow-find-next-block (regexp maxp comments)
>    "Python specific `hs-find-next-block' function for `hs-minor-mode'.
> 
> 
> 
> -- 
> Mess.

The patch works as expected.
I guess it depends on the person whether this kind of behavior is
desirable or not.  Wouldn't it be better to make it a customized
setting or something?





  parent reply	other threads:[~2024-05-26  8:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-24  8:40 bug#71170: 30.0.50; hs-hide-all in python mode not works as expected lorniu
2024-05-25 10:28 ` Eli Zaretskii
2024-05-25 14:36   ` kobarity
2024-05-26  4:39     ` lorniu
2024-05-26  5:10       ` kobarity
     [not found]         ` <87fru512ne.fsf@gmail.com>
2024-05-26  8:31           ` kobarity [this message]
2024-05-26  8:51             ` lorniu
2024-05-26  9:05               ` kobarity
2024-06-08 11:54                 ` Eli Zaretskii
2024-06-08 15:22                   ` kobarity
2024-06-09 13:50                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eke7zfsd9dpy.wl-kobarity@gmail.com \
    --to=kobarity@gmail.com \
    --cc=71170@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=lorniu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.