Re: Manipulating keymaps

[email protected] Mon, 15 Jun 2026 13:16:48 -0400
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
Dr Rainer Woitok <[email protected]> writes:

> Elin,
>
> On Sunday, 2026-06-14 17:22:24 +0300, you wrote:
>
>> ...
>> 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.
>
> Ok,  so perhaps I was just lucky  and used less major and minor modes or
> these modes had less key bindings defined.  Example: In all modes I used
> with Emacs 28.2 key "M-q"  just ran function "fill-region".   Emacs 30.2
> uses the same key binding in "Fundamental" mode, but as soon as I open a
> Shell,  Perl or Python script  or an "*.el" file,  key "M-q" is bound to
> "prog-fill-reindent-defun"  which simply doesn't do  exactly what I want
> or at least what I'm used to.
>
> So I would like to at least change this key binding in the modes associ-
> ated with these file types, but ideally in all modes.   Is there an easy
> way to achieve this?
>
> Sincerely,
>   Rainer
>

You might want to consider leaving ‘M-q’ bound to
‘prog-fill-reindent-defun’ (introduced in Emacs 30, see
NEWS: C-h n) and simply binding C-c q to ‘fill-region’, or
one of the function keys F5 through F9.  Remember that Emacs
reserves ‘C-c <single character>’ and F5-F9 for user
keybindings, so your binding will never be overridden by a
future version of Emacs.

See (info "(emacs) Key Bindings")

-- 
The lyf so short, the craft so long to lerne.
- Geoffrey Chaucer, The Parliament of Birds.