From: kobarity <kobarity@gmail.com>
To: Dima Kogan <dima@secretsauce.net>
Cc: Lars Ingebrigtsen <larsi@gnus.oradg>, 56635@debbugs.gnu.org
Subject: bug#56635: 29.0.50; [PATCH] hide-show in python-mode supports ONLY function and class blocks
Date: Sun, 24 Jul 2022 09:57:13 +0900 [thread overview]
Message-ID: <CAMQkrSriwQiQ-seoYMTP=kYrwi8fkfpZfzgaCUMy0N4p-ONK5w@mail.gmail.com> (raw)
In-Reply-To: <87sfmr5zi9.fsf@secretsauce.net>
Hi Dima,
Dima Kogan <dima@secretsauce.net> wrote:
> 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.
This is one point I was thinking of. The first patch failed to pass
ERTs python-hideshow-hide-levels-1 and python-hideshow-hide-levels-2.
The second patch still fails with python-hideshow-hide-levels-1, but I
think it's OK to fix the ERT:
diff --git a/test/lisp/progmodes/python-tests.el
b/test/lisp/progmodes/python-tests.el
index 3b10bde23b..8cb2aa84d0 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -5828,8 +5828,11 @@ python-hideshow-hide-levels-1
class SomeClass:
def __init__(self, arg, kwarg=1):
+
def filter(self, nums):
- def __str__(self):"))))
+
+ def __str__(self):
+"))))
(or enabled (hs-minor-mode -1)))))
(ert-deftest python-hideshow-hide-levels-2 ()
It would be better to add some ERTs for blocks.
Another point I am thinking of is to improve the regex. As
hs-special-modes-alist has a support of the form (COMPLEX-START
MDATA-SELECTOR), I tried with the code below:
(add-to-list
'hs-special-modes-alist
`(python-mode
(,(python-rx (seq (or (seq buffer-start (? ?\n)) (seq (not ?\\) ?\n))
(* space) (group block-start))) 1)
;; Use the empty string as end regexp so it doesn't default to
;; "\\s)". This way parens at end of defun are properly hidden.
""
"#"
python-hideshow-forward-sexp-function
nil))
This code solves many problems of `hs-hide-block' mentioned in the
first mail, but it breaks `hs-hide-level'. It seems that current
MDATA-SELECTOR support is limited and needs some fixes if we want to
do something like above. I will look into this a little bit more.
Regards,
next prev parent reply other threads:[~2022-07-24 0:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 22:20 bug#56635: 29.0.50; [PATCH] hide-show in python-mode supports ONLY function and class blocks Dima Kogan
2022-07-23 7:58 ` Lars Ingebrigtsen
2022-07-23 15:51 ` kobarity
2022-07-23 20:41 ` Dima Kogan
2022-07-24 0:57 ` kobarity [this message]
2022-07-31 10:18 ` kobarity
2022-07-31 19:04 ` Dima Kogan
2022-08-07 14:37 ` kobarity
2022-08-08 15:16 ` Augusto Stoffel
2022-08-13 12:36 ` kobarity
2022-08-15 15:00 ` kobarity
2022-08-15 17:16 ` Dima Kogan
2022-08-16 2:28 ` kobarity
2022-08-17 10:45 ` Lars Ingebrigtsen
2022-08-17 11:11 ` Lars Ingebrigtsen
2022-08-17 11:32 ` kobarity
2022-08-24 0:39 ` Dima Kogan
2022-08-24 10:27 ` Lars Ingebrigtsen
2022-08-24 14:15 ` kobarity
2022-08-25 12:31 ` Lars Ingebrigtsen
2022-08-25 13:39 ` kobarity
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMQkrSriwQiQ-seoYMTP=kYrwi8fkfpZfzgaCUMy0N4p-ONK5w@mail.gmail.com' \
--to=kobarity@gmail.com \
--cc=56635@debbugs.gnu.org \
--cc=dima@secretsauce.net \
--cc=larsi@gnus.oradg \
/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 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).