bug#81632: 31.0.91; outline-view-change-hook is marked obsolete, without an adequate replacement
Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
> The hook `outline-view-change-hook' was deprecated in 29.1 in commit
> 53b1e6f96cb03a461061e1e21cd185dd8a82ce6b. However there does not seem to
> exist an adequate replacement. Sometimes there is a need to run some
> code when folding or unfolding sections of a buffer.
>
> For instance the new `markdown-ts-mode' has this comment and code:
>
> ;; NOTE: `outline-view-change-hook' was obsoleted in 29.1 (commit
> ;; 53b1e6f96cb) on the grounds that only lazy-lock used it, but no
> ;; replacement was provided and outline.el itself still runs the hook
> ;; in 10+ places.
> (with-suppressed-warnings ((obsolete outline-view-change-hook))
> (add-hook 'outline-view-change-hook
> #'markdown-ts--outline-view-change nil t))
I wonder why this is needed. I see the following comment:
;; Don't create image overlays for nodes inside
;; folded (outline-invisible) headings, since the
;; images wouldn't be visible and could interfere
;; with the folded display.
(not (markdown-ts--outline-invisible-p node-start)))
The "images wouldn't be visible" bit seems unimportant (jit-lock usually
skips invisible text, so it shouldn't be an issue resource-wise).
Is the problem that the images are displayed even in text that's marked
as invisible? That would itself sound like a bug, tho I can imagine
it's debatable and not easy to fix in the redisplay code.
> Would it make sense to revert the deprecation or offer an alternative
> API to monitor folding and unfolding? Thanks!
I see it's used in a few other packages as well, but it's almost always
ill-adapted to the needs because it doesn't say what's changed, so the
clients end up refreshing the whole buffer every time even when we're
just (un)folding a particular node.
So, I'm in favor of introducing an alternative API
`outline-view-change-functions` which receives some useful info such as
a BEG..END range.
=== Stefan