Running emacs 28.1 whenever I use a mode derived from text-moe or prog-mode the value of context-menu-function is replaced. What is doing this and how can I stop it?

The default is


For elisp modes I see


I have run this using emacs -Q so it is not any of my code or any package. I have grepped the emacs source code and I think the variable is only alteed by add-hook e.g. in emacs-lisp.el

 (add-hook 'context-menu-functions #'elisp-context-menu 10 t)

1 Answer 1


The issue is that I did not understand add-hook.

If it is asked to add with the LOCAL variable set it does not just copy the global value and add to it in the buffer local value.

It creates a new local value with a t "That acts as a flag to run the hook functions of the global value as well as in the local value"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.