How to create case-sensitive keybinding in Emacs?

According to the Emacs manual , modifier keys are not case sensitive for "historical reasons."

Can I change this behavior?

My goal is to make Ma and Ma mean different things.

Thanks!

+6
source share
1 answer

According to the manual,

A Control- modified alphabetical character is always considered case-insensitive: Emacs always treats CA as Ca, CB as Cb, and so on. The reason for this is historical.

Thus, you cannot define them as:

 (global-set-key (kbd "Ca") 'xxx) (global-set-key (kbd "CA") 'yyy) 

but S- can be used for Shift , therefore:

 (global-set-key (kbd "Ca") 'xxx) (global-set-key (kbd "CSa") 'yyy) ;; CA 

OK. AND

For all other modifiers, you can make the changed alphabetical characters case sensitive when you configure Emacs. For example, you can force Ma and MA to execute different commands.

So you can define the key binding as follows:

 (global-set-key (kbd "Ma") 'xxx) (global-set-key (kbd "MA") 'yyy) 
+8
source

Source: https://habr.com/ru/post/970725/


All Articles