[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lamb
From: |
jakanakaevangeli |
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.
- bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas,
jakanakaevangeli <=