Re: Manipulating keymaps
Dr Rainer Woitok <[email protected]> Thu, 18 Jun 2026 18:38:13 +0200
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
Stefan,
On Tuesday, 2026-06-16 10:33:16 -0400, you wrote:
> ...
> I don't think `M-q` ever ran `fill-region` by default.
> I'll assume you meant `fill-paragraph` or `fill-paragraph-or-region`.
May well be. I no longer have Emacs 28.2 installed, so I can't check
what "M-q" was bound to, and at least "fill-paragraph-or-region" does
not exist in Emacs 30.2.
> ...
> 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.
Here goes:
$ emacs -Q lorem-ipsum
; Emacs will open a window in "Fundamental" mode. Enter the follow-
; ing text:
#! /usr/bin/bash
#
# lorem ipsum, dolor sit amet consectetur adipisci velit, sed eius modi tempora incidunt, ut labore et dolore magnam aliquam.
; Position the cursor on the "#" character preceding "lorem", and en-
; ter "C-<blank> <down> C-u M-q", which results in
#! /usr/bin/bash
#
# lorem ipsum, dolor sit amet consectetur adipisci velit, sed eius modi
tempora incidunt, ut labore et dolore magnam aliquam.
; (because this is still "Fundamental" mode). Manually add the miss-
; ing comment symbol in the last line:
#! /usr/bin/bash
#
# lorem ipsum, dolor sit amet consectetur adipisci velit, sed eius modi
# tempora incidunt, ut labore et dolore magnam aliquam.
; Now enter "C-s C-c" to terminate Emacs, and open this file in Emacs
again:
$ emacs -Q lorem-ipsum
; This time the file is opened using mode "Shell-script[bash]" and
; key "M-q" is bound to "prog-fill-reindent-defun". Now change the
; file's contents to
#! /usr/bin/bash
#
# lorem ipsum, dolor sit amet consectetur adipisci velit, ONE, TWO, THREE, sed eius modi
# tempora incidunt, ut labore et dolore magnam aliquam.
; Again place the cursor on the "#" character preceding "lorem", en-
; ter "C-<blank> <down> <down> C-u M-q" to again re-format these two
; lines, BUT NOTHING HAPPENS, the two lines don't change. However,
; if you again place the cursor on the "#" character preceding "lo-
; rem" and enter "C-<blank> <down> <down> C-u M-x fill-region" the
; two lines WILL BE re-formatted. And that's what I want to happen.
Sincerely,
Rainer