Subject: bug#48666: Leaks are still possible in hook--depth-alist

From: Stefan Monnier <[email-masked]>
Date: Tue, 22 Feb 2022 10:25:35 -0500

[email-masked] [2021-05-26 10:57:47] wrote:
>     (with-temp-buffer
>       (add-hook 'post-command-hook (make-symbol "fun-sym") 77 t))
>     (get 'post-command-hook 'hook--depth-alist)
> Perhaps hook--depth-alist could be a hash table with weak keys.

I just pushed to `master` a patch which should hopefully fix this
problem for good (basically, the depth alist is now kept in an(other)
variable (so for functions added to the buffer-local portion of the
hook, the depth is stored in the buffer-local portion of the depth
variable)).

I hope it will also fix the problems seen in
https://github.com/minad/corfu/issues/133

It makes it a bit harder to check if the old problem is still present or
not, OTOH, because the depth-alist isn't just a quick (get <hook>
'hook--depth-alist) away but you need to (symbol-value (get <hook>
'hook--depth-alist)) and that will only show you the global portion or
the portion relevant to the current buffer.

        Stefan