GNU bug report logs - #46407
27.1; Hooks with permanent-local-hook are not cleared of lambdas

Previous Next

Package: emacs;

Reported by: jakanakaevangeli <jakanakaevangeli <at> chiru.no>

Date: Tue, 9 Feb 2021 20:01:01 UTC

Severity: normal

Tags: patch

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: jakanakaevangeli <jakanakaevangeli <at> chiru.no>
To: 46407 <at> debbugs.gnu.org
Subject: bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas
Date: Tue, 09 Feb 2021 20:29:48 +0100
When kill-all-local-variables encounters a hook variable with its
'permanent-local property set to 'permanent-local-hook, it removes from
its value every element except for t, functions with
'permanent-local-hook property and anything that isn't a symbol
(see the comment at src/buffer.c:1072).

This means that, for the following code

     (defvar   'some-hook nil)
     (add-hook 'some-hook #'some-fun         nil t)
     (add-hook 'some-hook (lambda () (test)) nil t)

whether some-fun is removed depends on some-fun's permanent-local-hook
property, which is expected. As for the anonymous lambda function, it is
not predictable, whether it will be kept or removed. In fact, it depends
on some-fun's permanent-local-hook property.

Perhaps it would make things more predictable to also remove non-symbol
functions such as lambda expressions.

See also info node (elisp) Creating Buffer-Local:
>  -- Function: kill-all-local-variables
>      This function eliminates all the buffer-local variable bindings
>      except for [...] and local hook functions that have a non-‘nil’
>      ‘permanent-local-hook’ property.
Which suggests that functions with a permanent-local-hook property
should be the only exception.




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

Previous Next


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