Is it possible to stop emacs from down translating the key chords

emacskeyboard shortcuts

emacs has the default behaviour of double-guessing which key-combo (chord) I've pressed. It automatically down-translates to a lesser chord when the key-combo I pressed is unassigned, eg. <C-M-up> (translated from <C-M-S-up>)

How can I turn this off?

I really can't see any value in it, but it must be for some users. I'd also like to know what advantage this (dubious) feature offers…

Best Answer

Short answer: there is no easy way to disable the translation to the un-shifted version of the binding.

If you want to find unbound key sequences, you can try M-x describe-unbound-keys. And it does indeed find that C-S-up is unbound (enter 15 when prompted for complexity).

The command describe-unbound-keys can be found in the unbound library which is available here on the wiki.

Longer answer:

The relevant documentation can be found in Key Sequence Input which states:

If an input character is upper-case (or has the shift modifier) and has no key binding, but its lower-case equivalent has one, then read-key-sequence converts the character to lower case. Note that lookup-key does not perform case conversion in this way.

It's obvious you don't like that behavior, but to change this particular translation, you'd have to modify keyboard.c in the Emacs source code - look for the comment:

  /* If KEY is not defined in any of the keymaps,
     and cannot be part of a function key or translation,
     and is a shifted function key,
     use the corresponding unshifted function key instead.  */

and disable the if statement that follows it.

In general, the keyboard translations exist for other reasons (as mentioned in the documentation link at the top of this answer) and you can customize them by customizing the various keymaps it mentions.

Related Question