Thursday, July 06, 2006

How to tell emacs what to do when it receives a Delete or Backspace

Put in your .emacs file lines like

        (global-set-key "\?" 'help-command)
(global-set-key "\C-h" 'delete-backward-char)
Of course you can bind other commands to other keys in the same way. Note that various major and minor modes redefine keybindings. For example, in incremental search mode one finds the code
        (define-key map "\177" 'isearch-delete-char)
(define-key map "\C-h" 'isearch-mode-help)
This means that it may be a bad idea to use the above two global-set-key commands. There are too many places where there are built-in assumptions about Ctrl-H = help and DEL = delete. That doesn't mean that you have to setup keys so that Backspace generates DEL. But if it doesn't then it is easiest to remap them at the lowest possible level in emacs.

http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html



Below is to redefine keys.

http://cnsnap.cn.freebsd.org/doc/zh_CN.GB2312/books/developers-handbook/emacs.html

http://www-rcf.usc.edu/~christoj/.emacs

No comments: