Asked by
Develop
in
Computers & Technology
at
6:09 PM on September 20, 2008
Read all answers
shivneet's Answer
The way to redefine an Emacs key is to change its entry in a keymap. You can change the global keymap, in which case the change is effective in all major modes (except those that have their own overriding local definitions for the same key). Or you can change the current buffer's local map, which affects all buffers using the same major mode.
M-x global-set-key RET key cmd RET
Define key globally to run cmd.
M-x local-set-key RET key cmd RET
Define key locally (in the major mode now in effect) to run cmd.
M-x global-unset-key RET key
Make key undefined in the global map.
M-x local-unset-key RET key
Make key undefined locally (in the major mode now in effect).
For example, suppose you like to execute commands in a subshell within an Emacs buffer, instead of suspending Emacs and executing commands in your login shell. Normally, C-z is bound to the function suspend-emacs (when not using the X Window System), but you can change C-z to invoke an interactive subshell within Emacs, by binding it to shell as follows:
M-x global-set-key RET C-z shell RET
global-set-key reads the command name after the key. After you press the key, a message like this appears so that you can confirm that you are binding the key you want:
Answered at
7:52 PM on September 20, 2008
|
Read Comments [0]