Subject: Re: Backspace key in X (and emacs)
To: None <email@example.com>
From: Greg A. Woods <firstname.lastname@example.org>
Date: 05/15/2000 16:16:16
[ On Sunday, May 14, 2000 at 23:54:01 (+1200), Dave Sainty wrote: ]
> Subject: Re: Backspace key in X
> I assumed the problem was Emacs under xterm. Emacs under X just does
> the right thing...
> As usual :)
Well, that depends.
Some of us grew up with older DEC terminals, such as the real vt100,
where the key labeled <backspace> generated an ASCII 0x08 (i.e. Ctrl-H).
We also grew up using systems where ASCI DEL (0x7f, i.e. Ctrl-?, aka
RUBOUT) was the default tty interrupt character and where the local lore
was that you should set your "stty erase" character to <Ctrl-H> if you
didn't like the default of '#' (say, for example, because you like to
write scripts where that was the comment character and you were tired of
having to prefix it with '\' ;-). Until I had encountered GNU Emacs
(the third major variant of Emacs I'd used), I'd never even heard of
this hearsay of using <DEL> for "stty erase", not to mention that in V7
(or any Unix with only the original "sgtty" interface) you couldn't even
change the setting for "stty intr" (or "stty eof", or "stty quit", and
definitely not "stty stop" or "stty start")!
So, if you really want your <Backspace> key to generate a <Ctrl-H>, and
you want your <Delete> key to generate a <Ctrl-?> and you want
everything to be consistent everywhere, i.e. either in a normal tty
interface, or in X11, then you do have to fix your emacs configuration
too (I've used the following for ages and it works in 20.6 just fine
over both a tty connection and under X11):
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\C-?" 'delete-char)
(global-set-key "\e\C-h" 'backward-kill-word)
(global-set-key "\e\C-?" 'kill-word)
(global-set-key [f1] 'help-command) ; first do this for 19.28.
(global-set-key "\e?" 'help-command) ; this is the first step to set up help
(global-set-key "\e?F" 'view-emacs-FAQ) ; in 19.34 it needs more help...
(setq help-char ?\M-?) ; this should "fix" the rest.
(define-key function-key-map [backspace] [?\C-h])
(define-key function-key-map [M-backspace] [?\M-\C-h])
;; Remember to call override-local-key-settings in the appropriate hooks to fix
;; up modes which violate global user preferences....
(defun override-local-key-settings ()
"User defined function. Intended to be called within various hooks to
override the value of buffer-local key map settings which may have been
overridden without consideration by the major mode."
(local-set-key "\C-?" 'delete-char) ; many modes
;; the rest are *not* overridden by cc-mode, but are by c-mode
(local-set-key "\e\C-h" 'backward-kill-word) ; text-mode
(local-set-key "\e?" 'help-command) ; nroff-mode
(local-set-key "\eh" 'mark-c-function)
(local-set-key "\e\C-?" 'kill-word)
(local-set-key "\e\C-e" 'compile)
;; try this on for size...
(local-set-key "\C-x\e\C-e" 'recompile)
Greg A. Woods
+1 416 218-0098 VE3TCP <email@example.com> <robohack!woods>
Planix, Inc. <firstname.lastname@example.org>; Secrets of the Weird <email@example.com>