From unknown Sun Jun 22 17:13:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#19761 <19761@debbugs.gnu.org> To: bug#19761 <19761@debbugs.gnu.org> Subject: Status: python.el: improved hideshow mode support Reply-To: bug#19761 <19761@debbugs.gnu.org> Date: Mon, 23 Jun 2025 00:13:31 +0000 retitle 19761 python.el: improved hideshow mode support reassign 19761 emacs submitter 19761 Carlos Pita severity 19761 normal tag 19761 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 03 17:28:53 2015 Received: (at submit) by debbugs.gnu.org; 3 Feb 2015 22:28:53 +0000 Received: from localhost ([127.0.0.1]:33205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YIlxl-00074A-78 for submit@debbugs.gnu.org; Tue, 03 Feb 2015 17:28:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54990) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YIlxj-00073y-SJ for submit@debbugs.gnu.org; Tue, 03 Feb 2015 17:28:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIlxd-0000mo-Iz for submit@debbugs.gnu.org; Tue, 03 Feb 2015 17:28:46 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:58291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIlxd-0000mk-Ge for submit@debbugs.gnu.org; Tue, 03 Feb 2015 17:28:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIlxc-0002iN-JO for bug-gnu-emacs@gnu.org; Tue, 03 Feb 2015 17:28:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIlxb-0000mJ-Lg for bug-gnu-emacs@gnu.org; Tue, 03 Feb 2015 17:28:44 -0500 Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:51022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIlxb-0000mC-ES for bug-gnu-emacs@gnu.org; Tue, 03 Feb 2015 17:28:43 -0500 Received: by mail-lb0-f176.google.com with SMTP id z12so41222445lbi.7 for ; Tue, 03 Feb 2015 14:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=5UMkOE2Xsq9DPT5Li9wCiHFpY/AaUNEldcAC4Po6rJQ=; b=xEsPwk/bfQr7zUVt4e2GpRKe68HceoAQWZBljD+FBe7jWXmWOint+sXyF9rvuaYP+V Q3a1bFtDKER0QGTp9NJKhbgO5RFp8pTJJjBnxSG3KWx5ybIVtO0r85hY7uSc8T1hqk1p T+KwwAPtLBHXvcjFxr1xNNGVDuuqYWsHPe6VGBh6GVfi9wne5EOIawYCaDvDa64+Q6C3 yIEPHbQlVRA4hiOdStjStX0iJ/uvz8xfE8tWA1ty1VcSZ6EaNHmAiReXU/B8rpzLJise Z7ke6mbrbsiZVQbdlxozVX9gE225T22rAyJZGJtYVSSrl9F/pqyp13+KIl1L16gDMJau 9NBw== X-Received: by 10.112.218.8 with SMTP id pc8mr26750668lbc.16.1423002133580; Tue, 03 Feb 2015 14:22:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.124.202 with HTTP; Tue, 3 Feb 2015 14:21:53 -0800 (PST) From: Carlos Pita Date: Tue, 3 Feb 2015 19:21:53 -0300 Message-ID: Subject: python.el: improved hideshow mode support To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) X-Debbugs-CC: galli.87@gmail.com Tags: patch I've found two issues with the current hs configuration: 1) The hs-block-start-regexp wants to anchor at the beginning of line. At least, this doesn't behave well with hs-hide-level-recursive. Try C-c @ C-l on the line after the class statement below. The problem is that the point is not always at the beginning of line when the regexp is evaluated by hs. 2) The hs-forward-sexp-func is python-nav-end-of-defun. This is fine as far as the function is separated by a blank line from the code that follows it. Otherwise the closed fold is joined with the line immediately following it. Try C-c @ C-h on the nested def below. This is easily fixed going one char back when the point is not left in an empty line after python-nav-end-of-defun. So after the changes the new hs configuration is: (add-to-list 'hs-special-modes-alist `(python-mode "\\s-*\\(?:def\\|class\\)\\>" nil "#" ,(lambda (_arg) (python-nav-end-of-defun) (unless (python-info-current-line-empty-p) (backward-char))) nil)) Here is the (real life) example mentioned above: class PivotReader: def __init__(self, file, num_cols): self._pr_file = open(file) if type(file) is str else file self._pr_reader = csv.reader(self._pr_file) header = next(self._pr_reader) self._pr_cols = {col: i for i, col in enumerate(header)} self._pr_nums = [col in num_cols for col in header] self._pr_vals = None def next_row(self): try: self._pr_vals = next(self._pr_reader) return True except: return False def __enter__(self): return self def __exit__(self, type, value, tb): self._pr_file.close() def __getattr__(self, col): return self[col] def __getitem__(self, cols): def get(col): idx = self._pr_cols[col] val = self._pr_vals[idx] num = self._pr_nums[idx] return float(val) if num else val if type(cols) is str: return get(cols) else: return tuple(map(get, cols)) From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 07 14:48:31 2015 Received: (at 19761-done) by debbugs.gnu.org; 7 Feb 2015 19:48:31 +0000 Received: from localhost ([127.0.0.1]:36850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKBMk-0002Fs-Nt for submit@debbugs.gnu.org; Sat, 07 Feb 2015 14:48:31 -0500 Received: from fencepost.gnu.org ([208.118.235.10]:46730 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YKBMi-0002Fh-L1 for 19761-done@debbugs.gnu.org; Sat, 07 Feb 2015 14:48:29 -0500 Received: from [190.246.172.180] (port=44013 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1YKBMh-0003X8-SJ for 19761-done@debbugs.gnu.org; Sat, 07 Feb 2015 14:48:28 -0500 From: fgallina@gnu.org (=?utf-8?Q?Fabi=C3=A1n?= Ezequiel Gallina) To: 19761-done@debbugs.gnu.org Subject: python.el: improved hideshow mode support Date: Sat, 07 Feb 2015 16:48:25 -0300 Message-ID: <877fvta4fq.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 19761-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Fixed at revno 2d467a0 in the master branch. Note that I included few tests that you may want to take a look in order to get familiar with the test suite. Thanks for the detailed explanation and patch. Cheers, Fabi=C3=A1n. From unknown Sun Jun 22 17:13:31 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 08 Mar 2015 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator