all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: ttn@gnu.org, dann@ics.uci.edu, 19892@debbugs.gnu.org
Subject: bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop
Date: Fri, 02 Aug 2019 21:17:00 +0200	[thread overview]
Message-ID: <87a7crnzrn.fsf@mouse.gnus.org> (raw)
In-Reply-To: <87r3tonon8.fsf@web.de> (Michael Heerdegen's message of "Tue, 17 Feb 2015 23:45:15 +0100")

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ébastien Gross <seb@chezwam.org>
Date:   Wed Apr 11 01:34:25 2012 +0200

    (hs-hide-all): Don't infloop on comments that start in the middle of the line.
    
    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))))



-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no






      parent reply	other threads:[~2019-08-02 19:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-17 22:45 bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop Michael Heerdegen
2019-08-02 19:08 ` Lars Ingebrigtsen
2019-08-02 19:17 ` Lars Ingebrigtsen [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a7crnzrn.fsf@mouse.gnus.org \
    --to=larsi@gnus.org \
    --cc=19892@debbugs.gnu.org \
    --cc=dann@ics.uci.edu \
    --cc=michael_heerdegen@web.de \
    --cc=ttn@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.