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:08:54 +0200	[thread overview]
Message-ID: <87ef23o055.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")

Michael Heerdegen <michael_heerdegen@web.de> 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





  reply	other threads:[~2019-08-02 19:08 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 [this message]
2019-08-02 19:17 ` Lars Ingebrigtsen

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=87ef23o055.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.