GNU bug report logs -
#19892
25.0.50; hideshow: hs-hide-all-non-comment-function example infloop
Previous Next
Reported by: michael_heerdegen <at> web.de
Date: Tue, 17 Feb 2015 22:46:01 UTC
Severity: normal
Tags: fixed
Found in version 25.0.50
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 19892 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> 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
This bug report was last modified 5 years and 293 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.