Why the key binding M-S-t fails while C-S-t works?

2019-01-15 22:20发布

I got the question from this question, it seems we can't bind shift with meta like M-S-t (always translated to M-t), but we can do it with control like C-S-t (works as C-T).

As the accepted answer said, we can use M-T instead, but why we can't use it with meta? Does Emacs just ignore shift when used with meta?

1条回答
我只想做你的唯一
2楼-- · 2019-01-15 22:54

I think Emacs ignores S- for letters when Ctrl is not also used.

i.e. it's nothing to do with Meta in particular; the same thing applies to the other non-Ctrl modifiers (and indeed without other modifiers -- you also can't bind to plain S-t).

The justification may be that Ctrl keys are the only case where an explicit shift modifier is needed for letters:

(emacs) Modifier Keys says

The default key bindings in Emacs are set up so that modified
alphabetical characters are case-insensitive.  In other words, ‘C-A’
does the same thing as ‘C-a’, and ‘M-A’ does the same thing as ‘M-a’.
This concerns only alphabetical characters, and does not apply to
“shifted” versions of other keys; for instance, ‘C-@’ is not the same as
‘C-2’.

   A <Control>-modified alphabetical character is always considered
case-insensitive: Emacs always treats ‘C-A’ as ‘C-a’, ‘C-B’ as ‘C-b’,
and so forth.  The reason for this is historical.

   For all other modifiers, you can make the modified alphabetical
characters case-sensitive when you customize Emacs.  For instance, you
could make ‘M-a’ and ‘M-A’ run different commands.

By my recollection terminals do not distinguish case for control characters, so I would speculate that the "historical" reasons are related to that.

It would be reasonable for this to at least be documented in the manual. You may wish to M-x report-emacs-bug to suggest such an improvement, if no relevant bug exists at present.

Note that the Shift modifier can be used with non-letter keys, with or without other modifiers. M-S-SPC is a recognised sequence, for example.

查看更多
登录 后发表回答