1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-30 08:09:04 +00:00

Speed up `emacsclient -t' on xterms. (by suggestion of Dan Nicolaescu)

* lisp/term/xterm.el: Speed up load time by protecting
  `substitute-key-definition' and `define-key' calls against multiple
  execution.

* lisp/term/rxvt.el: Ditto.
* lisp/term/lk201.el: Ditto.

git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-345
This commit is contained in:
Karoly Lorentey 2005-05-14 01:56:59 +00:00
parent 892f9671ad
commit 133fe4c8a2
3 changed files with 339 additions and 330 deletions

View File

@ -1,74 +1,87 @@
;; -*- no-byte-compile: t -*-
;; Define function key sequences for DEC terminals.
;; XXX We need to find a way to have these define-keys be display-local. -- Lorentey
(defvar lk201-function-map nil
"Function key definitions for lk201.")
;; Termcap or terminfo should set these.
;; (define-key function-key-map "\e[A" [up])
;; (define-key function-key-map "\e[B" [down])
;; (define-key function-key-map "\e[C" [right])
;; (define-key function-key-map "\e[D" [left])
;; Protect against reloads.
(unless lk201-function-map
(setq lk201-function-map (make-sparse-keymap))
(define-key function-key-map "\e[1~" [find])
(define-key function-key-map "\e[2~" [insert])
(define-key function-key-map "\e[3~" [delete])
(define-key function-key-map "\e[4~" [select])
(define-key function-key-map "\e[5~" [prior])
(define-key function-key-map "\e[6~" [next])
(define-key function-key-map "\e[11~" [f1])
(define-key function-key-map "\e[12~" [f2])
(define-key function-key-map "\e[13~" [f3])
(define-key function-key-map "\e[14~" [f4])
(define-key function-key-map "\e[15~" [f5])
(define-key function-key-map "\e[17~" [f6])
(define-key function-key-map "\e[18~" [f7])
(define-key function-key-map "\e[19~" [f8])
(define-key function-key-map "\e[20~" [f9])
(define-key function-key-map "\e[21~" [f10])
;; Customarily F11 is used as the ESC key.
;; The file that includes this one, takes care of that.
(define-key function-key-map "\e[23~" [f11])
(define-key function-key-map "\e[24~" [f12])
(define-key function-key-map "\e[25~" [f13])
(define-key function-key-map "\e[26~" [f14])
(define-key function-key-map "\e[28~" [help])
(define-key function-key-map "\e[29~" [menu])
(define-key function-key-map "\e[31~" [f17])
(define-key function-key-map "\e[32~" [f18])
(define-key function-key-map "\e[33~" [f19])
(define-key function-key-map "\e[34~" [f20])
;; XXX We need to find a way to have these define-keys be display-local. -- Lorentey
;; Termcap or terminfo should set these.
;; (define-key function-key-map "\eOA" [up])
;; (define-key function-key-map "\eOB" [down])
;; (define-key function-key-map "\eOC" [right])
;; (define-key function-key-map "\eOD" [left])
;; Termcap or terminfo should set these.
;; (define-key function-key-map "\e[A" [up])
;; (define-key function-key-map "\e[B" [down])
;; (define-key function-key-map "\e[C" [right])
;; (define-key function-key-map "\e[D" [left])
;; Termcap or terminfo should set these, but doesn't properly.
;; Termcap sets these to k1-k4, which get mapped to f1-f4 in term.c
(define-key function-key-map "\eOP" [kp-f1])
(define-key function-key-map "\eOQ" [kp-f2])
(define-key function-key-map "\eOR" [kp-f3])
(define-key function-key-map "\eOS" [kp-f4])
(define-key function-key-map "\e[1~" [find])
(define-key function-key-map "\e[2~" [insert])
(define-key function-key-map "\e[3~" [delete])
(define-key function-key-map "\e[4~" [select])
(define-key function-key-map "\e[5~" [prior])
(define-key function-key-map "\e[6~" [next])
(define-key function-key-map "\e[11~" [f1])
(define-key function-key-map "\e[12~" [f2])
(define-key function-key-map "\e[13~" [f3])
(define-key function-key-map "\e[14~" [f4])
(define-key function-key-map "\e[15~" [f5])
(define-key function-key-map "\e[17~" [f6])
(define-key function-key-map "\e[18~" [f7])
(define-key function-key-map "\e[19~" [f8])
(define-key function-key-map "\e[20~" [f9])
(define-key function-key-map "\e[21~" [f10])
;; Customarily F11 is used as the ESC key.
;; The file that includes this one, takes care of that.
(define-key function-key-map "\e[23~" [f11])
(define-key function-key-map "\e[24~" [f12])
(define-key function-key-map "\e[25~" [f13])
(define-key function-key-map "\e[26~" [f14])
(define-key function-key-map "\e[28~" [help])
(define-key function-key-map "\e[29~" [menu])
(define-key function-key-map "\e[31~" [f17])
(define-key function-key-map "\e[32~" [f18])
(define-key function-key-map "\e[33~" [f19])
(define-key function-key-map "\e[34~" [f20])
(define-key function-key-map "\eOI" [kp-tab])
(define-key function-key-map "\eOj" [kp-multiply])
(define-key function-key-map "\eOk" [kp-add])
(define-key function-key-map "\eOl" [kp-separator])
(define-key function-key-map "\eOM" [kp-enter])
(define-key function-key-map "\eOm" [kp-subtract])
(define-key function-key-map "\eOn" [kp-decimal])
(define-key function-key-map "\eOo" [kp-divide])
(define-key function-key-map "\eOp" [kp-0])
(define-key function-key-map "\eOq" [kp-1])
(define-key function-key-map "\eOr" [kp-2])
(define-key function-key-map "\eOs" [kp-3])
(define-key function-key-map "\eOt" [kp-4])
(define-key function-key-map "\eOu" [kp-5])
(define-key function-key-map "\eOv" [kp-6])
(define-key function-key-map "\eOw" [kp-7])
(define-key function-key-map "\eOx" [kp-8])
(define-key function-key-map "\eOy" [kp-9])
;; Termcap or terminfo should set these.
;; (define-key function-key-map "\eOA" [up])
;; (define-key function-key-map "\eOB" [down])
;; (define-key function-key-map "\eOC" [right])
;; (define-key function-key-map "\eOD" [left])
;; Termcap or terminfo should set these, but doesn't properly.
;; Termcap sets these to k1-k4, which get mapped to f1-f4 in term.c
(define-key function-key-map "\eOP" [kp-f1])
(define-key function-key-map "\eOQ" [kp-f2])
(define-key function-key-map "\eOR" [kp-f3])
(define-key function-key-map "\eOS" [kp-f4])
(define-key function-key-map "\eOI" [kp-tab])
(define-key function-key-map "\eOj" [kp-multiply])
(define-key function-key-map "\eOk" [kp-add])
(define-key function-key-map "\eOl" [kp-separator])
(define-key function-key-map "\eOM" [kp-enter])
(define-key function-key-map "\eOm" [kp-subtract])
(define-key function-key-map "\eOn" [kp-decimal])
(define-key function-key-map "\eOo" [kp-divide])
(define-key function-key-map "\eOp" [kp-0])
(define-key function-key-map "\eOq" [kp-1])
(define-key function-key-map "\eOr" [kp-2])
(define-key function-key-map "\eOs" [kp-3])
(define-key function-key-map "\eOt" [kp-4])
(define-key function-key-map "\eOu" [kp-5])
(define-key function-key-map "\eOv" [kp-6])
(define-key function-key-map "\eOw" [kp-7])
(define-key function-key-map "\eOx" [kp-8])
(define-key function-key-map "\eOy" [kp-9])
;; Use inheritance to let the main keymap override these defaults.
;; This way we don't override terminfo-derived settings or settings
;; made in the .emacs file.
(set-keymap-parent lk201-function-map (keymap-parent function-key-map))
(set-keymap-parent function-key-map lk201-function-map))
;;; arch-tag: 7ffb4444-6a23-43e1-b457-43cf4f673c0d
;;; lk201.el ends here

View File

@ -28,80 +28,78 @@
(require 'server)
(defvar rxvt-function-map (make-sparse-keymap)
"Function key rxvt-function-mapoverrides for rxvt.")
(defvar rxvt-function-map nil
"Function key overrides for rxvt.")
;; Set up function-key-map entries that termcap and terminfo don't know.
;; XXX We need to find a way to have these define-keys be display-local. -- Lorentey
(define-key rxvt-function-map "\e[A" [up])
(define-key rxvt-function-map "\e[B" [down])
(define-key rxvt-function-map "\e[C" [right])
(define-key rxvt-function-map "\e[D" [left])
(define-key rxvt-function-map "\e[7~" [home])
(define-key rxvt-function-map "\e[2~" [insert])
(define-key rxvt-function-map "\e[3~" [delete])
(define-key rxvt-function-map "\e[4~" [select])
(define-key rxvt-function-map "\e[5~" [prior])
(define-key rxvt-function-map "\e[6~" [next])
(define-key rxvt-function-map "\e[11~" [f1])
(define-key rxvt-function-map "\e[12~" [f2])
(define-key rxvt-function-map "\e[13~" [f3])
(define-key rxvt-function-map "\e[14~" [f4])
(define-key rxvt-function-map "\e[15~" [f5])
(define-key rxvt-function-map "\e[17~" [f6])
(define-key rxvt-function-map "\e[18~" [f7])
(define-key rxvt-function-map "\e[19~" [f8])
(define-key rxvt-function-map "\e[20~" [f9])
(define-key rxvt-function-map "\e[21~" [f10])
(define-key rxvt-function-map "\e[23~" [f11])
(define-key rxvt-function-map "\e[24~" [f12])
(define-key rxvt-function-map "\e[29~" [print])
;; Protect against reloads.
(unless rxvt-function-map
(setq rxvt-function-map (make-sparse-keymap))
(define-key rxvt-function-map "\e[11^" [C-f1])
(define-key rxvt-function-map "\e[12^" [C-f2])
(define-key rxvt-function-map "\e[13^" [C-f3])
(define-key rxvt-function-map "\e[14^" [C-f4])
(define-key rxvt-function-map "\e[15^" [C-f5])
(define-key rxvt-function-map "\e[17^" [C-f6])
(define-key rxvt-function-map "\e[18^" [C-f7])
(define-key rxvt-function-map "\e[19^" [C-f8])
(define-key rxvt-function-map "\e[20^" [C-f9])
(define-key rxvt-function-map "\e[21^" [C-f10])
(define-key rxvt-function-map "\e[23^" [C-f11])
(define-key rxvt-function-map "\e[24^" [C-f12])
;; Set up function-key-map entries that termcap and terminfo don't know.
;; XXX We need to find a way to have these define-keys be display-local. -- Lorentey
(define-key rxvt-function-map "\e[A" [up])
(define-key rxvt-function-map "\e[B" [down])
(define-key rxvt-function-map "\e[C" [right])
(define-key rxvt-function-map "\e[D" [left])
(define-key rxvt-function-map "\e[7~" [home])
(define-key rxvt-function-map "\e[2~" [insert])
(define-key rxvt-function-map "\e[3~" [delete])
(define-key rxvt-function-map "\e[4~" [select])
(define-key rxvt-function-map "\e[5~" [prior])
(define-key rxvt-function-map "\e[6~" [next])
(define-key rxvt-function-map "\e[11~" [f1])
(define-key rxvt-function-map "\e[12~" [f2])
(define-key rxvt-function-map "\e[13~" [f3])
(define-key rxvt-function-map "\e[14~" [f4])
(define-key rxvt-function-map "\e[15~" [f5])
(define-key rxvt-function-map "\e[17~" [f6])
(define-key rxvt-function-map "\e[18~" [f7])
(define-key rxvt-function-map "\e[19~" [f8])
(define-key rxvt-function-map "\e[20~" [f9])
(define-key rxvt-function-map "\e[21~" [f10])
(define-key rxvt-function-map "\e[23~" [f11])
(define-key rxvt-function-map "\e[24~" [f12])
(define-key rxvt-function-map "\e[29~" [print])
(define-key rxvt-function-map "\e[29~" [print])
(define-key rxvt-function-map "\e[11^" [C-f1])
(define-key rxvt-function-map "\e[12^" [C-f2])
(define-key rxvt-function-map "\e[13^" [C-f3])
(define-key rxvt-function-map "\e[14^" [C-f4])
(define-key rxvt-function-map "\e[15^" [C-f5])
(define-key rxvt-function-map "\e[17^" [C-f6])
(define-key rxvt-function-map "\e[18^" [C-f7])
(define-key rxvt-function-map "\e[19^" [C-f8])
(define-key rxvt-function-map "\e[20^" [C-f9])
(define-key rxvt-function-map "\e[21^" [C-f10])
(define-key rxvt-function-map "\e[23^" [C-f11])
(define-key rxvt-function-map "\e[24^" [C-f12])
(define-key rxvt-function-map "\e[2;2~" [S-insert])
(define-key rxvt-function-map "\e[3$" [S-delete])
(define-key rxvt-function-map "\e[29~" [print])
(define-key rxvt-function-map "\e[2^" [C-insert])
(define-key rxvt-function-map "\e[3^" [C-delete])
(define-key rxvt-function-map "\e[5^" [C-prior])
(define-key rxvt-function-map "\e[6^" [C-next])
(define-key rxvt-function-map "\eOd" [C-left])
(define-key rxvt-function-map "\eOc" [C-right])
(define-key rxvt-function-map "\eOa" [C-up])
(define-key rxvt-function-map "\eOb" [C-down])
(define-key rxvt-function-map "\e[2;2~" [S-insert])
(define-key rxvt-function-map "\e[3$" [S-delete])
(define-key rxvt-function-map "\e[5$" [S-prior])
(define-key rxvt-function-map "\e[6$" [S-next])
(define-key rxvt-function-map "\e[8$" [S-end])
(define-key rxvt-function-map "\e[7$" [S-home])
(define-key rxvt-function-map "\e[d" [S-left])
(define-key rxvt-function-map "\e[c" [S-right])
(define-key rxvt-function-map "\e[a" [S-up])
(define-key rxvt-function-map "\e[b" [S-down])
(define-key rxvt-function-map "\e[2^" [C-insert])
(define-key rxvt-function-map "\e[3^" [C-delete])
(define-key rxvt-function-map "\e[5^" [C-prior])
(define-key rxvt-function-map "\e[6^" [C-next])
(define-key rxvt-function-map "\eOd" [C-left])
(define-key rxvt-function-map "\eOc" [C-right])
(define-key rxvt-function-map "\eOa" [C-up])
(define-key rxvt-function-map "\eOb" [C-down])
;; Use inheritance to let the main keymap override those defaults.
;; This way we don't override terminfo-derived settings or settings
;; made in the .emacs file.
(unless (let ((map (keymap-parent function-key-map))
found)
(while (and (not found) map)
(setq found (eq rxvt-function-map map)
map (keymap-parent map)))
found)
(define-key rxvt-function-map "\e[5$" [S-prior])
(define-key rxvt-function-map "\e[6$" [S-next])
(define-key rxvt-function-map "\e[8$" [S-end])
(define-key rxvt-function-map "\e[7$" [S-home])
(define-key rxvt-function-map "\e[d" [S-left])
(define-key rxvt-function-map "\e[c" [S-right])
(define-key rxvt-function-map "\e[a" [S-up])
(define-key rxvt-function-map "\e[b" [S-down])
;; Use inheritance to let the main keymap override those defaults.
;; This way we don't override terminfo-derived settings or settings
;; made in the .emacs file.
(set-keymap-parent rxvt-function-map (keymap-parent function-key-map))
(set-keymap-parent function-key-map rxvt-function-map))

View File

@ -28,230 +28,228 @@
(require 'server)
(defvar xterm-function-map (make-sparse-keymap)
(defvar xterm-function-map nil
"Function key map overrides for xterm.")
;; XXX We need to find a way to have these definitions be display-local. -- Lorentey
;; Protect against reloads.
(unless xterm-function-map
(setq xterm-function-map (make-sparse-keymap))
;;; The terminal intialization C code file might have initialized
;;; function keys F13->F60 from the termcap/terminfo information. On
;;; a PC-style keyboard these keys correspond to
;;; MODIFIER-FUNCTION_KEY, where modifier is S-, C, A-, C-S-. The
;;; code here subsitutes the corresponding defintions in
;;; function-key-map. This substitution is needed because if a key
;;; definition if found in function-key-map, there are no further
;;; lookups in other keymaps.
(substitute-key-definition [f13] [S-f1] function-key-map)
(substitute-key-definition [f14] [S-f2] function-key-map)
(substitute-key-definition [f15] [S-f3] function-key-map)
(substitute-key-definition [f16] [S-f4] function-key-map)
(substitute-key-definition [f17] [S-f5] function-key-map)
(substitute-key-definition [f18] [S-f6] function-key-map)
(substitute-key-definition [f19] [S-f7] function-key-map)
(substitute-key-definition [f20] [S-f8] function-key-map)
(substitute-key-definition [f21] [S-f9] function-key-map)
(substitute-key-definition [f22] [S-f10] function-key-map)
(substitute-key-definition [f23] [S-f11] function-key-map)
(substitute-key-definition [f24] [S-f12] function-key-map)
;; XXX We need to find a way to make these definitions display-local. -- Lorentey
(substitute-key-definition [f25] [C-f1] function-key-map)
(substitute-key-definition [f26] [C-f2] function-key-map)
(substitute-key-definition [f27] [C-f3] function-key-map)
(substitute-key-definition [f28] [C-f4] function-key-map)
(substitute-key-definition [f29] [C-f5] function-key-map)
(substitute-key-definition [f30] [C-f6] function-key-map)
(substitute-key-definition [f31] [C-f7] function-key-map)
(substitute-key-definition [f32] [C-f8] function-key-map)
(substitute-key-definition [f33] [C-f9] function-key-map)
(substitute-key-definition [f34] [C-f10] function-key-map)
(substitute-key-definition [f35] [C-f11] function-key-map)
(substitute-key-definition [f36] [C-f12] function-key-map)
;; The terminal intialization C code file might have initialized
;; function keys F13->F60 from the termcap/terminfo information. On
;; a PC-style keyboard these keys correspond to
;; MODIFIER-FUNCTION_KEY, where modifier is S-, C, A-, C-S-. The
;; code here subsitutes the corresponding defintions in
;; function-key-map. This substitution is needed because if a key
;; definition if found in function-key-map, there are no further
;; lookups in other keymaps.
(substitute-key-definition [f13] [S-f1] function-key-map)
(substitute-key-definition [f14] [S-f2] function-key-map)
(substitute-key-definition [f15] [S-f3] function-key-map)
(substitute-key-definition [f16] [S-f4] function-key-map)
(substitute-key-definition [f17] [S-f5] function-key-map)
(substitute-key-definition [f18] [S-f6] function-key-map)
(substitute-key-definition [f19] [S-f7] function-key-map)
(substitute-key-definition [f20] [S-f8] function-key-map)
(substitute-key-definition [f21] [S-f9] function-key-map)
(substitute-key-definition [f22] [S-f10] function-key-map)
(substitute-key-definition [f23] [S-f11] function-key-map)
(substitute-key-definition [f24] [S-f12] function-key-map)
(substitute-key-definition [f37] [C-S-f1] function-key-map)
(substitute-key-definition [f38] [C-S-f2] function-key-map)
(substitute-key-definition [f39] [C-S-f3] function-key-map)
(substitute-key-definition [f40] [C-S-f4] function-key-map)
(substitute-key-definition [f41] [C-S-f5] function-key-map)
(substitute-key-definition [f42] [C-S-f6] function-key-map)
(substitute-key-definition [f43] [C-S-f7] function-key-map)
(substitute-key-definition [f44] [C-S-f8] function-key-map)
(substitute-key-definition [f45] [C-S-f9] function-key-map)
(substitute-key-definition [f46] [C-S-f10] function-key-map)
(substitute-key-definition [f47] [C-S-f11] function-key-map)
(substitute-key-definition [f48] [C-S-f12] function-key-map)
(substitute-key-definition [f25] [C-f1] function-key-map)
(substitute-key-definition [f26] [C-f2] function-key-map)
(substitute-key-definition [f27] [C-f3] function-key-map)
(substitute-key-definition [f28] [C-f4] function-key-map)
(substitute-key-definition [f29] [C-f5] function-key-map)
(substitute-key-definition [f30] [C-f6] function-key-map)
(substitute-key-definition [f31] [C-f7] function-key-map)
(substitute-key-definition [f32] [C-f8] function-key-map)
(substitute-key-definition [f33] [C-f9] function-key-map)
(substitute-key-definition [f34] [C-f10] function-key-map)
(substitute-key-definition [f35] [C-f11] function-key-map)
(substitute-key-definition [f36] [C-f12] function-key-map)
(substitute-key-definition [f49] [A-f1] function-key-map)
(substitute-key-definition [f50] [A-f2] function-key-map)
(substitute-key-definition [f51] [A-f3] function-key-map)
(substitute-key-definition [f52] [A-f4] function-key-map)
(substitute-key-definition [f53] [A-f5] function-key-map)
(substitute-key-definition [f54] [A-f6] function-key-map)
(substitute-key-definition [f55] [A-f7] function-key-map)
(substitute-key-definition [f56] [A-f8] function-key-map)
(substitute-key-definition [f57] [A-f9] function-key-map)
(substitute-key-definition [f58] [A-f10] function-key-map)
(substitute-key-definition [f59] [A-f11] function-key-map)
(substitute-key-definition [f60] [A-f12] function-key-map)
(substitute-key-definition [f37] [C-S-f1] function-key-map)
(substitute-key-definition [f38] [C-S-f2] function-key-map)
(substitute-key-definition [f39] [C-S-f3] function-key-map)
(substitute-key-definition [f40] [C-S-f4] function-key-map)
(substitute-key-definition [f41] [C-S-f5] function-key-map)
(substitute-key-definition [f42] [C-S-f6] function-key-map)
(substitute-key-definition [f43] [C-S-f7] function-key-map)
(substitute-key-definition [f44] [C-S-f8] function-key-map)
(substitute-key-definition [f45] [C-S-f9] function-key-map)
(substitute-key-definition [f46] [C-S-f10] function-key-map)
(substitute-key-definition [f47] [C-S-f11] function-key-map)
(substitute-key-definition [f48] [C-S-f12] function-key-map)
(define-key xterm-function-map "\e[A" [up])
(define-key xterm-function-map "\e[B" [down])
(define-key xterm-function-map "\e[C" [right])
(define-key xterm-function-map "\e[D" [left])
(define-key xterm-function-map "\e[1~" [home])
(define-key xterm-function-map "\e[2~" [insert])
(define-key xterm-function-map "\e[3~" [delete])
(define-key xterm-function-map "\e[4~" [select])
(define-key xterm-function-map "\e[5~" [prior])
(define-key xterm-function-map "\e[6~" [next])
(define-key xterm-function-map "\e[11~" [f1])
(define-key xterm-function-map "\e[12~" [f2])
(define-key xterm-function-map "\e[13~" [f3])
(define-key xterm-function-map "\e[14~" [f4])
(define-key xterm-function-map "\e[15~" [f5])
(define-key xterm-function-map "\e[17~" [f6])
(define-key xterm-function-map "\e[18~" [f7])
(define-key xterm-function-map "\e[19~" [f8])
(define-key xterm-function-map "\e[20~" [f9])
(define-key xterm-function-map "\e[21~" [f10])
(define-key xterm-function-map "\e[23~" [f11])
(define-key xterm-function-map "\e[24~" [f12])
(define-key xterm-function-map "\e[29~" [print])
(substitute-key-definition [f49] [A-f1] function-key-map)
(substitute-key-definition [f50] [A-f2] function-key-map)
(substitute-key-definition [f51] [A-f3] function-key-map)
(substitute-key-definition [f52] [A-f4] function-key-map)
(substitute-key-definition [f53] [A-f5] function-key-map)
(substitute-key-definition [f54] [A-f6] function-key-map)
(substitute-key-definition [f55] [A-f7] function-key-map)
(substitute-key-definition [f56] [A-f8] function-key-map)
(substitute-key-definition [f57] [A-f9] function-key-map)
(substitute-key-definition [f58] [A-f10] function-key-map)
(substitute-key-definition [f59] [A-f11] function-key-map)
(substitute-key-definition [f60] [A-f12] function-key-map)
(define-key xterm-function-map "\eOP" [f1])
(define-key xterm-function-map "\eOQ" [f2])
(define-key xterm-function-map "\eOR" [f3])
(define-key xterm-function-map "\eOS" [f4])
(define-key xterm-function-map "\e[A" [up])
(define-key xterm-function-map "\e[B" [down])
(define-key xterm-function-map "\e[C" [right])
(define-key xterm-function-map "\e[D" [left])
(define-key xterm-function-map "\e[1~" [home])
(define-key xterm-function-map "\e[2~" [insert])
(define-key xterm-function-map "\e[3~" [delete])
(define-key xterm-function-map "\e[4~" [select])
(define-key xterm-function-map "\e[5~" [prior])
(define-key xterm-function-map "\e[6~" [next])
(define-key xterm-function-map "\e[11~" [f1])
(define-key xterm-function-map "\e[12~" [f2])
(define-key xterm-function-map "\e[13~" [f3])
(define-key xterm-function-map "\e[14~" [f4])
(define-key xterm-function-map "\e[15~" [f5])
(define-key xterm-function-map "\e[17~" [f6])
(define-key xterm-function-map "\e[18~" [f7])
(define-key xterm-function-map "\e[19~" [f8])
(define-key xterm-function-map "\e[20~" [f9])
(define-key xterm-function-map "\e[21~" [f10])
(define-key xterm-function-map "\e[23~" [f11])
(define-key xterm-function-map "\e[24~" [f12])
(define-key xterm-function-map "\e[29~" [print])
(define-key xterm-function-map "\eO2P" [S-f1])
(define-key xterm-function-map "\eO2Q" [S-f2])
(define-key xterm-function-map "\eO2R" [S-f3])
(define-key xterm-function-map "\eO2S" [S-f4])
(define-key xterm-function-map "\e[15;2~" [S-f5])
(define-key xterm-function-map "\e[17;2~" [S-f6])
(define-key xterm-function-map "\e[18;2~" [S-f7])
(define-key xterm-function-map "\e[19;2~" [S-f8])
(define-key xterm-function-map "\e[20;2~" [S-f9])
(define-key xterm-function-map "\e[21;2~" [S-f10])
(define-key xterm-function-map "\e[23;2~" [S-f11])
(define-key xterm-function-map "\e[24;2~" [S-f12])
(define-key xterm-function-map "\eOP" [f1])
(define-key xterm-function-map "\eOQ" [f2])
(define-key xterm-function-map "\eOR" [f3])
(define-key xterm-function-map "\eOS" [f4])
(define-key xterm-function-map "\eO5P" [C-f1])
(define-key xterm-function-map "\eO5Q" [C-f2])
(define-key xterm-function-map "\eO5R" [C-f3])
(define-key xterm-function-map "\eO5S" [C-f4])
(define-key xterm-function-map "\e[15;5~" [C-f5])
(define-key xterm-function-map "\e[17;5~" [C-f6])
(define-key xterm-function-map "\e[18;5~" [C-f7])
(define-key xterm-function-map "\e[19;5~" [C-f8])
(define-key xterm-function-map "\e[20;5~" [C-f9])
(define-key xterm-function-map "\e[21;5~" [C-f10])
(define-key xterm-function-map "\e[23;5~" [C-f11])
(define-key xterm-function-map "\e[24;5~" [C-f12])
(define-key xterm-function-map "\eO2P" [S-f1])
(define-key xterm-function-map "\eO2Q" [S-f2])
(define-key xterm-function-map "\eO2R" [S-f3])
(define-key xterm-function-map "\eO2S" [S-f4])
(define-key xterm-function-map "\e[15;2~" [S-f5])
(define-key xterm-function-map "\e[17;2~" [S-f6])
(define-key xterm-function-map "\e[18;2~" [S-f7])
(define-key xterm-function-map "\e[19;2~" [S-f8])
(define-key xterm-function-map "\e[20;2~" [S-f9])
(define-key xterm-function-map "\e[21;2~" [S-f10])
(define-key xterm-function-map "\e[23;2~" [S-f11])
(define-key xterm-function-map "\e[24;2~" [S-f12])
(define-key xterm-function-map "\eO6P" [C-S-f1])
(define-key xterm-function-map "\eO6Q" [C-S-f2])
(define-key xterm-function-map "\eO6R" [C-S-f3])
(define-key xterm-function-map "\eO6S" [C-S-f4])
(define-key xterm-function-map "\e[15;6~" [C-S-f5])
(define-key xterm-function-map "\e[17;6~" [C-S-f6])
(define-key xterm-function-map "\e[18;6~" [C-S-f7])
(define-key xterm-function-map "\e[19;6~" [C-S-f8])
(define-key xterm-function-map "\e[20;6~" [C-S-f9])
(define-key xterm-function-map "\e[21;6~" [C-S-f10])
(define-key xterm-function-map "\e[23;6~" [C-S-f11])
(define-key xterm-function-map "\e[24;6~" [C-S-f12])
(define-key xterm-function-map "\eO5P" [C-f1])
(define-key xterm-function-map "\eO5Q" [C-f2])
(define-key xterm-function-map "\eO5R" [C-f3])
(define-key xterm-function-map "\eO5S" [C-f4])
(define-key xterm-function-map "\e[15;5~" [C-f5])
(define-key xterm-function-map "\e[17;5~" [C-f6])
(define-key xterm-function-map "\e[18;5~" [C-f7])
(define-key xterm-function-map "\e[19;5~" [C-f8])
(define-key xterm-function-map "\e[20;5~" [C-f9])
(define-key xterm-function-map "\e[21;5~" [C-f10])
(define-key xterm-function-map "\e[23;5~" [C-f11])
(define-key xterm-function-map "\e[24;5~" [C-f12])
(define-key xterm-function-map "\eO3P" [A-f1])
(define-key xterm-function-map "\eO3Q" [A-f2])
(define-key xterm-function-map "\eO3R" [A-f3])
(define-key xterm-function-map "\eO3S" [A-f4])
(define-key xterm-function-map "\e[15;3~" [A-f5])
(define-key xterm-function-map "\e[17;3~" [A-f6])
(define-key xterm-function-map "\e[18;3~" [A-f7])
(define-key xterm-function-map "\e[19;3~" [A-f8])
(define-key xterm-function-map "\e[20;3~" [A-f9])
(define-key xterm-function-map "\e[21;3~" [A-f10])
(define-key xterm-function-map "\e[23;3~" [A-f11])
(define-key xterm-function-map "\e[24;3~" [A-f12])
(define-key xterm-function-map "\eO6P" [C-S-f1])
(define-key xterm-function-map "\eO6Q" [C-S-f2])
(define-key xterm-function-map "\eO6R" [C-S-f3])
(define-key xterm-function-map "\eO6S" [C-S-f4])
(define-key xterm-function-map "\e[15;6~" [C-S-f5])
(define-key xterm-function-map "\e[17;6~" [C-S-f6])
(define-key xterm-function-map "\e[18;6~" [C-S-f7])
(define-key xterm-function-map "\e[19;6~" [C-S-f8])
(define-key xterm-function-map "\e[20;6~" [C-S-f9])
(define-key xterm-function-map "\e[21;6~" [C-S-f10])
(define-key xterm-function-map "\e[23;6~" [C-S-f11])
(define-key xterm-function-map "\e[24;6~" [C-S-f12])
(define-key xterm-function-map "\e[1;2A" [S-up])
(define-key xterm-function-map "\e[1;2B" [S-down])
(define-key xterm-function-map "\e[1;2C" [S-right])
(define-key xterm-function-map "\e[1;2D" [S-left])
(define-key xterm-function-map "\e[1;2F" [S-end])
(define-key xterm-function-map "\e[1;2H" [S-home])
(define-key xterm-function-map "\eO3P" [A-f1])
(define-key xterm-function-map "\eO3Q" [A-f2])
(define-key xterm-function-map "\eO3R" [A-f3])
(define-key xterm-function-map "\eO3S" [A-f4])
(define-key xterm-function-map "\e[15;3~" [A-f5])
(define-key xterm-function-map "\e[17;3~" [A-f6])
(define-key xterm-function-map "\e[18;3~" [A-f7])
(define-key xterm-function-map "\e[19;3~" [A-f8])
(define-key xterm-function-map "\e[20;3~" [A-f9])
(define-key xterm-function-map "\e[21;3~" [A-f10])
(define-key xterm-function-map "\e[23;3~" [A-f11])
(define-key xterm-function-map "\e[24;3~" [A-f12])
(define-key xterm-function-map "\e[1;5A" [C-up])
(define-key xterm-function-map "\e[1;5B" [C-down])
(define-key xterm-function-map "\e[1;5C" [C-right])
(define-key xterm-function-map "\e[1;5D" [C-left])
(define-key xterm-function-map "\e[1;5F" [C-end])
(define-key xterm-function-map "\e[1;5H" [C-home])
(define-key xterm-function-map "\e[1;2A" [S-up])
(define-key xterm-function-map "\e[1;2B" [S-down])
(define-key xterm-function-map "\e[1;2C" [S-right])
(define-key xterm-function-map "\e[1;2D" [S-left])
(define-key xterm-function-map "\e[1;2F" [S-end])
(define-key xterm-function-map "\e[1;2H" [S-home])
(define-key xterm-function-map "\e[1;6A" [C-S-up])
(define-key xterm-function-map "\e[1;6B" [C-S-down])
(define-key xterm-function-map "\e[1;6C" [C-S-right])
(define-key xterm-function-map "\e[1;6D" [C-S-left])
(define-key xterm-function-map "\e[1;6F" [C-S-end])
(define-key xterm-function-map "\e[1;6H" [C-S-home])
(define-key xterm-function-map "\e[1;5A" [C-up])
(define-key xterm-function-map "\e[1;5B" [C-down])
(define-key xterm-function-map "\e[1;5C" [C-right])
(define-key xterm-function-map "\e[1;5D" [C-left])
(define-key xterm-function-map "\e[1;5F" [C-end])
(define-key xterm-function-map "\e[1;5H" [C-home])
(define-key xterm-function-map "\e[1;3A" [A-up])
(define-key xterm-function-map "\e[1;3B" [A-down])
(define-key xterm-function-map "\e[1;3C" [A-right])
(define-key xterm-function-map "\e[1;3D" [A-left])
(define-key xterm-function-map "\e[1;3F" [A-end])
(define-key xterm-function-map "\e[1;3H" [A-home])
(define-key xterm-function-map "\e[1;6A" [C-S-up])
(define-key xterm-function-map "\e[1;6B" [C-S-down])
(define-key xterm-function-map "\e[1;6C" [C-S-right])
(define-key xterm-function-map "\e[1;6D" [C-S-left])
(define-key xterm-function-map "\e[1;6F" [C-S-end])
(define-key xterm-function-map "\e[1;6H" [C-S-home])
(define-key xterm-function-map "\e[2;2~" [S-insert])
(define-key xterm-function-map "\e[3;2~" [S-delete])
(define-key xterm-function-map "\e[5;2~" [S-prior])
(define-key xterm-function-map "\e[6;2~" [S-next])
(define-key xterm-function-map "\e[1;3A" [A-up])
(define-key xterm-function-map "\e[1;3B" [A-down])
(define-key xterm-function-map "\e[1;3C" [A-right])
(define-key xterm-function-map "\e[1;3D" [A-left])
(define-key xterm-function-map "\e[1;3F" [A-end])
(define-key xterm-function-map "\e[1;3H" [A-home])
(define-key xterm-function-map "\e[2;5~" [C-insert])
(define-key xterm-function-map "\e[3;5~" [C-delete])
(define-key xterm-function-map "\e[5;5~" [C-prior])
(define-key xterm-function-map "\e[6;5~" [C-next])
(define-key xterm-function-map "\e[2;2~" [S-insert])
(define-key xterm-function-map "\e[3;2~" [S-delete])
(define-key xterm-function-map "\e[5;2~" [S-prior])
(define-key xterm-function-map "\e[6;2~" [S-next])
(define-key xterm-function-map "\e[2;6~" [C-S-insert])
(define-key xterm-function-map "\e[3;6~" [C-S-delete])
(define-key xterm-function-map "\e[5;6~" [C-S-prior])
(define-key xterm-function-map "\e[6;6~" [C-S-next])
(define-key xterm-function-map "\e[2;5~" [C-insert])
(define-key xterm-function-map "\e[3;5~" [C-delete])
(define-key xterm-function-map "\e[5;5~" [C-prior])
(define-key xterm-function-map "\e[6;5~" [C-next])
(define-key xterm-function-map "\e[2;3~" [A-insert])
(define-key xterm-function-map "\e[3;3~" [A-delete])
(define-key xterm-function-map "\e[5;3~" [A-prior])
(define-key xterm-function-map "\e[6;3~" [A-next])
(define-key xterm-function-map "\e[2;6~" [C-S-insert])
(define-key xterm-function-map "\e[3;6~" [C-S-delete])
(define-key xterm-function-map "\e[5;6~" [C-S-prior])
(define-key xterm-function-map "\e[6;6~" [C-S-next])
(define-key xterm-function-map "\eOA" [up])
(define-key xterm-function-map "\eOB" [down])
(define-key xterm-function-map "\eOC" [right])
(define-key xterm-function-map "\eOD" [left])
(define-key xterm-function-map "\eOF" [end])
(define-key xterm-function-map "\eOH" [home])
(define-key xterm-function-map "\e[2;3~" [A-insert])
(define-key xterm-function-map "\e[3;3~" [A-delete])
(define-key xterm-function-map "\e[5;3~" [A-prior])
(define-key xterm-function-map "\e[6;3~" [A-next])
(define-key xterm-function-map "\eO2A" [S-up])
(define-key xterm-function-map "\eO2B" [S-down])
(define-key xterm-function-map "\eO2C" [S-right])
(define-key xterm-function-map "\eO2D" [S-left])
(define-key xterm-function-map "\eO2F" [S-end])
(define-key xterm-function-map "\eO2H" [S-home])
(define-key xterm-function-map "\eOA" [up])
(define-key xterm-function-map "\eOB" [down])
(define-key xterm-function-map "\eOC" [right])
(define-key xterm-function-map "\eOD" [left])
(define-key xterm-function-map "\eOF" [end])
(define-key xterm-function-map "\eOH" [home])
(define-key xterm-function-map "\eO5A" [C-up])
(define-key xterm-function-map "\eO5B" [C-down])
(define-key xterm-function-map "\eO5C" [C-right])
(define-key xterm-function-map "\eO5D" [C-left])
(define-key xterm-function-map "\eO5F" [C-end])
(define-key xterm-function-map "\eO5H" [C-home])
(define-key xterm-function-map "\eO2A" [S-up])
(define-key xterm-function-map "\eO2B" [S-down])
(define-key xterm-function-map "\eO2C" [S-right])
(define-key xterm-function-map "\eO2D" [S-left])
(define-key xterm-function-map "\eO2F" [S-end])
(define-key xterm-function-map "\eO2H" [S-home])
;; Use inheritance to let the main keymap override those defaults.
;; This way we don't override terminfo-derived settings or settings
;; made in the .emacs file.
(unless (let ((map (keymap-parent function-key-map))
found)
(while (and (not found) map)
(setq found (eq xterm-function-map map)
map (keymap-parent map)))
found)
(define-key xterm-function-map "\eO5A" [C-up])
(define-key xterm-function-map "\eO5B" [C-down])
(define-key xterm-function-map "\eO5C" [C-right])
(define-key xterm-function-map "\eO5D" [C-left])
(define-key xterm-function-map "\eO5F" [C-end])
(define-key xterm-function-map "\eO5H" [C-home])
;; Use inheritance to let the main keymap override those defaults.
;; This way we don't override terminfo-derived settings or settings
;; made in the .emacs file.
(set-keymap-parent xterm-function-map (keymap-parent function-key-map))
(set-keymap-parent function-key-map xterm-function-map))