Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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...

share|improve this question
1  
Why are you pressing key combos that are unassigned? It probably assumes that you hit the wrong key, since the alternative is you're intentionally pressing unbound keys –  Michael Mrozek Nov 29 '11 at 15:14
    
That's exactly my point. If I hit the wrong key, and that key is unassigned, what is the rationale, or algorithm, that comes up with: "Oh! he pressed a wrong key! Must have, 'cos C-S-y is unassigned!" So Mr Algorithm then thinks: "Well he probably meant C-y, so lets yank!" .. But, unbeknown to Mr Algorithm, I actually mistyped C-S-u (today), and the other day (many days actually), I was just testing for unassigned keys via C-h k and kept getting presented with unnecessary descriptions of a down-keyed functions which I have no interest in.. I don't understand why, nor the algorithm. –  Peter.O Nov 29 '11 at 16:18
add comment

2 Answers

up vote 6 down vote accepted

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.

share|improve this answer
    
Thanks. It's not that I don't like it per se. It's more, "What's going on here?". I would prefer the behaviour to be what I'm used to, but emacs keeps showing me there are other paradigms which typically work in more functional/productive ways. Certainly describe-unbound-keys (unbound.el) will resolve many of my "encounters with the unfamiliar". Reading your link, I see that read-key-sequence.. functions cater for dont-downcase-last.. Ok! I still don't understand why the default behaviour is as-is, but I assume it is well considered, and will become clear down the line. –  Peter.O Nov 30 '11 at 3:38
1  
PS. the unbound key list is great! –  Peter.O Nov 30 '11 at 4:03
    
Perhaps the reason for this behaviour is that it allows keys like 'C-f' and 'right-arrow' (forward-char) to behave fundamentally the same, whether shifted or not, and yet react to the shift-key status according to highlighting rules? .. I say/ask this because C-h k for the shifted and vanilla versions of these key-presses shows that they are are both bound to (forward-char), and for C-S-f it says: C-f (translated from C-S-f).. And, actually, C-S-f shows up as unbound, according to describe-unbound-keys; but it certainly acts like it has its own binding.. –  Peter.O Nov 30 '11 at 5:45
    
(1.) The describe-unbound-keys function doesn't seem to be a standard part of Emacs, at least not on the version I'm running (24.2). But it can be downloaded here. (2.) In my .emacs, I've bound one function to C-z (which usually minimizes the frame) and another to C-Z, but whichever keystroke I use, it's always the former function that gets executed. (Switching definition order makes no difference.) Maybe this happens because C-z is bound to function suspend-frame by default? –  Teemu Leisti Oct 17 '12 at 7:28
    
@TeemuLeisti I've updated the answer to have a link to the required library. Thanks. –  Trey Jackson Oct 17 '12 at 18:18
show 1 more comment

There's no setting that disables the behavior for all keys. For specific shifted key combinations you can bind the key to ignore which will prevent Emacs from automapping the key to the unshifted version.

As for why the automapping exists, one advantage of this system is that it lets you use Emacs on uppercase-only terminals without having to duplicate all the (usually) lowercase bindings. GNU Emacs is old enough to have been around when plenty of such terminals were still in use.

share|improve this answer
    
This is useful information, and I initially upvoted it, but it's really a comment, not an answer. (In other words, it does not supply the information that the question requests.) I'd gladly upvote it if you converted it to a comment. (I don't have enough reputation to do that. Perhaps you do.) –  iconoclast Aug 30 '12 at 15:14
1  
The second part of the question says " I'd also like to know what advantage this (dubious) feature offers...", so that's why I posted this as an answer. But I'll also answer the first part of the question. –  Kyle Jones Aug 30 '12 at 15:37
    
d'oh! you're right. My mistake. –  iconoclast Aug 30 '12 at 15:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.