Search code examples
emacsemacs-prelude

Shifted command ignored when unshifted version exists


I have the following bindings:

M-q   => fill-paragraph
M-S-q => unfill-paragraph

But either key combo results in the first: fill-paragraph, so it appears that the Shift and thus unfill is ignored. I set the second myself:

(prelude-require-package 'unfill)
(define-key prelude-mode-map "\M-\S-q" nil)  ; don't let prelude dictate it
(global-set-key (kbd "M-S-q") 'unfill-paragraph)

There is a behavior of Emacs to fall back to an unshifted sequence when the shifted version does not exist (this seems good, but should not be happening for this case). So if I didn't have the M-S-q binding, then pressing that should result in fill-paragraph, which is what I'm unhappily seeing. This suggests that somehow Emacs doesn't know about the second binding. But I've verified that it does know with C-h f unfill-paragraph confirming it. Invoking from M-x shows it working well.

Why is the Shift being ignored?

(This is the GUI version of Emacs and my Shift keys work fine for other things.)


Solution

  • Emacs has some confusing problems w.r.t handling of shift, since the shift modifier is sometimes treated like a normal modifier but other times is special-cased to modify the base char so it's upper-cased.

    In this case, I think you'll need ?\M-Q. In contrast, ?\C-Q is the same as ?\C-q so you need to use ?\C-S-q to bind something to C-S-q.

    This probably deserves a M-x report-emacs-bug.