From unknown Fri Aug 15 12:48:33 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#8279 <8279@debbugs.gnu.org> To: bug#8279 <8279@debbugs.gnu.org> Subject: Status: [PATCH] More fixes to prevent hide-show from being confused by commented-out braces Reply-To: bug#8279 <8279@debbugs.gnu.org> Date: Fri, 15 Aug 2025 19:48:33 +0000 retitle 8279 [PATCH] More fixes to prevent hide-show from being confused by= commented-out braces reassign 8279 emacs submitter 8279 Dima Kogan severity 8279 normal tag 8279 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 18 03:33:35 2011 Received: (at submit) by debbugs.gnu.org; 18 Mar 2011 07:33:35 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0UBi-0007bB-Ng for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:33:35 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0UBh-0007az-4C for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0UBa-00061v-T7 for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:33:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:43600) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0UBa-00061i-B5 for submit@debbugs.gnu.org; Fri, 18 Mar 2011 03:33:26 -0400 Received: from [140.186.70.92] (port=36128 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0UBY-0002Mv-5s for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2011 03:33:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0UBV-00060k-B4 for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2011 03:33:22 -0400 Received: from ibar.cds.caltech.edu ([131.215.42.49]:39596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0UBV-00060K-1u for bug-gnu-emacs@gnu.org; Fri, 18 Mar 2011 03:33:21 -0400 Received: from smart (cpe-76-175-234-46.socal.res.rr.com [76.175.234.46]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by ibar.cds.caltech.edu (Postfix) with ESMTP id 8427CBA846E for ; Fri, 18 Mar 2011 00:33:17 -0700 (PDT) Date: Fri, 18 Mar 2011 00:33:15 -0700 From: Dima Kogan To: bug-gnu-emacs@gnu.org Subject: [PATCH] More fixes to prevent hide-show from being confused by commented-out braces Message-ID: <20110318003315.788002f0@smart> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.24.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/G9ftT4A85K0lXj_Ej5laC15" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 199.232.76.165 X-Spam-Score: -5.5 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.5 (-----) --MP_/G9ftT4A85K0lXj_Ej5laC15 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Earlier I submitted some fixes to hideshow.el to improve handling of braces in comments (bug#8036). These fixes were incomplete and in one case, incorrect. The attached patch improves hideshow.el further: 1. The previous patch made hs-find-block-beginning quit searching if a brace was found inside a comment. This patch ignores that match and keeps searching. 2. There were some false positives of (looking-at hs-block-start-regexp) if the point was at a commented-out brace. This patch wraps all instances of that in a function to check for comments. --MP_/G9ftT4A85K0lXj_Ej5laC15 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-hideshow.el-corrected-improper-handling-of-braces-in.patch >From fad432dc00b7ba1103041b9fd87d4adcf4ac7fd1 Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sun, 6 Mar 2011 16:28:08 -0800 Subject: [PATCH] hideshow.el: corrected improper handling of braces in comments. Previous fix in bug #8036 would stop searching for a block start as soon as one was encountered in a comment. This patch keeps searching, until a non-commented block start is found. Furthermore, this patch resolves some corner cases by wrapping all searches for hs-block-start-regexp into a function that also checks for comments --- lisp/progmodes/hideshow.el | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index 9468d7b..708a0b4 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -536,6 +536,13 @@ property of an overlay." (overlay-put ov 'display nil)))) (overlay-put ov 'invisible (and hide-p 'hs))) +(defun hs-looking-at-block-start-p () + "Returns non-nil if the point is at the block start. +A function is useful for this to cleanly disregard commented-out +blocks" + (and (looking-at hs-block-start-regexp) + (save-match-data (not (nth 4 (syntax-ppss)))))) + (defun hs-forward-sexp (match-data arg) "Adjust point based on MATCH-DATA and call `hs-forward-sexp-func' w/ ARG. Original match data is restored upon return." @@ -564,7 +571,7 @@ The block beginning is adjusted by `hs-adjust-block-beginning' and then further adjusted to be at the end of the line." (if comment-reg (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end) - (when (looking-at hs-block-start-regexp) + (when (hs-looking-at-block-start-p) (let* ((mdata (match-data t)) (header-beg (match-beginning 0)) (header-end (match-end 0)) @@ -685,16 +692,15 @@ Return point, or nil if original point was not in a block." (let ((done nil) (here (point))) ;; look if current line is block start - (if (looking-at hs-block-start-regexp) + (if (hs-looking-at-block-start-p) (point) ;; look backward for the start of a block that contains the cursor (while (and (re-search-backward hs-block-start-regexp nil t) - (save-match-data - (not (nth 4 (syntax-ppss)))) ; not inside comments - (not (setq done + (or (save-match-data (nth 4 (syntax-ppss))) ; go again if in a comment + (not (setq done (< here (save-excursion (hs-forward-sexp (match-data t) 1) - (point))))))) + (point)))))))) (if done (point) (goto-char here) @@ -751,7 +757,7 @@ and `case-fold-search' are both t." (end-of-line) (when (and (not c-reg) (hs-find-block-beginning) - (looking-at hs-block-start-regexp)) + (hs-looking-at-block-start-p)) ;; point is inside a block (goto-char (match-end 0))))) (end-of-line) @@ -836,7 +842,7 @@ Upon completion, point is repositioned and the normal hook (<= (count-lines (car c-reg) (nth 1 c-reg)) 1))) (message "(not enough comment lines to hide)")) ((or c-reg - (looking-at hs-block-start-regexp) + (hs-looking-at-block-start-p) (hs-find-block-beginning)) (hs-hide-block-at-point end c-reg) (run-hooks 'hs-hide-hook)))))) @@ -868,7 +874,7 @@ See documentation for functions `hs-hide-block' and `run-hooks'." q (cadr c-reg)))) ((and (hs-find-block-beginning) ;; ugh, fresh match-data - (looking-at hs-block-start-regexp)) + (hs-looking-at-block-start-p)) (setq p (point) q (progn (hs-forward-sexp (match-data t) 1) (point))))) (when (and p q) -- 1.7.4.1 --MP_/G9ftT4A85K0lXj_Ej5laC15-- From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 14:36:08 2011 Received: (at 8279) by debbugs.gnu.org; 28 May 2011 18:36:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QQOMq-0007pp-9q for submit@debbugs.gnu.org; Sat, 28 May 2011 14:36:08 -0400 Received: from vm-emlprdomr-04.its.yale.edu ([130.132.50.145]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QQOMo-0007pV-RL for 8279@debbugs.gnu.org; Sat, 28 May 2011 14:36:07 -0400 Received: from furball (c-71-192-165-84.hsd1.ct.comcast.net [71.192.165.84]) (authenticated bits=0) by vm-emlprdomr-04.its.yale.edu (8.14.4/8.14.4) with ESMTP id p4SIZwMa015681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 28 May 2011 14:35:59 -0400 Received: by furball (Postfix, from userid 1000) id 055E116031F; Sat, 28 May 2011 14:35:57 -0400 (EDT) From: Chong Yidong To: Dima Kogan Subject: Re: bug#8279: [PATCH] More fixes to prevent hide-show from being confused by commented-out braces References: <20110318003315.788002f0@smart> Date: Sat, 28 May 2011 14:35:57 -0400 In-Reply-To: <20110318003315.788002f0@smart> (Dima Kogan's message of "Fri, 18 Mar 2011 00:33:15 -0700") Message-ID: <8762our7ua.fsf@stupidchicken.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.71 on 130.132.50.145 X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 8279 Cc: 8279@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) Dima Kogan writes: > Earlier I submitted some fixes to hideshow.el to improve handling of > braces in comments (bug#8036). These fixes were incomplete and in one > case, incorrect. The attached patch improves hideshow.el further: + "Returns non-nil if the point is at the block start. +A function is useful for this to cleanly disregard commented-out +blocks" This docstring should use the active voice, i.e. "Returns non-nil if the point is at the block start." And there's no need to justify the use of a function. Otherwise, the patch looks reasonable; I've commited it. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sat May 28 14:36:21 2011 Received: (at control) by debbugs.gnu.org; 28 May 2011 18:36:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QQON3-0007qB-GJ for submit@debbugs.gnu.org; Sat, 28 May 2011 14:36:21 -0400 Received: from vm-emlprdomr-04.its.yale.edu ([130.132.50.145]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QQON2-0007q1-Jn for control@debbugs.gnu.org; Sat, 28 May 2011 14:36:20 -0400 Received: from furball (c-71-192-165-84.hsd1.ct.comcast.net [71.192.165.84]) (authenticated bits=0) by vm-emlprdomr-04.its.yale.edu (8.14.4/8.14.4) with ESMTP id p4SIaEgh015755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Sat, 28 May 2011 14:36:15 -0400 Received: by furball (Postfix, from userid 1000) id 7CCAE16031F; Sat, 28 May 2011 14:36:14 -0400 (EDT) From: Chong Yidong To: control@debbugs.gnu.org Subject: close 8279 Date: Sat, 28 May 2011 14:36:14 -0400 Message-ID: <87vcwuhdup.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.71 on 130.132.50.145 X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) close 8279 thanks From unknown Fri Aug 15 12:48:33 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, 26 Jun 2011 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 From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 06 15:28:11 2011 Received: (at control) by debbugs.gnu.org; 6 Oct 2011 19:28:11 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBtc2-0001xi-RT for submit@debbugs.gnu.org; Thu, 06 Oct 2011 15:28:11 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RBtc0-0001xb-Ve for control@debbugs.gnu.org; Thu, 06 Oct 2011 15:28:09 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1RBtbq-0005hT-8B for control@debbugs.gnu.org; Thu, 06 Oct 2011 15:27:58 -0400 Date: Thu, 06 Oct 2011 15:27:58 -0400 Message-Id: Subject: control message for bug 6158 To: X-Mailer: mail (GNU Mailutils 2.1) From: Glenn Morris X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) unarchive 8279 forcemerge 8279 6158 From unknown Fri Aug 15 12:48:33 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 04 Nov 2011 11:24:03 +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