To What Should C-h Be Bound?

Now that we've bound help-command to M-?, the next thing to do is to change the binding for C-h. Using exactly the same process just described—that is, running describe-bindings (with either C-h b or M-? b at this point)—we find that the command invoked by DEL is delete-backward-char.

So we can write

(global-set-key "\C-h" 'delete-backward-char)

Now DEL and C-h do the same thing. If you put these lines into your .emacs file:

(global-set-key "\M-?" 'help-command)
(global-set-key "\C-h" 'delete-backward-char)

then in your future Emacs sessions, your BACKSPACE/DELETE/ERASE key will do the right thing, whether it sends a BS code or a DEL code. But how can we cause these changes to take effect in the current session? This requires explicit evaluation of these two Lisp expressions.

Get Writing GNU Emacs Extensions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.