bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51620: add-hook repeatedly adds same function into hook--depth-alist


From: Michael Heerdegen
Subject: bug#51620: add-hook repeatedly adds same function into hook--depth-alist
Date: Sat, 06 Nov 2021 01:13:02 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Filipp Gunbin <fgunbin@fastmail.fm> writes:

> diff --git a/lisp/subr.el b/lisp/subr.el
> index 8ff403e113..2b8b6deeb0 100644
> --- a/lisp/subr.el
> +++ b/lisp/subr.el
> @@ -1868,7 +1868,7 @@ add-hook
>        (when (or (get hook 'hook--depth-alist) (not (zerop depth)))
>          ;; Note: The main purpose of the above `when' test is to avoid 
> running
>          ;; this `setf' before `gv' is loaded during bootstrap.
> -        (push (cons function depth) (get hook 'hook--depth-alist)))
> +        (setf (alist-get function (get hook 'hook--depth-alist) 0) depth))
>        (setq hook-value
>           (if (< 0 depth)
>               (append hook-value (list function))

So the function would still be compared using `eq' but we would avoid to
add dups of equal conses?  Looks reasonable to me -- Stefan?

TIA,

Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]