[gnu.emacs.bug] Escape key on VT220

gildea@ALEXANDER.BBN.COM (Stephen Gildea) (11/22/88)

Yes, the VT220 keyboard is poorly designed.  Here is a simple fix that will
make ` work as ESC.  (I actually use something more complicated that allows
me to run the terminal in VT200 mode.)  This code also doesn't allow you to
type C-x ` for C-x ESC (M-x repeat-complex-command).  Since C-x ` already
has a binding, I recommend that you put repeat-complex-command on some other
key.  I use ESC C-y.

 < Stephen


;;; gildea@bbn.com 21 Nov 88
(defun simple-ESC (simple-esc-arg)
  "Imitate the Escape key.  Not suitable for binding to a keypad key."
  (interactive "P")
  (setq prefix-arg simple-esc-arg)
  (setq unread-command-char ?\e))

(if (string-match "^vt2" (getenv "TERM"))
    (progn
      ;; make ` work like ESC since it stole ESC's place on the keyboard.
      ;; DEC keyboard design loses again.
      ;; I don't fix C-x ESC because I use C-M-y instead.
      (global-set-key "`" 'simple-ESC)
      (global-set-key "\e`" (key-binding "\e\e"))))