Re: Manipulating keymaps

Eli Zaretskii <[email protected]> Sun, 14 Jun 2026 17:22:24 +0300
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> From: Dr Rainer Woitok <[email protected]>
> Date: Sun, 14 Jun 2026 16:08:42 +0200
> 
> Greetings,
> 
> After eventually upgrading  from Emacs 28.2 to 30.2  I have problems de-
> fining personal key bindings  which are intended for being active in ALL
> keymaps.  In 28.2 I simply used something like
> 
>   (global-set-key (kbd "C-x M-y") 'function)
> 
> to globally define  all my personal key bindings.   But apart from func-
> tion "global-set-key"  meanwhile being deprecated  this function as well
> as its successor "keymap-global-set"  no longer override key bindings in
> more specific keymaps, as is pointed out when running

Key bindings in the global keymap were _always_ overridden by local
bindings.  That's how major and minor modes define key bindings that
override the global ones.  There was never a version of Emacs where
this wasn't so.  So if you think Emacs 28 worked differently, there's
some confusion and/or misunderstanding here.  Perhaps "C-x M-y" was
simply never used by any local binding before, but is used now?

> So how can I define key bindings which override all built-in keymaps?

You can't.  If there's a local key binding that gets in your way, you
need to unbind or rebind it (in a mode hook, for example).