I am not able to bind Meta + Shift + any character.

I do not experience these problems with other key combinations (such as Control + Shift + Key).

Below is the specific case that I cannot get to work:

(global-set-key (kbd "M-S-Z") 'zap-up-to-char-backward)
(defun zap-up-to-char-backward (char)
  (interactive "cZap up to char (backward): ")
  (zap-up-to-char -1 char))
  • Maybe M-S-<char> is intercepted by your DE for its own nefarious purposes? It may be that Emacs never sees it. – NickD Oct 14 '20 at 13:28

M-S-Z would mean Meta + Shift + Z. But Z (uppercase) is itself what Emacs uses for Shift> + z.

There's likely no key on your keyboard corresponding to S-Z. That's why you say it doesn't work.

If you use C-h b you'll find your key binding listed OK. And if you use C-h w zap-up-to-char-backward you'll see that it says it's bound to M-S-Z.

The problem is that you have no way of typing such a key sequence with your keyboard.

C- is special, in that C-Z is interpreted as the Control character C-z, that is, ASCII Control Z.

It's unclear what you really want to do. Do you want to bind keyboard key combination Meta + Shift> + z? If so, use (kbd "M-Z"), not (kbd "M-S-z") or (kbd "M-S-Z").

  • That solved it -- thanks! I guess the C- case got me confused, thinking M- would follow a similar pattern. – jloow Oct 15 '20 at 11:10
  • Both C- and M- are a bit special, for different reasons: C- because of ASCII control chars and M- because of the use of ESC etc. – Drew Oct 15 '20 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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