Re: Manipulating keymaps

Stefan Monnier via Users list for the GNU Emacs text editor <[email protected]> Tue, 16 Jun 2026 10:33:16 -0400
Newsgroups gmane.emacs.help
Message-ID <[email protected]>
> 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".

I don't think `M-q` ever ran `fill-region` by default.
I'll assume you meant `fill-paragraph` or `fill-paragraph-or-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.

This is a binding in `prog-mode-map` inherited by most "programming
language" major modes.  A quick way to recover the previous behavior is

    (define-key prog-mode-map (kbd "M-q") nil)

But `prog-fill-reindent-defun` is meant to "do what you mean", so maybe
you should report the specific cases where you used `M-q` and it did not
do what you intended, so we can improve it.


=== Stefan