GNU bug report logs - #51620
add-hook repeatedly adds same function into hook--depth-alist

Previous Next

Package: emacs;

Reported by: Filipp Gunbin <fgunbin <at> fastmail.fm>

Date: Fri, 5 Nov 2021 23:27:02 UTC

Severity: normal

Tags: patch

Fixed in version 29.1

Done: Filipp Gunbin <fgunbin <at> fastmail.fm>

Bug is archived. No further changes may be made.

Full log


Message #13 received at 51620 <at> debbugs.gnu.org (full text, mbox):

From: Filipp Gunbin <fgunbin <at> fastmail.fm>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: 51620 <at> debbugs.gnu.org, Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#51620: add-hook repeatedly adds same function into
 hook--depth-alist
Date: Sat, 06 Nov 2021 23:31:58 +0300
On 06/11/2021 01:13 +0100, Michael Heerdegen wrote:

> Filipp Gunbin <fgunbin <at> 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?

Yep, that was the intent.




This bug report was last modified 3 years and 250 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.