all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas
@ 2021-02-09 19:29 jakanakaevangeli
  2021-02-09 21:38 ` jakanakaevangeli
  2021-05-24 21:55 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 7+ messages in thread
From: jakanakaevangeli @ 2021-02-09 19:29 UTC (permalink / raw)
  To: 46407


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.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-20 14:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-09 19:29 bug#46407: 27.1; Hooks with permanent-local-hook are not cleared of lambdas jakanakaevangeli
2021-02-09 21:38 ` 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.