From unknown Wed Jun 18 23:03:51 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#19892 <19892@debbugs.gnu.org> To: bug#19892 <19892@debbugs.gnu.org> Subject: Status: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop Reply-To: bug#19892 <19892@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:03:51 +0000 retitle 19892 25.0.50; hideshow: hs-hide-all-non-comment-function example i= nfloop reassign 19892 emacs submitter 19892 michael_heerdegen@web.de severity 19892 normal tag 19892 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 17 17:45:42 2015 Received: (at submit) by debbugs.gnu.org; 17 Feb 2015 22:45:42 +0000 Received: from localhost ([127.0.0.1]:46688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YNqti-0002ZA-32 for submit@debbugs.gnu.org; Tue, 17 Feb 2015 17:45:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:42911) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YNqtf-0002Yu-DL for submit@debbugs.gnu.org; Tue, 17 Feb 2015 17:45:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNqtV-0002wI-M5 for submit@debbugs.gnu.org; Tue, 17 Feb 2015 17:45:33 -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 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:57532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNqtV-0002wD-Jk for submit@debbugs.gnu.org; Tue, 17 Feb 2015 17:45:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNqtU-0002Nl-K2 for bug-gnu-emacs@gnu.org; Tue, 17 Feb 2015 17:45:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNqtP-0002v1-JZ for bug-gnu-emacs@gnu.org; Tue, 17 Feb 2015 17:45:28 -0500 Received: from mout.web.de ([212.227.17.11]:57538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNqtP-0002uo-7y; Tue, 17 Feb 2015 17:45:23 -0500 Received: from drachen.dragon ([94.218.211.212]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MGiUP-1YJEJI0Ryz-00DZWw; Tue, 17 Feb 2015 23:45:17 +0100 From: Michael Heerdegen To: bug-gnu-emacs@gnu.org Subject: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop Date: Tue, 17 Feb 2015 23:45:15 +0100 Message-ID: <87r3tonon8.fsf@web.de> MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:BIuKaWGqxMbmOOqyTztS4tFZliU9cW7lYTYZCFRa++UQ+WRWJHg 1pMoC8X7WBQ5FuN7BB6NijvqgU0bEC1oLzpCbeVTiZs2odvdTcdHDGpkNaWmuPZQtKFK/XF hoFtHwVyalNAbz1wjudDDwjRlhnO/X5hUwIXdOOZdYnGgyEqaAAVFbYUuqo7So/Xb7aaj0p dJUs8/o4mayESigyGvJJQ== X-UI-Out-Filterresults: notjunk:1; X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.1 (----) X-Debbugs-Envelope-To: submit Cc: ttn@gnu.org, dann@ics.uci.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: michael_heerdegen@web.de 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.1 (----) Hello, (CCing the authors of hideshow specified in the file header) in the header of hideshow.el, we have the following paragraph: --8<---------------cut here---------------start------------->8--- ;; Some languages (e.g., Java) are deeply nested, so the normal behavior ;; of `hs-hide-all' (hiding all but top-level blocks) results in very ;; little information shown, which is not very useful. You can use the ;; variable `hs-hide-all-non-comment-function' to implement your idea of ;; what is more useful. For example, the following code shows the next ;; nested level in addition to the top-level: ;; ;; (defun ttn-hs-hide-level-1 () ;; (hs-hide-level 1) ;; (forward-sexp 1)) ;; (setq hs-hide-all-non-comment-function 'ttn-hs-hide-level-1) --8<---------------cut here---------------end--------------->8--- But this doesn't always work. For example, eval the above example in emacs -Q, open "files.el", M-x hs-minor-mode, M-x hs-hide-all. You get an infloop. AFAICT the definition should be (or at least it works with that) (defun ttn-hs-hide-level-1 () (when (hs-looking-at-block-start-p) (hs-hide-level 1)) (forward-sexp 1)) Secondly, there is this comment in `hs-hide-all' which confuses me a bit: ;; Go to end of matched data to prevent from getting stuck ;; with an endless loop. Which match data is meant there? It is either match data from before hiding the block - then it should be documented that `hs-hide-all-non-comment-function' must not change match data, I guess, or the call should be wrapped into `save-match-data'. Or it is even the case that `hs-hide-all-non-comment-function' must set the match data (how?), which then should probably be documented. Thanks, Michael. In GNU Emacs 25.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.5) of 2015-02-15 on drachen Repository revision: ba5bc0ee7c81f2122072bee162fcf1dbd8b2a8f2 Windowing system distributor `The X.Org Foundation', version 11.0.11602901 System Description: Debian GNU/Linux 8.0 (jessie) Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY LIBXML2 FREETYPE XFT ZLIB Important settings: value of $LC_ALL: de_DE.utf8 value of $LC_COLLATE: C value of $LC_TIME: C value of $LANG: de_DE.utf8 locale-coding-system: utf-8-unix Major mode: Emacs-Lisp Minor modes in effect: magit-auto-revert-mode: t rainbow-delimiters-mode: t paredit-mode: t on-screen-global-mode: t ml-scale-mode: t interaction-log-mode: t highlight-defined-mode: t helm-descbinds-mode: t helm-mode: t shell-dirtrack-mode: t helm-occur-match-plugin-mode: t helm-match-plugin-mode: t helm-autoresize-mode: t global-diff-hl-mode: t diff-hl-mode: t diff-auto-refine-mode: t recentf-mode: t which-function-mode: t winner-mode: t show-paren-mode: t auto-image-file-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t mouse-wheel-mode: t prettify-symbols-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t buffer-read-only: t column-number-mode: t line-number-mode: t hs-minor-mode: t From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 02 15:09:06 2019 Received: (at 19892) by debbugs.gnu.org; 2 Aug 2019 19:09:06 +0000 Received: from localhost ([127.0.0.1]:57724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htcvK-0007Dp-59 for submit@debbugs.gnu.org; Fri, 02 Aug 2019 15:09:06 -0400 Received: from quimby.gnus.org ([80.91.231.51]:34368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htcvI-0007Dh-DJ for 19892@debbugs.gnu.org; Fri, 02 Aug 2019 15:09:04 -0400 Received: from 77.18.62.220.tmi.telenormobil.no ([77.18.62.220] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htcv8-00054L-Ul; Fri, 02 Aug 2019 21:08:57 +0200 From: Lars Ingebrigtsen To: Michael Heerdegen Subject: Re: bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop References: <87r3tonon8.fsf@web.de> Date: Fri, 02 Aug 2019 21:08:54 +0200 In-Reply-To: <87r3tonon8.fsf@web.de> (Michael Heerdegen's message of "Tue, 17 Feb 2015 23:45:15 +0100") Message-ID: <87ef23o055.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: Michael Heerdegen writes: > in the header of hideshow.el, we have the following paragraph: [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19892 Cc: ttn@gnu.org, dann@ics.uci.edu, 19892@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -1.0 (-) Michael Heerdegen writes: > in the header of hideshow.el, we have the following paragraph: [...] > ;; (defun ttn-hs-hide-level-1 () > ;; (hs-hide-level 1) > ;; (forward-sexp 1)) > ;; (setq hs-hide-all-non-comment-function 'ttn-hs-hide-level-1) > > But this doesn't always work. For example, eval the above example in > emacs -Q, open "files.el", M-x hs-minor-mode, M-x hs-hide-all. You get > an infloop. > > AFAICT the definition should be (or at least it works with that) > > (defun ttn-hs-hide-level-1 () > (when (hs-looking-at-block-start-p) > (hs-hide-level 1)) > (forward-sexp 1)) I've confirmed that the example still infloops in Emacs 27, and that your example doesn't, so I've committed it to the Emacs trunk. > Secondly, there is this comment in `hs-hide-all' which confuses me a bit: > > ;; Go to end of matched data to prevent from getting stuck > ;; with an endless loop. > > Which match data is meant there? It is either match data from before > hiding the block - then it should be documented that > `hs-hide-all-non-comment-function' must not change match data, I guess, > or the call should be wrapped into `save-match-data'. Or it is even the > case that `hs-hide-all-non-comment-function' must set the match data > (how?), which then should probably be documented. Here's the code: (progn (goto-char (match-beginning 1)) (unless (if hs-hide-all-non-comment-function (funcall hs-hide-all-non-comment-function) (hs-hide-block-at-point t)) ;; Go to end of matched data to prevent from getting stuck ;; with an endless loop. (goto-char (match-end 0)))) `hs-hide-block-at-point' calls a lot of functions that change match data, so presumably `hs-hide-all-non-comment-function' is allowed, too. But this all seems nonsensical -- what `match-end' points to here seems pretty random. So it looks like a bug to me. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 02 15:17:09 2019 Received: (at 19892) by debbugs.gnu.org; 2 Aug 2019 19:17:09 +0000 Received: from localhost ([127.0.0.1]:57732 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htd37-0007QV-E9 for submit@debbugs.gnu.org; Fri, 02 Aug 2019 15:17:09 -0400 Received: from quimby.gnus.org ([80.91.231.51]:34484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htd35-0007QN-6r for 19892@debbugs.gnu.org; Fri, 02 Aug 2019 15:17:07 -0400 Received: from 77.18.62.220.tmi.telenormobil.no ([77.18.62.220] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htd2z-00059i-F5; Fri, 02 Aug 2019 21:17:03 +0200 From: Lars Ingebrigtsen To: Michael Heerdegen Subject: Re: bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop References: <87r3tonon8.fsf@web.de> Date: Fri, 02 Aug 2019 21:17:00 +0200 In-Reply-To: <87r3tonon8.fsf@web.de> (Michael Heerdegen's message of "Tue, 17 Feb 2015 23:45:15 +0100") Message-ID: <87a7crnzrn.fsf@mouse.gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: This was introduced (by me applying the following patch) seven years ago. Hm... Oh, I see what the brittle logic here really is. The code (by default) calls this function: (defun hs-hide-block-at-point (&optional end comment-reg) [...] (when (hs-looking-at-block-start-p) Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 19892 Cc: ttn@gnu.org, dann@ics.uci.edu, 19892@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -1.0 (-) This was introduced (by me applying the following patch) seven years ago. Hm... Oh, I see what the brittle logic here really is. The code (by default) calls this function: (defun hs-hide-block-at-point (&optional end comment-reg) [...] (when (hs-looking-at-block-start-p) And: (defun hs-looking-at-block-start-p () "Return non-nil if the point is at the block start." (and (looking-at hs-block-start-regexp) (save-match-data (not (nth 8 (syntax-ppss)))))) So if the match is successful, but whatever (nth 8 (syntax-ppss)) means doesn't, then we go to the end of that match data. So it kinda works... But not if `hs-hide-all-non-comment-function' is set. I'll try to rework this in a more logical fashion. commit 43956923c00921499e0582f5da4cd739bc005240 Author: S=C3=A9bastien Gross Date: Wed Apr 11 01:34:25 2012 +0200 (hs-hide-all): Don't infloop on comments that start in the middle of th= e line. =20=20=20=20 Fixes: debbugs:10496 diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -804,7 +804,10 @@ (if (match-beginning 1) - ;; we have found a block beginning + ;; We have found a block beginning. (progn (goto-char (match-beginning 1)) - (if hs-hide-all-non-comment-function - (funcall hs-hide-all-non-comment-function) - (hs-hide-block-at-point t))) + (unless (if hs-hide-all-non-comment-function + (funcall hs-hide-all-non-comment-function) + (hs-hide-block-at-point t)) + ;; Go to end of matched data to prevent from getting stuck + ;; with an endless loop. + (goto-char (match-end 0)))) --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 02 15:21:41 2019 Received: (at control) by debbugs.gnu.org; 2 Aug 2019 19:21:41 +0000 Received: from localhost ([127.0.0.1]:57740 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htd7V-0007Y3-Ht for submit@debbugs.gnu.org; Fri, 02 Aug 2019 15:21:41 -0400 Received: from quimby.gnus.org ([80.91.231.51]:34540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1htd7T-0007Xt-H3 for control@debbugs.gnu.org; Fri, 02 Aug 2019 15:21:39 -0400 Received: from 77.18.62.220.tmi.telenormobil.no ([77.18.62.220] helo=sandy) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1htd7Q-0005AV-UX for control@debbugs.gnu.org; Fri, 02 Aug 2019 21:21:38 +0200 Date: Fri, 02 Aug 2019 21:21:36 +0200 Message-Id: <878ssbnzjz.fsf@mouse.gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #19892 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: tags 19892 fixed close 19892 27.1 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP 0.0 TVD_RCVD_IP Message was received from an IP address -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 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: -1.0 (-) tags 19892 fixed close 19892 27.1 quit From unknown Wed Jun 18 23:03:51 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 31 Aug 2019 11:24:08 +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