Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...