From: jakanakaevangeli <jakanakaevangeli@chiru.no>
To: 46407@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 [thread overview]
Message-ID: <87im7182fn.fsf@miha-pc> (raw)
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.
next reply other threads:[~2021-02-09 19:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 19:29 jakanakaevangeli [this message]
2021-02-09 21:38 ` bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas jakanakaevangeli
2021-05-21 12:56 ` jakanakaevangeli
2021-05-24 21:55 ` Lars Ingebrigtsen
2021-05-25 7:10 ` jakanakaevangeli
2021-05-25 19:10 ` Lars Ingebrigtsen
2021-07-20 14:31 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87im7182fn.fsf@miha-pc \
--to=jakanakaevangeli@chiru.no \
--cc=46407@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).