Received: (at 56635) by debbugs.gnu.org; 23 Jul 2022 07:59:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 23 03:59:10 2022 Received: from localhost ([127.0.0.1]:43205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1oFA2X-00026l-Op for submit <at> debbugs.gnu.org; Sat, 23 Jul 2022 03:59:09 -0400 Received: from quimby.gnus.org ([95.216.78.240]:48164) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <larsi@HIDDEN>) id 1oFA2V-00026T-NU for 56635 <at> debbugs.gnu.org; Sat, 23 Jul 2022 03:59:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=63s4/YoLG9L3kmUKhev8P+EVZvICxIeIlTbemzN74Y0=; b=Z37wSoM3QmcnkMrX5oDSdwK0it UMbxoD5VNAkOYKdtAI3LjKlH9A9OzDRZThchWf6ZQU8JnMcl4ohynkVk6weLMuKfEB0luLkPlgpRg oS7vquldBnoswS+cR5R/YXBeaQe8/jC7hPYQSXLiwWqgY4MzfKp24lpLoTC4Gs4rh3nM=; Received: from [84.212.220.105] (helo=joga) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <larsi@HIDDEN>) id 1oFA2M-000053-Ff; Sat, 23 Jul 2022 09:59:00 +0200 From: Lars Ingebrigtsen <larsi@HIDDEN> To: Dima Kogan <dima@HIDDEN> Subject: Re: bug#56635: 29.0.50; [PATCH] hide-show in python-mode supports ONLY function and class blocks In-Reply-To: <87v8ruysep.fsf@HIDDEN> (Dima Kogan's message of "Mon, 18 Jul 2022 15:20:30 -0700") References: <87v8ruysep.fsf@HIDDEN> X-Now-Playing: The Residents's _Subterranean Modern_: "Time's Up" Date: Sat, 23 Jul 2022 09:58:57 +0200 Message-ID: <87zgh01cqm.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Dima Kogan <dima@HIDDEN> writes: > Obvious options: > > 1. Leave the code as it is, don't support other blocks > > 2. Take this patch, with the understanding that it'll collapse some > stuff that it shouldn't > > 3. Patch hide-show t [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 56635 Cc: kobarity <kobarity@HIDDEN>, 56635 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Dima Kogan <dima@HIDDEN> writes: > Obvious options: > > 1. Leave the code as it is, don't support other blocks > > 2. Take this patch, with the understanding that it'll collapse some > stuff that it shouldn't > > 3. Patch hide-show to potentially accept non-regex logic > > I've been dogfooding the patch for a few days now, and it's behaving 99% > properly for me, so I'm inclined to suggest option 2. Making hide-show > smarter (option 3) doesn't feel worth the effort to fix THIS problem. Hm; don't know either. Kobarity's done some work in related areas in python-mode lately, and perhaps has some comments, so added to the CCs.
bug-gnu-emacs@HIDDEN
:bug#56635
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 18 Jul 2022 22:20:45 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jul 18 18:20:45 2022 Received: from localhost ([127.0.0.1]:52393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1oDZ6a-00076J-RF for submit <at> debbugs.gnu.org; Mon, 18 Jul 2022 18:20:45 -0400 Received: from lists.gnu.org ([209.51.188.17]:34372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <dima@HIDDEN>) id 1oDZ6Y-00076A-6t for submit <at> debbugs.gnu.org; Mon, 18 Jul 2022 18:20:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <dima@HIDDEN>) id 1oDZ6X-0000ik-R2 for bug-gnu-emacs@HIDDEN; Mon, 18 Jul 2022 18:20:42 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:60497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <dima@HIDDEN>) id 1oDZ6U-0007jo-Pt for bug-gnu-emacs@HIDDEN; Mon, 18 Jul 2022 18:20:41 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id BE40A32007D7 for <bug-gnu-emacs@HIDDEN>; Mon, 18 Jul 2022 18:20:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 18 Jul 2022 18:20:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretsauce.net; h=cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm2; t= 1658182834; x=1658269234; bh=AHP82qI2EpLLjSzvIdvMLawEJNAt3ECV0NH P4o16ycw=; b=POU8pk349naQTUZ/WH5APxyZWUXC+WWLOvktzinZRZ+tTIPF2Xa FpHV6GS6/BMleMZ84FAfBLpxW0cli/pOvH9F3h4Pd2jiyELdfCJXDCMrXWUD83MZ pnk1krtB4fK0EUtxIYi5irUHDC/nb2j1INsluDNYnFr38D6V7hfA3ykV5nMvKfZw lQ3jbuyhMgzallp8vl4HZX44W5cKu/LQ353q/IA45ijaDxaV9DaWPTFHKX4MoUQT 33ccBc+o0w4op6eVy6HynXpx1iT3nJEh/q93YWIbYUOnzsvF1Q9HRhBCzo3zCUXL wXg0m0BL2bI8nxJQKWoxWiVDMqBlgIFmlxA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1658182834; x= 1658269234; bh=AHP82qI2EpLLjSzvIdvMLawEJNAt3ECV0NHP4o16ycw=; b=t 5oJ1wIq9gUkFXr43VY/MI5TeYxFmh4aFyR7ehJmlITj9dEHCgmewnIYZi1TEafEQ 4heRFVm2ONPxxrgIO0UXVcJE90KlunobX1WNjInBqm9fphBkxVPNf0jtDNr//yKR lg0mpguGBwfp3TLZlgQk9mcBVj6VBNHn+/iefuQZ4XhHz/zkozXlI6v8cepfE7IO UYA6w8l42QZyR00qo2qc9/3QD1DEc2g2KLNCIMZEzJmqs+vBapEZbNIVjf0qijKP CU5LpdvBx35CEKAqodj6u4aXjZo62O/Z93lgpoH2nNXqzOc2oAQ/gI+OcO7F6Hwg hZORSF0XQwO20HrgTxmfQ== X-ME-Sender: <xms:stzVYuo5ZAu5-rHuVMmJG5f8du1_1Xw4Np83kNPUTOyziK-Pk56Dzg> <xme:stzVYsoAY33vuMw3C9oENz9Fa928YCOVw14g-KHkNV2cGCZjNbPW0xmVlENwzp03E VrKdjahcUjdwei3> X-ME-Received: <xmr:stzVYjMqdTOeBWlOURN-YFl3rmk_7NRRsN_y8oJUG0jmI6HCgsuHbSnl> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudekledgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtsehttdertddttd dtnecuhfhrohhmpeffihhmrgcumfhoghgrnhcuoeguihhmrgesshgvtghrvghtshgruhgt vgdrnhgvtheqnecuggftrfgrthhtvghrnhepffdvffduhfekfffhieefhfffvddtgfefje evuedvfedujeejudevfedtgeeguedvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepughimhgrsehsvggtrhgvthhsrghutggvrdhnvght X-ME-Proxy: <xmx:stzVYt41tJJGp99-SAIChgVRevAfHKOfIxedTGQxG74b2uh8i0g-6Q> <xmx:stzVYt4nDMg2KpopjT1F4eAgipCP31RLnp4bYGDUfjdqrT952q1xBg> <xmx:stzVYtgJjd7kw6rGMqoS90VbMAZMdeEQEa6lb0RrUsQxihYek_7aFw> <xmx:stzVYuXCNqoEjsIxfXgDPtP-zreqAQkFHrZ-eRczAc2BLckdmhwcww> Feedback-ID: i3e8042a0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for <bug-gnu-emacs@HIDDEN>; Mon, 18 Jul 2022 18:20:34 -0400 (EDT) From: Dima Kogan <dima@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 29.0.50; [PATCH] hide-show in python-mode supports ONLY function and class blocks Date: Mon, 18 Jul 2022 15:20:30 -0700 Message-ID: <87v8ruysep.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.25; envelope-from=dima@HIDDEN; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.7 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.7 (--) Hi. I'm using hide-show mode to visually collapse blocks while coding. This is very helpful, and works great in C-like modes. hide-show mode currently supports Python in a limited fashion: only def: and class: blocks are hidden. Other kinds of blocks (if, else, for, while, ...) are not supported. A simple patch that mostly adds support for all other kinds of blocks is: diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 1c99937c4b9..b63d2bc0690 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -4819,7 +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) + (python-nav-end-of-block) (unless (python-info-current-line-empty-p) (backward-char))) @@ -5766,8 +5766,8 @@ python-mode (add-to-list 'hs-special-modes-alist - '(python-mode - "\\s-*\\_<\\(?:def\\|class\\)\\_>" + `(python-mode + ,(python-rx block-start) ;; Use the empty string as end regexp so it doesn't default to ;; "\\s)". This way parens at end of defun are properly hidden. "" I say "mostly" because this isn't doable with regular expressions, as is required by hide-show mode. So this patch can confuse the parser: some bits of code will look like they begin a block, while in reality they do not. hide-show would then collapse lines that it should ignore. Some Python code that shows this failure: if 0: aaa l = [ i for i in range(5) \ if i < 3 ] ccc abc = o.match(1,2,3) ddd Here the "for" and "if" in the list comprehension both trigger the block hiding. And the "match" function call triggers it too. python-mode has functions to move between blocks (python-nav-...), but they're not completely regex-based, so they can't be baked into hide-show. Suggestions? Obvious options: 1. Leave the code as it is, don't support other blocks 2. Take this patch, with the understanding that it'll collapse some stuff that it shouldn't 3. Patch hide-show to potentially accept non-regex logic I've been dogfooding the patch for a few days now, and it's behaving 99% properly for me, so I'm inclined to suggest option 2. Making hide-show smarter (option 3) doesn't feel worth the effort to fix THIS problem. Thanks!
Dima Kogan <dima@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#56635
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.