[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example i
From: |
Lars Ingebrigtsen |
Subject: |
bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop |
Date: |
Fri, 02 Aug 2019 21:08:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
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
- bug#19892: 25.0.50; hideshow: hs-hide-all-non-comment-function example infloop,
Lars Ingebrigtsen <=