changeset 64651:af1c58687bdd

* term/apollo.el (terminal-init-apollo): New function containing all former top level forms in the file. * term/bobcat.el (terminal-init-bobcat): * term/cygwin.el (terminal-init-cygwin): * term/iris-ansi.el (terminal-init-iris-ansi): * term/linux.el (terminal-init-linux): * term/news.el (terminal-init-news): * term/rxvt.el (terminal-init-rxvt): * term/sun.el (terminal-init-sun): * term/tvi970.el (terminal-init-tvi970): * term/vt100.el (terminal-init-vt100): * term/vt102.el (terminal-init-vt102): * term/vt125.el (terminal-init-vt125): * term/vt200.el (terminal-init-vt200): * term/vt201.el (terminal-init-vt201): * term/vt220.el (terminal-init-vt220): * term/vt240.el (terminal-init-vt240): * term/vt300.el (terminal-init-vt300): * term/vt320.el (terminal-init-vt320): * term/vt400.el (terminal-init-vt400): * term/vt420.el (terminal-init-vt420): * term/wyse50.el (terminal-init-wyse50): * term/xterm.el (terminal-init-xterm): Likewise. * term/README: Describe the terminal-init-* functionality. * startup.el (command-line): After loading the terminal initialization file call the corresponding terminal initialization function.
author Dan Nicolaescu <dann@ics.uci.edu>
date Wed, 27 Jul 2005 18:02:08 +0000
parents 82d9ac62ed1d
children 883ca83abac4
files lisp/ChangeLog lisp/startup.el lisp/term/README lisp/term/apollo.el lisp/term/bobcat.el lisp/term/cygwin.el lisp/term/iris-ansi.el lisp/term/linux.el lisp/term/news.el lisp/term/rxvt.el lisp/term/sun.el lisp/term/tvi970.el lisp/term/vt100.el lisp/term/vt102.el lisp/term/vt125.el lisp/term/vt200.el lisp/term/vt201.el lisp/term/vt220.el lisp/term/vt240.el lisp/term/vt300.el lisp/term/vt320.el lisp/term/vt400.el lisp/term/vt420.el lisp/term/wyse50.el lisp/term/xterm.el
diffstat 25 files changed, 1041 insertions(+), 955 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/ChangeLog	Wed Jul 27 18:02:08 2005 +0000
@@ -1,3 +1,35 @@
+2005-07-27  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* term/apollo.el (terminal-init-apollo): New function containing
+	all former top level forms in the file.
+	* term/bobcat.el (terminal-init-bobcat):
+	* term/cygwin.el (terminal-init-cygwin):
+	* term/iris-ansi.el (terminal-init-iris-ansi):
+	* term/linux.el (terminal-init-linux):
+	* term/news.el (terminal-init-news):
+	* term/rxvt.el (terminal-init-rxvt):
+	* term/sun.el (terminal-init-sun):
+	* term/tvi970.el (terminal-init-tvi970):
+	* term/vt100.el (terminal-init-vt100):
+	* term/vt102.el (terminal-init-vt102):
+	* term/vt125.el (terminal-init-vt125):
+	* term/vt200.el (terminal-init-vt200):
+	* term/vt201.el (terminal-init-vt201):
+	* term/vt220.el (terminal-init-vt220):
+	* term/vt240.el (terminal-init-vt240):
+	* term/vt300.el (terminal-init-vt300):
+	* term/vt320.el (terminal-init-vt320):
+	* term/vt400.el (terminal-init-vt400):
+	* term/vt420.el (terminal-init-vt420):
+	* term/wyse50.el (terminal-init-wyse50):
+	* term/xterm.el (terminal-init-xterm): Likewise.
+
+	* term/README: Describe the terminal-init-* functionality.
+
+	* startup.el (command-line): After loading the terminal
+	initialization file call the corresponding terminal initialization
+	function.
+
 2005-07-27  Kenichi Handa  <handa@m17n.org>
 
 	* ps-bdf.el (bdf-read-font-info): Ignore glyphs whose ENCODING is
--- a/lisp/startup.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/startup.el	Wed Jul 27 18:02:08 2005 +0000
@@ -984,7 +984,13 @@
         (setq term
               (if (setq hyphend (string-match "[-_][^-_]+$" term))
                   (substring term 0 hyphend)
-                nil)))))
+                nil)))
+      (when term
+	;; The terminal file has been loaded, now call the terminal
+	;; specific initialization function.
+	(let ((term-init-func (intern (concat "terminal-init-" term))))
+	  (when (fboundp term-init-func)
+	    (funcall term-init-func))))))
 
   ;; Update the out-of-memory error message based on user's key bindings
   ;; for save-some-buffers.
--- a/lisp/term/README	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/README	Wed Jul 27 18:02:08 2005 +0000
@@ -8,7 +8,12 @@
 yield a file that exists, the previous hyphen is stripped, and so on until all
 hyphens are gone.  For example, if the terminal type is `aaa-48-foo', Emacs
 will try first `term/aaa-48-foo.el', then `term/aaa-48.el' and finally
-`term/aaa.el'.
+`term/aaa.el'.  Each terminal specific file should contain a function
+named terminal-init-TERMINALNAME (eg terminal-init-aaa-48 for
+term/aaa-48.el) that Emacs will call in order to initialize the
+terminal. The terminal files should not contain any top level forms
+that are executed when the file is loaded, all the initialization
+actions are performed by the terminal-init-TERMINALNAME functions.
 
    When writing terminal packages, there are some things it is good to keep in
 mind.
--- a/lisp/term/apollo.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/apollo.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,7 @@
 ;; -*- no-byte-compile: t -*-
-
-(load "term/vt100" nil t)
+(defun terminal-init-apollo ()
+  "Terminal initialization function for apollo."  
+  (load "term/vt100" nil t))
 
 ;;; arch-tag: c72f446f-e6b7-4749-90a4-bd68632adacf
 ;;; apollo.el ends here
--- a/lisp/term/bobcat.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/bobcat.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,7 +1,10 @@
 ;; -*- no-byte-compile: t -*-
-;;; HP terminals usually encourage using ^H as the rubout character
-(keyboard-translate ?\177 ?\^h)
-(keyboard-translate ?\^h ?\177)
+
+(defun terminal-init-bobcat ()
+  "Terminal initialization function for bobcat."  
+  ;; HP terminals usually encourage using ^H as the rubout character
+  (keyboard-translate ?\177 ?\^h)
+  (keyboard-translate ?\^h ?\177))
 
 ;;; arch-tag: 754e4520-0a3e-4e6e-8ca5-9481b1f85cf7
 ;;; bobcat.el ends here
--- a/lisp/term/cygwin.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/cygwin.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,7 +1,10 @@
 ;;; cygwin.el --- support for the Cygwin terminal -*- no-byte-compile: t -*-
 
 ;;; The Cygwin terminal can't really display underlines.
-(tty-no-underline)
+
+(defun terminal-init-cygwin ()
+  "Terminal initialization function for cygwin."  
+  (tty-no-underline))
 
 ;; arch-tag: ca81ce67-3c41-4883-a29b-4c3d64a21191
 ;;; cygwin.el ends here
--- a/lisp/term/iris-ansi.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/iris-ansi.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,6 @@
 ;;; iris-ansi.el --- configure Emacs for SGI xwsh and winterm apps -*- no-byte-compile: t -*-
 
-;; Copyright (C) 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 2005 Free Software Foundation, Inc.
 
 ;; Author: Dan Nicolaescu <dann@ics.uci.edu>
 
@@ -25,302 +25,306 @@
 
 ;;; Code:
 
-(define-key function-key-map "\e[120q" [S-escape])
-(define-key function-key-map "\e[121q" [C-escape])
-
-(define-key function-key-map "\e[001q" [f1])
-(define-key function-key-map "\e[013q" [S-f1])
-(define-key function-key-map "\e[025q" [C-f1])
-
-
-(define-key function-key-map "\e[002q" [f2])
-(define-key function-key-map "\e[014q" [S-f2])
-(define-key function-key-map "\e[026q" [C-f2])
-(define-key function-key-map "\e[038q" [M-f2])
-
-(define-key function-key-map "\e[003q" [f3])
-(define-key function-key-map "\e[015q" [S-f3])
-(define-key function-key-map "\e[027q" [C-f3])
-
+(defun iris-ansi-initialize-terminal ()
+  "Terminal initialization function for iris-ansi."
+  (define-key function-key-map "\e[120q" [S-escape])
+  (define-key function-key-map "\e[121q" [C-escape])
 
-(define-key function-key-map "\e[004q" [f4])
-(define-key function-key-map "\e[016q" [S-f4])
-(define-key function-key-map "\e[028q" [C-f4])
-
-
-(define-key function-key-map "\e[005q" [f5])
-(define-key function-key-map "\e[017q" [S-f5])
-(define-key function-key-map "\e[029q" [C-f5])
-
-
-(define-key function-key-map "\e[006q" [f6])
-(define-key function-key-map "\e[018q" [S-f6])
-(define-key function-key-map "\e[030q" [C-f6])
-
-
-(define-key function-key-map "\e[007q" [f7])
-(define-key function-key-map "\e[019q" [S-f7])
-(define-key function-key-map "\e[031q" [C-f7])
+  (define-key function-key-map "\e[001q" [f1])
+  (define-key function-key-map "\e[013q" [S-f1])
+  (define-key function-key-map "\e[025q" [C-f1])
 
 
-(define-key function-key-map "\e[008q" [f8])
-(define-key function-key-map "\e[020q" [S-f8])
-(define-key function-key-map "\e[032q" [C-f8])
-
+  (define-key function-key-map "\e[002q" [f2])
+  (define-key function-key-map "\e[014q" [S-f2])
+  (define-key function-key-map "\e[026q" [C-f2])
+  (define-key function-key-map "\e[038q" [M-f2])
 
-(define-key function-key-map "\e[009q" [f9])
-(define-key function-key-map "\e[021q" [S-f9])
-(define-key function-key-map "\e[033q" [C-f9])
-
-
-(define-key function-key-map "\e[010q" [f10])
-(define-key function-key-map "\e[022q" [S-f10])
-(define-key function-key-map "\e[034q" [C-f10])
+  (define-key function-key-map "\e[003q" [f3])
+  (define-key function-key-map "\e[015q" [S-f3])
+  (define-key function-key-map "\e[027q" [C-f3])
 
 
-(define-key function-key-map "\e[011q" [f11])
-(define-key function-key-map "\e[023q" [S-f11])
-(define-key function-key-map "\e[035q" [C-f11])
-(define-key function-key-map "\e[047q" [M-f11])
-
-(define-key function-key-map "\e[012q" [f12])
-(define-key function-key-map "\e[024q" [S-f12])
-(define-key function-key-map "\e[036q" [C-f12])
-(define-key function-key-map "\e[048q" [M-f12])
+  (define-key function-key-map "\e[004q" [f4])
+  (define-key function-key-map "\e[016q" [S-f4])
+  (define-key function-key-map "\e[028q" [C-f4])
 
 
-(define-key function-key-map "\e[057q" [C-`])
-(define-key function-key-map "\e[115q" [M-`])
-
-(define-key function-key-map "\e[049q" [?\C-1])
-(define-key function-key-map "\e[058q" [?\M-1])
-
-
-(define-key function-key-map "\e[059q" [?\M-2])
-
-(define-key function-key-map "\e[050q" [?\C-3])
-(define-key function-key-map "\e[060q" [?\M-3])
-
-(define-key function-key-map "\e[051q" [?\C-4])
-(define-key function-key-map "\e[061q" [?\M-4])
-
-(define-key function-key-map "\e[052q" [?\C-5])
-(define-key function-key-map "\e[062q" [?\M-5])
+  (define-key function-key-map "\e[005q" [f5])
+  (define-key function-key-map "\e[017q" [S-f5])
+  (define-key function-key-map "\e[029q" [C-f5])
 
 
-(define-key function-key-map "\e[063q" [?\M-6])
-
-(define-key function-key-map "\e[053q" [?\C-7])
-(define-key function-key-map "\e[064q" [?\M-7])
+  (define-key function-key-map "\e[006q" [f6])
+  (define-key function-key-map "\e[018q" [S-f6])
+  (define-key function-key-map "\e[030q" [C-f6])
+  
 
-(define-key function-key-map "\e[054q" [?\C-8])
-(define-key function-key-map "\e[065q" [?\M-8])
-
-(define-key function-key-map "\e[055q" [?\C-9])
-(define-key function-key-map "\e[066q" [?\M-9])
+  (define-key function-key-map "\e[007q" [f7])
+  (define-key function-key-map "\e[019q" [S-f7])
+  (define-key function-key-map "\e[031q" [C-f7])
+  
+  
+  (define-key function-key-map "\e[008q" [f8])
+  (define-key function-key-map "\e[020q" [S-f8])
+  (define-key function-key-map "\e[032q" [C-f8])
+  
 
-(define-key function-key-map "\e[056q" [?\C-0])
-(define-key function-key-map "\e[067q" [?\M-0])
-
-(define-key function-key-map "\e[068q" [?\M--])
-
-(define-key function-key-map "\e[069q" [?\C-=])
-(define-key function-key-map "\e[070q" [?\M-=])
-
-;; I don't know what to do with those.
-;(define-key function-key-map "^H" [<del>])
-;(define-key function-key-map "^H" [S-<del>])
-;(define-key function-key-map "\177" [C-<del>])
-;(define-key function-key-map "\e[071q" [M-<del>])
+  (define-key function-key-map "\e[009q" [f9])
+  (define-key function-key-map "\e[021q" [S-f9])
+  (define-key function-key-map "\e[033q" [C-f9])
+  
+  
+  (define-key function-key-map "\e[010q" [f10])
+  (define-key function-key-map "\e[022q" [S-f10])
+  (define-key function-key-map "\e[034q" [C-f10])
+  
+  
+  (define-key function-key-map "\e[011q" [f11])
+  (define-key function-key-map "\e[023q" [S-f11])
+  (define-key function-key-map "\e[035q" [C-f11])
+  (define-key function-key-map "\e[047q" [M-f11])
 
-(define-key function-key-map "\e[Z" [?\S-\t])
-(define-key function-key-map "\e[072q" [?\C-\t])
-;; This only works if you remove the M-TAB keybing from the system.4Dwmrc
-;; our your ~/.4Dwmrc, if you use the 4Dwm window manager.
-(define-key function-key-map "\e[073q" [?\M-\t])
-
-(define-key function-key-map "\e[074q" [?\M-q])
-
-(define-key function-key-map "\e[075q" [?\M-w])
-
-(define-key function-key-map "\e[076q" [?\M-e])
-
-(define-key function-key-map "\e[077q" [?\M-r])
-
-(define-key function-key-map "\e[078q" [?\M-t])
-
-(define-key function-key-map "\e[079q" [?\M-y])
+  (define-key function-key-map "\e[012q" [f12])
+  (define-key function-key-map "\e[024q" [S-f12])
+  (define-key function-key-map "\e[036q" [C-f12])
+  (define-key function-key-map "\e[048q" [M-f12])
+  
+  
+  (define-key function-key-map "\e[057q" [?\C-`])
+  (define-key function-key-map "\e[115q" [?\M-`])
+  
+  (define-key function-key-map "\e[049q" [?\C-1])
+  (define-key function-key-map "\e[058q" [?\M-1])
+  
+  
+  (define-key function-key-map "\e[059q" [?\M-2])
+  
+  (define-key function-key-map "\e[050q" [?\C-3])
+  (define-key function-key-map "\e[060q" [?\M-3])
+  
+  (define-key function-key-map "\e[051q" [?\C-4])
+  (define-key function-key-map "\e[061q" [?\M-4])
+  
+  (define-key function-key-map "\e[052q" [?\C-5])
+  (define-key function-key-map "\e[062q" [?\M-5])
+  
 
-(define-key function-key-map "\e[080q" [?\M-u])
-
-(define-key function-key-map "\e[081q" [?\M-i])
-
-(define-key function-key-map "\e[082q" [?\M-o])
-
-(define-key function-key-map "\e[083q" [?\M-p])
+  (define-key function-key-map "\e[063q" [?\M-6])
+  
+  (define-key function-key-map "\e[053q" [?\C-7])
+  (define-key function-key-map "\e[064q" [?\M-7])
+  
+  (define-key function-key-map "\e[054q" [?\C-8])
+  (define-key function-key-map "\e[065q" [?\M-8])
+  
+  (define-key function-key-map "\e[055q" [?\C-9])
+  (define-key function-key-map "\e[066q" [?\M-9])
+  
+  (define-key function-key-map "\e[056q" [?\C-0])
+  (define-key function-key-map "\e[067q" [?\M-0])
+  
+  (define-key function-key-map "\e[068q" [?\M--])
+  
+  (define-key function-key-map "\e[069q" [?\C-=])
+  (define-key function-key-map "\e[070q" [?\M-=])
+  
+  ;; I don't know what to do with those.
+  ;;(define-key function-key-map "^H" [<del>])
+  ;;(define-key function-key-map "^H" [S-<del>])
+  ;;(define-key function-key-map "\177" [C-<del>])
+  ;;(define-key function-key-map "\e[071q" [M-<del>])
+  
+  (define-key function-key-map "\e[Z" [?\S-\t])
+  (define-key function-key-map "\e[072q" [?\C-\t])
+  ;; This only works if you remove the M-TAB keybing from the system.4Dwmrc
+  ;; our your ~/.4Dwmrc, if you use the 4Dwm window manager.
+  (define-key function-key-map "\e[073q" [?\M-\t])
+  
+  (define-key function-key-map "\e[074q" [?\M-q])
 
-(define-key function-key-map "\e[084q" [?\M-\[])
-
-(define-key function-key-map "\e[085q" [?\M-\]])
-
-(define-key function-key-map "\e[086q" [?\M-\\])
-
-(define-key function-key-map "\e[087q" [?\M-a])
-
-(define-key function-key-map "\e[088q" [?\M-s])
+  (define-key function-key-map "\e[075q" [?\M-w])
+  
+  (define-key function-key-map "\e[076q" [?\M-e])
 
-(define-key function-key-map "\e[089q" [?\M-d])
-
-(define-key function-key-map "\e[090q" [?\M-f])
-
-(define-key function-key-map "\e[091q" [?\M-g])
-
-(define-key function-key-map "\e[092q" [?\M-h])
-
-(define-key function-key-map "\e[093q" [?\M-j])
-
-(define-key function-key-map "\e[094q" [?\M-k])
-
-(define-key function-key-map "\e[095q" [?\M-l])
+  (define-key function-key-map "\e[077q" [?\M-r])
+  
+  (define-key function-key-map "\e[078q" [?\M-t])
+  
+  (define-key function-key-map "\e[079q" [?\M-y])
+  
+  (define-key function-key-map "\e[080q" [?\M-u])
+  
+  (define-key function-key-map "\e[081q" [?\M-i])
 
-(define-key function-key-map "\e[096q" [?\C-\;])
-(define-key function-key-map "\e[097q" [?\M-:]) ;; we are cheating
-						;; here, this is realy
-						;; M-;, but M-:
-						;; generates the same
-						;; string and is more
-						;; usefull.
-
-(define-key function-key-map "\e[098q" [?\C-'])
-(define-key function-key-map "\e[099q" [?\M-'])
-
-(define-key function-key-map "\e[100q" [?\M-\n])
-
-(define-key function-key-map "\e[101q" [?\M-z])
-
-(define-key function-key-map "\e[102q" [?\M-x])
+  (define-key function-key-map "\e[082q" [?\M-o])
+  
+  (define-key function-key-map "\e[083q" [?\M-p])
+  
+  (define-key function-key-map "\e[084q" [?\M-\[])
+  
+  (define-key function-key-map "\e[085q" [?\M-\]])
+  
+  (define-key function-key-map "\e[086q" [?\M-\\])
+  
+  (define-key function-key-map "\e[087q" [?\M-a])
+  
+  (define-key function-key-map "\e[088q" [?\M-s])
+  
+  (define-key function-key-map "\e[089q" [?\M-d])
+  
+  (define-key function-key-map "\e[090q" [?\M-f])
+  
+  (define-key function-key-map "\e[091q" [?\M-g])
+  
+  (define-key function-key-map "\e[092q" [?\M-h])
+  
+  (define-key function-key-map "\e[093q" [?\M-j])
+  
+  (define-key function-key-map "\e[094q" [?\M-k])
+  
+  (define-key function-key-map "\e[095q" [?\M-l])
+  
+  (define-key function-key-map "\e[096q" [?\C-\;])
+  (define-key function-key-map "\e[097q" [?\M-:]) ;; we are cheating
+						  ;; here, this is
+						  ;; realy M-;, but
+						  ;; M-: generates the
+						  ;; same string and
+						  ;; is more usefull.
 
-(define-key function-key-map "\e[103q" [?\M-c])
-
-(define-key function-key-map "\e[104q" [?\M-v])
-
-(define-key function-key-map "\e[105q" [?\M-b])
-
-(define-key function-key-map "\e[106q" [M-n])
-
-(define-key function-key-map "\e[107q" [M-m])
-
-(define-key function-key-map "\e[108q" [?\C-,])
-(define-key function-key-map "\e[109q" [?\M-,])
-
-(define-key function-key-map "\e[110q" [?\C-.])
-(define-key function-key-map "\e[111q" [?\M-.])
+  (define-key function-key-map "\e[098q" [?\C-'])
+  (define-key function-key-map "\e[099q" [?\M-'])
+  
+  (define-key function-key-map "\e[100q" [?\M-\n])
+  
+  (define-key function-key-map "\e[101q" [?\M-z])
+  
+  (define-key function-key-map "\e[102q" [?\M-x])
+  
+  (define-key function-key-map "\e[103q" [?\M-c])
+  
+  (define-key function-key-map "\e[104q" [?\M-v])
+  
+  (define-key function-key-map "\e[105q" [?\M-b])
+  
+  (define-key function-key-map "\e[106q" [M-n])
+  
+  (define-key function-key-map "\e[107q" [M-m])
+  
+  (define-key function-key-map "\e[108q" [?\C-,])
+  (define-key function-key-map "\e[109q" [?\M-,])
+  
+  (define-key function-key-map "\e[110q" [?\C-.])
+  (define-key function-key-map "\e[111q" [?\M-.])
+  
+  (define-key function-key-map "\e[112q" [?\C-/])
+  (define-key function-key-map "\e[113q" [?\M-/])
+  
+  (define-key function-key-map "\e[139q" [insert])
+  (define-key function-key-map "\e[139q" [S-insert])
+  (define-key function-key-map "\e[140q" [C-insert])
+  (define-key function-key-map "\e[141q" [M-insert])
+  
+  (define-key function-key-map "\e[H" [home])
+  (define-key function-key-map "\e[143q" [S-home])
+  (define-key function-key-map "\e[144q" [C-home])
+  
 
-(define-key function-key-map "\e[112q" [?\C-/])
-(define-key function-key-map "\e[113q" [?\M-/])
-
-(define-key function-key-map "\e[139q" [insert])
-(define-key function-key-map "\e[139q" [S-insert])
-(define-key function-key-map "\e[140q" [C-insert])
-(define-key function-key-map "\e[141q" [M-insert])
+  (define-key function-key-map "\e[150q" [prior])
+  (define-key function-key-map "\e[151q" [S-prior]) ;; those don't
+						    ;; seem to
+						    ;; generate
+						    ;; anything
+  (define-key function-key-map "\e[152q" [C-prior])
 
-(define-key function-key-map "\e[H" [home])
-(define-key function-key-map "\e[143q" [S-home])
-(define-key function-key-map "\e[144q" [C-home])
-
-
-(define-key function-key-map "\e[150q" [prior])
-(define-key function-key-map "\e[151q" [S-prior]) ;; those don't seem
+  
+  ;; (define-key function-key-map "^?" [delete]) 
+  (define-key function-key-map "\e[P" [S-delete])
+  (define-key function-key-map "\e[142q" [C-delete])
+  (define-key function-key-map "\e[M" [M-delete])
+  
+  (define-key function-key-map "\e[146q" [end])
+  (define-key function-key-map "\e[147q" [S-end]) ;; those don't seem
 						  ;; to generate
 						  ;; anything
-(define-key function-key-map "\e[152q" [C-prior])
-
-
-;; (define-key function-key-map "^?" [delete]) ?? something else seems to take care of this.
-(define-key function-key-map "\e[P" [S-delete])
-(define-key function-key-map "\e[142q" [C-delete])
-(define-key function-key-map "\e[M" [M-delete])
-
-(define-key function-key-map "\e[146q" [end])
-(define-key function-key-map "\e[147q" [S-end]) ;; those don't seem to
-						;; generate anything
-(define-key function-key-map "\e[148q" [C-end])
-
-(define-key function-key-map "\e[154q" [next])
-(define-key function-key-map "\e[155q" [S-next])
-(define-key function-key-map "\e[156q" [C-next])
-
-
-(define-key function-key-map "\e[161q" [S-up])
-(define-key function-key-map "\e[162q" [C-up])
-(define-key function-key-map "\e[163q" [M-up])
-
-(define-key function-key-map "\e[158q" [S-left])
-(define-key function-key-map "\e[159q" [C-left])
-(define-key function-key-map "\e[160q" [M-left])
-
-(define-key function-key-map "\e[164q" [S-down])
-(define-key function-key-map "\e[165q" [C-down])
-(define-key function-key-map "\e[166q" [M-down])
-
-(define-key function-key-map "\e[167q" [S-right])
-(define-key function-key-map "\e[168q" [C-right])
-(define-key function-key-map "\e[169q" [M-right])
-
-;; Keypad functions, most of those are untested.
-(define-key function-key-map "\e[179q" [?\C-/])
-(define-key function-key-map "\e[180q" [?\M-/])
-
-(define-key function-key-map "\e[187q" [?\C-*])
-(define-key function-key-map "\e[188q" [?\M-*])
-
-(define-key function-key-map "\e[198q" [?\C--])
-(define-key function-key-map "\e[199q" [?\M--])
+  (define-key function-key-map "\e[148q" [C-end])
+  
+  (define-key function-key-map "\e[154q" [next])
+  (define-key function-key-map "\e[155q" [S-next])
+  (define-key function-key-map "\e[156q" [C-next])
+  
 
-;; Something else takes care of home, up, prior, down, left, right, next
-;(define-key function-key-map "\e[H" [home])
-(define-key function-key-map "\e[172q" [C-home])
-
-;(define-key function-key-map "\e[A" [up])
-(define-key function-key-map "\e[182q" [C-up])
-
-
-;(define-key function-key-map "\e[150q" [prior])
-(define-key function-key-map "\e[190q" [C-prior])
-
-
-(define-key function-key-map "\e[200q" [?\C-+])
-(define-key function-key-map "\e[201q" [?\M-+])
-
-;(define-key function-key-map "\e[D" [left])
-(define-key function-key-map "\e[174q" [C-left])
-
-
-(define-key function-key-map "\e[000q" [begin])
-(define-key function-key-map "\e[184q" [C-begin])
+  (define-key function-key-map "\e[161q" [S-up])
+  (define-key function-key-map "\e[162q" [C-up])
+  (define-key function-key-map "\e[163q" [M-up])
+  
+  (define-key function-key-map "\e[158q" [S-left])
+  (define-key function-key-map "\e[159q" [C-left])
+  (define-key function-key-map "\e[160q" [M-left])
+  
+  (define-key function-key-map "\e[164q" [S-down])
+  (define-key function-key-map "\e[165q" [C-down])
+  (define-key function-key-map "\e[166q" [M-down])
+  
+  (define-key function-key-map "\e[167q" [S-right])
+  (define-key function-key-map "\e[168q" [C-right])
+  (define-key function-key-map "\e[169q" [M-right])
+  
+  ;; Keypad functions, most of those are untested.
+  (define-key function-key-map "\e[179q" [?\C-/])
+  (define-key function-key-map "\e[180q" [?\M-/])
+  
+  (define-key function-key-map "\e[187q" [?\C-*])
+  (define-key function-key-map "\e[188q" [?\M-*])
+  
+  (define-key function-key-map "\e[198q" [?\C--])
+  (define-key function-key-map "\e[199q" [?\M--])
+  
+  ;; Something else takes care of home, up, prior, down, left, right, next
+  ;;(define-key function-key-map "\e[H" [home])
+  (define-key function-key-map "\e[172q" [C-home])
+  
+  ;;(define-key function-key-map "\e[A" [up])
+  (define-key function-key-map "\e[182q" [C-up])
+  
+  
+  ;;(define-key function-key-map "\e[150q" [prior])
+  (define-key function-key-map "\e[190q" [C-prior])
+  
+  
+  (define-key function-key-map "\e[200q" [?\C-+])
+  (define-key function-key-map "\e[201q" [?\M-+])
+  
+  ;;(define-key function-key-map "\e[D" [left])
+  (define-key function-key-map "\e[174q" [C-left])
 
-
-;(define-key function-key-map "\e[C" [right])
-(define-key function-key-map "\e[192q" [C-right])
-
-;(define-key function-key-map "\e[146q" [end])
-(define-key function-key-map "\e[176q" [C-end])
-
-;(define-key function-key-map "\e[B" [down])
-(define-key function-key-map "\e[186q" [C-down])
+  
+  (define-key function-key-map "\e[000q" [begin])
+  (define-key function-key-map "\e[184q" [C-begin])
 
-;(define-key function-key-map "\e[154q" [next])
-(define-key function-key-map "\e[194q" [C-next])
-
-
-(define-key function-key-map "\e[100q" [M-enter])
-
-(define-key function-key-map "\e[139q" [insert])
-(define-key function-key-map "\e[178q" [C-inset])
-
-(define-key function-key-map "\e[P" [delete])
-(define-key function-key-map "\e[196q" [C-delete])
-(define-key function-key-map "\e[197q" [M-delete])
+  
+  ;;(define-key function-key-map "\e[C" [right])
+  (define-key function-key-map "\e[192q" [C-right])
+  
+  ;;(define-key function-key-map "\e[146q" [end])
+  (define-key function-key-map "\e[176q" [C-end])
+  
+  ;;(define-key function-key-map "\e[B" [down])
+  (define-key function-key-map "\e[186q" [C-down])
+  
+  ;;(define-key function-key-map "\e[154q" [next])
+  (define-key function-key-map "\e[194q" [C-next])
+  
+  
+  (define-key function-key-map "\e[100q" [M-enter])
+  
+  (define-key function-key-map "\e[139q" [insert])
+  (define-key function-key-map "\e[178q" [C-inset])
+  
+  (define-key function-key-map "\e[P" [delete])
+  (define-key function-key-map "\e[196q" [C-delete])
+  (define-key function-key-map "\e[197q" [M-delete]))
 
 ;;; arch-tag: b1d0e73a-bb7d-47be-9fb2-6fb126469a1b
 ;;; iris-ansi.el ends here
--- a/lisp/term/linux.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/linux.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,19 +1,21 @@
 ;; -*- no-byte-compile: t -*-
 ;; The Linux console handles Latin-1 by default.
 
-(unless (terminal-coding-system)
-  (set-terminal-coding-system 'iso-latin-1))
+(defun terminal-init-linux ()
+  "Terminal initialization function for linux."  
+  (unless (terminal-coding-system)
+    (set-terminal-coding-system 'iso-latin-1))
 
-;; It can't really display underlines.
-(tty-no-underline)
+  ;; It can't really display underlines.
+  (tty-no-underline)
 
-;; Make Latin-1 input characters work, too.
-;; Meta will continue to work, because the kernel
-;; turns that into Escape.
+  ;; Make Latin-1 input characters work, too.
+  ;; Meta will continue to work, because the kernel
+  ;; turns that into Escape.
 
-(let ((value (current-input-mode)))
-  ;; The third arg only matters in that it is not t or nil.
-  (set-input-mode (nth 0 value) (nth 1 value) 'iso-latin-1 (nth 3 value)))
+  (let ((value (current-input-mode)))
+    ;; The third arg only matters in that it is not t or nil.
+    (set-input-mode (nth 0 value) (nth 1 value) 'iso-latin-1 (nth 3 value))))
 
 ;;; arch-tag: 5d0c4f63-739b-4862-abf3-041fe42adb8f
 ;;; linux.el ends here
--- a/lisp/term/news.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/news.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,6 @@
 ;;; news.el --- keypad and function key bindings for the Sony NEWS keyboard -*- no-byte-compile: t -*-
 
-;; Copyright (C) 1989, 1993 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 2005 Free Software Foundation, Inc.
 
 ;; Author: FSF
 ;; Keywords: terminals
@@ -28,47 +28,49 @@
 
 ;;; Code:
 
-(if (boundp 'news-fkey-prefix)
-    nil
-  ;; The terminal initialization should already have set up some keys
-  (setq news-fkey-prefix (lookup-key function-key-map "\eO"))
-  (if (not (keymapp news-fkey-prefix))
-      (error "What?  Your news termcap/terminfo has no keycaps in it"))
+(defun terminal-init-news ()
+  "Terminal initialization function for news."  
+  (if (boundp 'news-fkey-prefix)
+      nil
+    ;; The terminal initialization should already have set up some keys
+    (setq news-fkey-prefix (lookup-key function-key-map "\eO"))
+    (if (not (keymapp news-fkey-prefix))
+	(error "What?  Your news termcap/terminfo has no keycaps in it"))
 
-  ;; Termcap or terminfo will set these
-  ;; (define-key news-fkey-prefix "P" [f1])
-  ;; (define-key news-fkey-prefix "Q" [f2])
-  ;; (define-key news-fkey-prefix "R" [f3])
-  ;; (define-key news-fkey-prefix "S" [f4])
-  ;; (define-key news-fkey-prefix "T" [f5])
-  ;; (define-key news-fkey-prefix "U" [f6])
-  ;; (define-key news-fkey-prefix "V" [f7])
-  ;; (define-key news-fkey-prefix "W" [f8])
-  ;; (define-key news-fkey-prefix "X" [f9])
-  ;; (define-key news-fkey-prefix "Y" [f10])
+    ;; Termcap or terminfo will set these
+    ;; (define-key news-fkey-prefix "P" [f1])
+    ;; (define-key news-fkey-prefix "Q" [f2])
+    ;; (define-key news-fkey-prefix "R" [f3])
+    ;; (define-key news-fkey-prefix "S" [f4])
+    ;; (define-key news-fkey-prefix "T" [f5])
+    ;; (define-key news-fkey-prefix "U" [f6])
+    ;; (define-key news-fkey-prefix "V" [f7])
+    ;; (define-key news-fkey-prefix "W" [f8])
+    ;; (define-key news-fkey-prefix "X" [f9])
+    ;; (define-key news-fkey-prefix "Y" [f10])
 
-  ;; Terminfo will set these
-  (define-key news-fkey-prefix "a" [execute])
-  (define-key news-fkey-prefix "b" [select])
-  (define-key news-fkey-prefix "c" [cancel])
-  (define-key news-fkey-prefix "M" [kp-enter])
-  (define-key news-fkey-prefix "q" [kp-1])
-  (define-key news-fkey-prefix "s" [kp-3])
-  (define-key news-fkey-prefix "u" [kp-5])
-  (define-key news-fkey-prefix "w" [kp-7])
-  (define-key news-fkey-prefix "y" [kp-9])
+    ;; Terminfo will set these
+    (define-key news-fkey-prefix "a" [execute])
+    (define-key news-fkey-prefix "b" [select])
+    (define-key news-fkey-prefix "c" [cancel])
+    (define-key news-fkey-prefix "M" [kp-enter])
+    (define-key news-fkey-prefix "q" [kp-1])
+    (define-key news-fkey-prefix "s" [kp-3])
+    (define-key news-fkey-prefix "u" [kp-5])
+    (define-key news-fkey-prefix "w" [kp-7])
+    (define-key news-fkey-prefix "y" [kp-9])
 
-  ;; These aren't in either termcap or terminfo's repertoire
-  (define-key news-fkey-prefix "m" [kp-subtract])
-  (define-key news-fkey-prefix "k" [kp-add])
-  (define-key news-fkey-prefix "l" [kp-separator])
-  (define-key news-fkey-prefix "n" [kp-decimal])
-  (define-key news-fkey-prefix "p" [kp-0])
-  (define-key news-fkey-prefix "r" [kp-2])
-  (define-key news-fkey-prefix "t" [kp-4])
-  (define-key news-fkey-prefix "v" [kp-6])
-  (define-key news-fkey-prefix "x" [kp-8])
-  )
+    ;; These aren't in either termcap or terminfo's repertoire
+    (define-key news-fkey-prefix "m" [kp-subtract])
+    (define-key news-fkey-prefix "k" [kp-add])
+    (define-key news-fkey-prefix "l" [kp-separator])
+    (define-key news-fkey-prefix "n" [kp-decimal])
+    (define-key news-fkey-prefix "p" [kp-0])
+    (define-key news-fkey-prefix "r" [kp-2])
+    (define-key news-fkey-prefix "t" [kp-4])
+    (define-key news-fkey-prefix "v" [kp-6])
+    (define-key news-fkey-prefix "x" [kp-8])
+    ))
 
 ;;; arch-tag: bfe141a0-623b-4b42-b753-5d9353776c5e
 ;;; news.el ends here
--- a/lisp/term/rxvt.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/rxvt.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,6 @@
 ;;; rxvt.el --- define function key sequences and standard colors for rxvt
 
-;; Copyright (C) 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2005 Free Software Foundation, Inc.
 
 ;; Author: Eli Zaretskii
 ;; Keywords: terminals
@@ -26,135 +26,143 @@
 
 ;;; Code:
 
-;;; The terminal intialization C code file might have initialized
-;;; function keys F11->F42 from the termcap/terminfo information.  On
-;;; a PC-style keyboard these keys correspond to
-;;; MODIFIER-FUNCTION_KEY, where modifier is S-, C-, 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 [f11] [S-f1] function-key-map) 
-(substitute-key-definition [f12] [S-f2] function-key-map)
-(substitute-key-definition [f13] [S-f3] function-key-map)
-(substitute-key-definition [f14] [S-f4] function-key-map)
-(substitute-key-definition [f15] [S-f5] function-key-map)
-(substitute-key-definition [f16] [S-f6] function-key-map)
-(substitute-key-definition [f17] [S-f7] function-key-map)
-(substitute-key-definition [f18] [S-f8] function-key-map)
-(substitute-key-definition [f19] [S-f9] function-key-map)
-(substitute-key-definition [f20] [S-f10] function-key-map)
+(defun terminal-init-rxvt ()
+  "Terminal initialization function for rxvt."
+  ;; The terminal intialization C code file might have initialized
+  ;; function keys F11->F42 from the termcap/terminfo information.  On
+  ;; a PC-style keyboard these keys correspond to
+  ;; MODIFIER-FUNCTION_KEY, where modifier is S-, C-, 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 [f11] [S-f1] function-key-map) 
+  (substitute-key-definition [f12] [S-f2] function-key-map)
+  (substitute-key-definition [f13] [S-f3] function-key-map)
+  (substitute-key-definition [f14] [S-f4] function-key-map)
+  (substitute-key-definition [f15] [S-f5] function-key-map)
+  (substitute-key-definition [f16] [S-f6] function-key-map)
+  (substitute-key-definition [f17] [S-f7] function-key-map)
+  (substitute-key-definition [f18] [S-f8] function-key-map)
+  (substitute-key-definition [f19] [S-f9] function-key-map)
+  (substitute-key-definition [f20] [S-f10] function-key-map)
 
-(substitute-key-definition [f23] [C-f1] function-key-map) 
-(substitute-key-definition [f24] [C-f2] function-key-map)
-(substitute-key-definition [f25] [C-f3] function-key-map)
-(substitute-key-definition [f26] [C-f4] function-key-map)
-(substitute-key-definition [f27] [C-f5] function-key-map)
-(substitute-key-definition [f28] [C-f6] function-key-map)
-(substitute-key-definition [f29] [C-f7] function-key-map)
-(substitute-key-definition [f30] [C-f8] function-key-map)
-(substitute-key-definition [f31] [C-f9] function-key-map)
-(substitute-key-definition [f32] [C-f10] function-key-map)
+  (substitute-key-definition [f23] [C-f1] function-key-map) 
+  (substitute-key-definition [f24] [C-f2] function-key-map)
+  (substitute-key-definition [f25] [C-f3] function-key-map)
+  (substitute-key-definition [f26] [C-f4] function-key-map)
+  (substitute-key-definition [f27] [C-f5] function-key-map)
+  (substitute-key-definition [f28] [C-f6] function-key-map)
+  (substitute-key-definition [f29] [C-f7] function-key-map)
+  (substitute-key-definition [f30] [C-f8] function-key-map)
+  (substitute-key-definition [f31] [C-f9] function-key-map)
+  (substitute-key-definition [f32] [C-f10] function-key-map)
 
-(substitute-key-definition [f33] [C-S-f1] function-key-map) 
-(substitute-key-definition [f34] [C-S-f2] function-key-map)
-(substitute-key-definition [f35] [C-S-f3] function-key-map)
-(substitute-key-definition [f36] [C-S-f4] function-key-map)
-(substitute-key-definition [f37] [C-S-f5] function-key-map)
-(substitute-key-definition [f38] [C-S-f6] function-key-map)
-(substitute-key-definition [f39] [C-S-f7] function-key-map)
-(substitute-key-definition [f40] [C-S-f8] function-key-map)
-(substitute-key-definition [f41] [C-S-f9] function-key-map)
-(substitute-key-definition [f42] [C-S-f10] function-key-map)
+  (substitute-key-definition [f33] [C-S-f1] function-key-map) 
+  (substitute-key-definition [f34] [C-S-f2] function-key-map)
+  (substitute-key-definition [f35] [C-S-f3] function-key-map)
+  (substitute-key-definition [f36] [C-S-f4] function-key-map)
+  (substitute-key-definition [f37] [C-S-f5] function-key-map)
+  (substitute-key-definition [f38] [C-S-f6] function-key-map)
+  (substitute-key-definition [f39] [C-S-f7] function-key-map)
+  (substitute-key-definition [f40] [C-S-f8] function-key-map)
+  (substitute-key-definition [f41] [C-S-f9] function-key-map)
+  (substitute-key-definition [f42] [C-S-f10] function-key-map)
 
-;; Set up function-key-map entries that termcap and terminfo don't know.
-(let ((map (make-sparse-keymap)))
-  (define-key map "\e[A" [up])
-  (define-key map "\e[B" [down])
-  (define-key map "\e[C" [right])
-  (define-key map "\e[D" [left])
-  (define-key map "\e[7~" [home])
-  (define-key map "\e[2~" [insert])
-  (define-key map "\e[3~" [delete])
-  (define-key map "\e[4~" [select])
-  (define-key map "\e[5~" [prior])
-  (define-key map "\e[6~" [next])
-  (define-key map "\e[11~" [f1])
-  (define-key map "\e[12~" [f2])
-  (define-key map "\e[13~" [f3])
-  (define-key map "\e[14~" [f4])
-  (define-key map "\e[15~" [f5])
-  (define-key map "\e[17~" [f6])
-  (define-key map "\e[18~" [f7])
-  (define-key map "\e[19~" [f8])
-  (define-key map "\e[20~" [f9])
-  (define-key map "\e[21~" [f10])
-  ;; The strings emitted by f11 and f12 are the same as the strings
-  ;; emitted by S-f1 and S-f2, so don't define f11 and f12.
-  ;; (define-key map "\e[23~" [f11])
-  ;; (define-key map "\e[24~" [f12])
-  (define-key map "\e[29~" [print])
+  ;; Set up function-key-map entries that termcap and terminfo don't know.
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\e[A" [up])
+    (define-key map "\e[B" [down])
+    (define-key map "\e[C" [right])
+    (define-key map "\e[D" [left])
+    (define-key map "\e[7~" [home])
+    (define-key map "\e[2~" [insert])
+    (define-key map "\e[3~" [delete])
+    (define-key map "\e[4~" [select])
+    (define-key map "\e[5~" [prior])
+    (define-key map "\e[6~" [next])
+    (define-key map "\e[11~" [f1])
+    (define-key map "\e[12~" [f2])
+    (define-key map "\e[13~" [f3])
+    (define-key map "\e[14~" [f4])
+    (define-key map "\e[15~" [f5])
+    (define-key map "\e[17~" [f6])
+    (define-key map "\e[18~" [f7])
+    (define-key map "\e[19~" [f8])
+    (define-key map "\e[20~" [f9])
+    (define-key map "\e[21~" [f10])
+    ;; The strings emitted by f11 and f12 are the same as the strings
+    ;; emitted by S-f1 and S-f2, so don't define f11 and f12.
+    ;; (define-key map "\e[23~" [f11])
+    ;; (define-key map "\e[24~" [f12])
+    (define-key map "\e[29~" [print])
 
-  (define-key map "\e[11^" [C-f1])
-  (define-key map "\e[12^" [C-f2])
-  (define-key map "\e[13^" [C-f3])
-  (define-key map "\e[14^" [C-f4])
-  (define-key map "\e[15^" [C-f5])
-  (define-key map "\e[17^" [C-f6])
-  (define-key map "\e[18^" [C-f7])
-  (define-key map "\e[19^" [C-f8])
-  (define-key map "\e[20^" [C-f9])
-  (define-key map "\e[21^" [C-f10])
+    (define-key map "\e[11^" [C-f1])
+    (define-key map "\e[12^" [C-f2])
+    (define-key map "\e[13^" [C-f3])
+    (define-key map "\e[14^" [C-f4])
+    (define-key map "\e[15^" [C-f5])
+    (define-key map "\e[17^" [C-f6])
+    (define-key map "\e[18^" [C-f7])
+    (define-key map "\e[19^" [C-f8])
+    (define-key map "\e[20^" [C-f9])
+    (define-key map "\e[21^" [C-f10])
 
-  (define-key map "\e[23~" [S-f1])
-  (define-key map "\e[24~" [S-f2])
-  (define-key map "\e[25~" [S-f3])
-  (define-key map "\e[26~" [S-f4])
-  (define-key map "\e[28~" [S-f5])
-  (define-key map "\e[29~" [S-f6])
-  (define-key map "\e[31~" [S-f7])
-  (define-key map "\e[32~" [S-f8])
-  (define-key map "\e[33~" [S-f9])
-  (define-key map "\e[34~" [S-f10])
+    (define-key map "\e[23~" [S-f1])
+    (define-key map "\e[24~" [S-f2])
+    (define-key map "\e[25~" [S-f3])
+    (define-key map "\e[26~" [S-f4])
+    (define-key map "\e[28~" [S-f5])
+    (define-key map "\e[29~" [S-f6])
+    (define-key map "\e[31~" [S-f7])
+    (define-key map "\e[32~" [S-f8])
+    (define-key map "\e[33~" [S-f9])
+    (define-key map "\e[34~" [S-f10])
 
-  (define-key map "\e[23^" [C-S-f1])
-  (define-key map "\e[24^" [C-S-f2])
-  (define-key map "\e[25^" [C-S-f3])
-  (define-key map "\e[26^" [C-S-f4])
-  (define-key map "\e[28^" [C-S-f5])
-  (define-key map "\e[29^" [C-S-f6])
-  (define-key map "\e[31^" [C-S-f7])
-  (define-key map "\e[32^" [C-S-f8])
-  (define-key map "\e[33^" [C-S-f9])
-  (define-key map "\e[34^" [C-S-f10])
+    (define-key map "\e[23^" [C-S-f1])
+    (define-key map "\e[24^" [C-S-f2])
+    (define-key map "\e[25^" [C-S-f3])
+    (define-key map "\e[26^" [C-S-f4])
+    (define-key map "\e[28^" [C-S-f5])
+    (define-key map "\e[29^" [C-S-f6])
+    (define-key map "\e[31^" [C-S-f7])
+    (define-key map "\e[32^" [C-S-f8])
+    (define-key map "\e[33^" [C-S-f9])
+    (define-key map "\e[34^" [C-S-f10])
 
-  (define-key map "\e[2^" [C-insert])
-  (define-key map "\e[3^" [C-delete])
-  (define-key map "\e[5^" [C-prior])
-  (define-key map "\e[6^" [C-next])
-  (define-key map "\e[7^" [C-home])
-  (define-key map "\e[8^" [C-end])
-  (define-key map "\eOd" [C-left])
-  (define-key map "\eOc" [C-right])
-  (define-key map "\eOa" [C-up])
-  (define-key map "\eOb" [C-down])
+    (define-key map "\e[2^" [C-insert])
+    (define-key map "\e[3^" [C-delete])
+    (define-key map "\e[5^" [C-prior])
+    (define-key map "\e[6^" [C-next])
+    (define-key map "\e[7^" [C-home])
+    (define-key map "\e[8^" [C-end])
+    (define-key map "\eOd" [C-left])
+    (define-key map "\eOc" [C-right])
+    (define-key map "\eOa" [C-up])
+    (define-key map "\eOb" [C-down])
 
-  (define-key map "\e[2;2~" [S-insert])
-  (define-key map "\e[3$" [S-delete])
-  (define-key map "\e[5$" [S-prior])
-  (define-key map "\e[6$" [S-next])
-  (define-key map "\e[8$" [S-end])
-  (define-key map "\e[7$" [S-home])
-  (define-key map "\e[d" [S-left])
-  (define-key map "\e[c" [S-right])
-  (define-key map "\e[a" [S-up])
-  (define-key map "\e[b" [S-down])
+    (define-key map "\e[2;2~" [S-insert])
+    (define-key map "\e[3$" [S-delete])
+    (define-key map "\e[5$" [S-prior])
+    (define-key map "\e[6$" [S-next])
+    (define-key map "\e[8$" [S-end])
+    (define-key map "\e[7$" [S-home])
+    (define-key map "\e[d" [S-left])
+    (define-key map "\e[c" [S-right])
+    (define-key map "\e[a" [S-up])
+    (define-key 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 map (keymap-parent function-key-map))
-  (set-keymap-parent function-key-map map))
+    ;; 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 map (keymap-parent function-key-map))
+    (set-keymap-parent function-key-map map))
+
+  ;; Initialize colors and background mode.
+  (rxvt-register-default-colors)
+  (rxvt-set-background-mode)
+  ;; This recomputes all the default faces given the colors we've just set up.
+  (tty-set-up-initial-frame-faces))
 
 ;; Set up colors, for those versions of rxvt that support it.
 (defvar rxvt-standard-colors
@@ -228,11 +236,5 @@
 	  (setq default-frame-background-mode 'dark)))
     (frame-set-background-mode (selected-frame))))
 
-;; Do it!
-(rxvt-register-default-colors)
-(rxvt-set-background-mode)
-;; This recomputes all the default faces given the colors we've just set up.
-(tty-set-up-initial-frame-faces)
-
 ;;; arch-tag: 20cf2fb6-6318-4bab-9dbf-1d15048f2257
 ;;; rxvt.el ends here
--- a/lisp/term/sun.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/sun.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,6 @@
 ;;; sun.el --- keybinding for standard default sunterm keys
 
-;; Copyright (C) 1987, 2001 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 2001, 2005 Free Software Foundation, Inc.
 
 ;; Author: Jeff Peck <peck@sun.com>
 ;; Keywords: terminals
@@ -93,58 +93,6 @@
 ;;
 
 (defvar sun-raw-prefix (make-sparse-keymap))
-(define-key function-key-map "\e[" sun-raw-prefix)
-
-(define-key sun-raw-prefix "210z" [r3])
-(define-key sun-raw-prefix "213z" [r6])
-(define-key sun-raw-prefix "214z" [r7])
-(define-key sun-raw-prefix "216z" [r9])
-(define-key sun-raw-prefix "218z" [r11])
-(define-key sun-raw-prefix "220z" [r13])
-(define-key sun-raw-prefix "222z" [r15])
-(define-key sun-raw-prefix "193z" [redo])
-(define-key sun-raw-prefix "194z" [props])
-(define-key sun-raw-prefix "195z" [undo])
-;; (define-key sun-raw-prefix "196z" 'ignore)		; Expose-down
-;; (define-key sun-raw-prefix "197z" [put])
-;; (define-key sun-raw-prefix "198z" 'ignore)		; Open-down
-;; (define-key sun-raw-prefix "199z" [get])
-(define-key sun-raw-prefix "200z" [find])
-;; (define-key sun-raw-prefix "201z" 'kill-region-and-unmark)	; Delete
-(define-key sun-raw-prefix "224z" [f1])
-(define-key sun-raw-prefix "225z" [f2])
-(define-key sun-raw-prefix "226z" [f3])
-(define-key sun-raw-prefix "227z" [f4])
-(define-key sun-raw-prefix "228z" [f5])
-(define-key sun-raw-prefix "229z" [f6])
-(define-key sun-raw-prefix "230z" [f7])
-(define-key sun-raw-prefix "231z" [f8])
-(define-key sun-raw-prefix "232z" [f9])
-(define-key sun-raw-prefix "233z" [f10])
-(define-key sun-raw-prefix "234z" [f11])
-(define-key sun-raw-prefix "235z" [f12])
-(define-key sun-raw-prefix "A" [up])			; R8
-(define-key sun-raw-prefix "B" [down])			; R14
-(define-key sun-raw-prefix "C" [right])			; R12
-(define-key sun-raw-prefix "D" [left])			; R10
-
-(global-set-key [r3]	'backward-page)
-(global-set-key [r6]	'forward-page)
-(global-set-key [r7]	'beginning-of-buffer)
-(global-set-key [r9]	'scroll-down)
-(global-set-key [r11]	'recenter)
-(global-set-key [r13]	'end-of-buffer)
-(global-set-key [r15]	'scroll-up)
-(global-set-key [redo]	'redraw-display)  ;FIXME: collides with default.
-(global-set-key [props]	'list-buffers)
-(global-set-key [put]	'sun-select-region)
-(global-set-key [get]	'sun-yank-selection)
-(global-set-key [find]	'exchange-point-and-mark)
-(global-set-key [f3]	'scroll-down-in-place)
-(global-set-key [f4]	'scroll-up-in-place)
-(global-set-key [f6]	'shrink-window)
-(global-set-key [f7]	'enlarge-window)
-
 
 ;; Since .emacs gets loaded before this file, a hook is supplied
 ;; for you to put your own bindings in.
@@ -152,13 +100,6 @@
 (defvar sun-raw-prefix-hooks nil
   "List of forms to evaluate after setting sun-raw-prefix.")
 
-(when sun-raw-prefix-hooks
-  (message "sun-raw-prefix-hooks is obsolete!  Use term-setup-hook instead!")
-  (let ((hooks sun-raw-prefix-hooks))
-    (while hooks
-      (eval (car hooks))
-      (setq hooks (cdr hooks)))))
-
 
 ;;; This section adds definitions for the emacstool users
 ;; emacstool event filter converts function keys to C-x*{c}{lrt}
@@ -188,44 +129,6 @@
 (defvar suntool-map (make-sparse-keymap)
   "*Keymap for Emacstool bindings.")
 
-(define-key suntool-map "gr" 'beginning-of-buffer)	; r7
-(define-key suntool-map "iR" 'backward-page)		; R9
-(define-key suntool-map "ir" 'scroll-down)		; r9
-(define-key suntool-map "kr" 'recenter)			; r11
-(define-key suntool-map "mr" 'end-of-buffer)		; r13
-(define-key suntool-map "oR" 'forward-page)		; R15
-(define-key suntool-map "or" 'scroll-up)		; r15
-(define-key suntool-map "b\M-L" 'rerun-prev-command)	; M-AGAIN
-(define-key suntool-map "b\M-l" 'prev-complex-command)	; M-Again
-(define-key suntool-map "bl" 'redraw-display)		; Again
-(define-key suntool-map "cl" 'list-buffers)		; Props
-(define-key suntool-map "dl" 'undo)			; Undo
-(define-key suntool-map "el" 'ignore)			; Expose-Open
-(define-key suntool-map "fl" 'sun-select-region)	; Put
-(define-key suntool-map "f," 'copy-region-as-kill)	; C-Put
-(define-key suntool-map "gl" 'ignore)			; Open-Open
-(define-key suntool-map "hl" 'sun-yank-selection)	; Get
-(define-key suntool-map "h," 'yank)			; C-Get
-(define-key suntool-map "il" 'research-forward)		; Find
-(define-key suntool-map "i," 're-search-forward)	; C-Find
-(define-key suntool-map "i\M-l" 'research-backward)	; M-Find
-(define-key suntool-map "i\M-," 're-search-backward)	; C-M-Find
-
-(define-key suntool-map "jL" 'yank)			; DELETE
-(define-key suntool-map "jl" 'kill-region-and-unmark)	; Delete
-(define-key suntool-map "j\M-l" 'exchange-point-and-mark); M-Delete
-(define-key suntool-map "j,"
-  (lambda () (interactive) (pop-mark)))		; C-Delete
-
-(define-key suntool-map "fT" 'shrink-window-horizontally)	; T6
-(define-key suntool-map "gT" 'enlarge-window-horizontally)	; T7
-(define-key suntool-map "ft" 'shrink-window)			; t6
-(define-key suntool-map "gt" 'enlarge-window)			; t7
-(define-key suntool-map "cT" (lambda (n) (interactive "p") (scroll-down n)))
-(define-key suntool-map "dT" (lambda (n) (interactive "p") (scroll-up n)))
-(define-key suntool-map "ct" 'scroll-down-in-place)		; t3
-(define-key suntool-map "dt" 'scroll-up-in-place)		; t4
-(define-key ctl-x-map "*" suntool-map)
 
 ;; Since .emacs gets loaded before this file, a hook is supplied
 ;; for you to put your own bindings in.
@@ -233,13 +136,6 @@
 (defvar suntool-map-hooks nil
   "List of forms to evaluate after setting suntool-map.")
 
-(when suntool-map-hooks
-  (message "suntool-map-hooks is obsolete!  Use term-setup-hook instead!")
-  (let ((hooks suntool-map-hooks))
-    (while hooks
-      (eval (car hooks))
-      (setq hooks (cdr hooks)))))
-
 ;;
 ;; If running under emacstool, arrange to call suspend-emacstool
 ;; instead of suspend-emacs.
@@ -251,6 +147,115 @@
 (autoload 'sun-mouse-handler "sun-mouse"
 	  "Sun Emacstool handler for mouse blips (not loaded)." t)
 
+(defun terminal-init-sun ()
+  "Terminal initialization function for sun."
+  (define-key function-key-map "\e[" sun-raw-prefix)
+
+  (define-key sun-raw-prefix "210z" [r3])
+  (define-key sun-raw-prefix "213z" [r6])
+  (define-key sun-raw-prefix "214z" [r7])
+  (define-key sun-raw-prefix "216z" [r9])
+  (define-key sun-raw-prefix "218z" [r11])
+  (define-key sun-raw-prefix "220z" [r13])
+  (define-key sun-raw-prefix "222z" [r15])
+  (define-key sun-raw-prefix "193z" [redo])
+  (define-key sun-raw-prefix "194z" [props])
+  (define-key sun-raw-prefix "195z" [undo])
+  ;; (define-key sun-raw-prefix "196z" 'ignore)		; Expose-down
+  ;; (define-key sun-raw-prefix "197z" [put])
+  ;; (define-key sun-raw-prefix "198z" 'ignore)		; Open-down
+  ;; (define-key sun-raw-prefix "199z" [get])
+  (define-key sun-raw-prefix "200z" [find])
+  ;; (define-key sun-raw-prefix "201z" 'kill-region-and-unmark)	; Delete
+  (define-key sun-raw-prefix "224z" [f1])
+  (define-key sun-raw-prefix "225z" [f2])
+  (define-key sun-raw-prefix "226z" [f3])
+  (define-key sun-raw-prefix "227z" [f4])
+  (define-key sun-raw-prefix "228z" [f5])
+  (define-key sun-raw-prefix "229z" [f6])
+  (define-key sun-raw-prefix "230z" [f7])
+  (define-key sun-raw-prefix "231z" [f8])
+  (define-key sun-raw-prefix "232z" [f9])
+  (define-key sun-raw-prefix "233z" [f10])
+  (define-key sun-raw-prefix "234z" [f11])
+  (define-key sun-raw-prefix "235z" [f12])
+  (define-key sun-raw-prefix "A" [up])			; R8
+  (define-key sun-raw-prefix "B" [down])		; R14
+  (define-key sun-raw-prefix "C" [right])		; R12
+  (define-key sun-raw-prefix "D" [left])		; R10
+
+  (global-set-key [r3]	'backward-page)
+  (global-set-key [r6]	'forward-page)
+  (global-set-key [r7]	'beginning-of-buffer)
+  (global-set-key [r9]	'scroll-down)
+  (global-set-key [r11]	'recenter)
+  (global-set-key [r13]	'end-of-buffer)
+  (global-set-key [r15]	'scroll-up)
+  (global-set-key [redo]	'redraw-display) ;FIXME: collides with default.
+  (global-set-key [props]	'list-buffers)
+  (global-set-key [put]	'sun-select-region)
+  (global-set-key [get]	'sun-yank-selection)
+  (global-set-key [find]	'exchange-point-and-mark)
+  (global-set-key [f3]	'scroll-down-in-place)
+  (global-set-key [f4]	'scroll-up-in-place)
+  (global-set-key [f6]	'shrink-window)
+  (global-set-key [f7]	'enlarge-window)
+
+  (when sun-raw-prefix-hooks
+    (message "sun-raw-prefix-hooks is obsolete!  Use term-setup-hook instead!")
+    (let ((hooks sun-raw-prefix-hooks))
+      (while hooks
+	(eval (car hooks))
+	(setq hooks (cdr hooks)))))
+
+  (define-key suntool-map "gr" 'beginning-of-buffer)	; r7
+  (define-key suntool-map "iR" 'backward-page)		; R9
+  (define-key suntool-map "ir" 'scroll-down)		; r9
+  (define-key suntool-map "kr" 'recenter)		; r11
+  (define-key suntool-map "mr" 'end-of-buffer)		; r13
+  (define-key suntool-map "oR" 'forward-page)		; R15
+  (define-key suntool-map "or" 'scroll-up)		; r15
+  (define-key suntool-map "b\M-L" 'rerun-prev-command)	; M-AGAIN
+  (define-key suntool-map "b\M-l" 'prev-complex-command) ; M-Again
+  (define-key suntool-map "bl" 'redraw-display)		 ; Again
+  (define-key suntool-map "cl" 'list-buffers)		 ; Props
+  (define-key suntool-map "dl" 'undo)			 ; Undo
+  (define-key suntool-map "el" 'ignore)			 ; Expose-Open
+  (define-key suntool-map "fl" 'sun-select-region)	 ; Put
+  (define-key suntool-map "f," 'copy-region-as-kill)	 ; C-Put
+  (define-key suntool-map "gl" 'ignore)			 ; Open-Open
+  (define-key suntool-map "hl" 'sun-yank-selection)	 ; Get
+  (define-key suntool-map "h," 'yank)			 ; C-Get
+  (define-key suntool-map "il" 'research-forward)	 ; Find
+  (define-key suntool-map "i," 're-search-forward)	 ; C-Find
+  (define-key suntool-map "i\M-l" 'research-backward)	 ; M-Find
+  (define-key suntool-map "i\M-," 're-search-backward)	 ; C-M-Find
+
+  (define-key suntool-map "jL" 'yank)			; DELETE
+  (define-key suntool-map "jl" 'kill-region-and-unmark)	; Delete
+  (define-key suntool-map "j\M-l" 'exchange-point-and-mark) ; M-Delete
+  (define-key suntool-map "j,"
+    (lambda () (interactive) (pop-mark))) ; C-Delete
+
+  (define-key suntool-map "fT" 'shrink-window-horizontally)	; T6
+  (define-key suntool-map "gT" 'enlarge-window-horizontally)	; T7
+  (define-key suntool-map "ft" 'shrink-window)			; t6
+  (define-key suntool-map "gt" 'enlarge-window)			; t7
+  (define-key suntool-map "cT" (lambda (n) (interactive "p") (scroll-down n)))
+  (define-key suntool-map "dT" (lambda (n) (interactive "p") (scroll-up n)))
+  (define-key suntool-map "ct" 'scroll-down-in-place)		; t3
+  (define-key suntool-map "dt" 'scroll-up-in-place)		; t4
+  (define-key ctl-x-map "*" suntool-map)
+
+  (when suntool-map-hooks
+    (message "suntool-map-hooks is obsolete!  Use term-setup-hook instead!")
+    (let ((hooks suntool-map-hooks))
+      (while hooks
+	(eval (car hooks))
+	(setq hooks (cdr hooks)))))
+  
+  (define-key ctl-x-map "\C-@" 'sun-mouse-once))
+
 (defun emacstool-init ()
   "Set up Emacstool window, if you know you are in an emacstool."
   ;; Make sure sun-mouse and sun-fns are loaded.
@@ -272,7 +277,6 @@
   (interactive)
   (emacstool-init)
   (sun-mouse-handler))			; Now, execute this mouse blip.
-(define-key ctl-x-map "\C-@" 'sun-mouse-once)
 
 ;;; arch-tag: db761d47-fd7d-42b4-aae1-04fa116b6ba6
 ;;; sun.el ends here
--- a/lisp/term/tvi970.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/tvi970.el	Wed Jul 27 18:02:08 2005 +0000
@@ -3,7 +3,7 @@
 ;; Author: Jim Blandy <jimb@occs.cs.oberlin.edu>, January 1992
 ;; Keywords: terminals
 
-;; Copyright (C) 1992 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 2005 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -28,77 +28,80 @@
 
 ;;; Code:
 
-(or (lookup-key function-key-map "\e[")
-    (define-key function-key-map "\e[" (make-keymap)))
-;; (or (lookup-key function-key-map "\eO")
-;;    (define-key function-key-map "\eO" (make-keymap)))
+(defun terminal-init-tvi970 ()
+  "Terminal initialization function for tvi970."
+  (or (lookup-key function-key-map "\e[")
+      (define-key function-key-map "\e[" (make-keymap)))
+  ;; (or (lookup-key function-key-map "\eO")
+  ;;    (define-key function-key-map "\eO" (make-keymap)))
 
-;; Miscellaneous keys
-(mapcar (function (lambda (key-binding)
-		    (define-key function-key-map
-		      (car key-binding) (nth 1 key-binding))))
-	'(
-	  ;; These are set up by termcap or terminfo
-	  ;; ("\eOP"	[kp-f1])
-	  ;; ("\eOQ"	[kp-f2])
-	  ;; ("\eOR"	[kp-f3])
-	  ;; ("\eOS"	[kp-f4])
+  ;; Miscellaneous keys
+  (mapcar (function (lambda (key-binding)
+		      (define-key function-key-map
+			(car key-binding) (nth 1 key-binding))))
+	  '(
+	    ;; These are set up by termcap or terminfo
+	    ;; ("\eOP"	[kp-f1])
+	    ;; ("\eOQ"	[kp-f2])
+	    ;; ("\eOR"	[kp-f3])
+	    ;; ("\eOS"	[kp-f4])
 
-	  ;; These might br set by terminfo
-	  ("\e[H"	[home])
-	  ("\e[Z"	[backtab])
-	  ("\e[i"	[print])
-	  ("\e[@"	[insert])
-	  ("\e[L"	[insertline])
-	  ("\e[M"	[deleteline])
-	  ("\e[U"	[next])		;; actually the `page' key
+	    ;; These might br set by terminfo
+	    ("\e[H"	[home])
+	    ("\e[Z"	[backtab])
+	    ("\e[i"	[print])
+	    ("\e[@"	[insert])
+	    ("\e[L"	[insertline])
+	    ("\e[M"	[deleteline])
+	    ("\e[U"	[next])	;; actually the `page' key
 
-	  ;; These won't be set up by either
-	  ("\eOm"	[kp-subtract])
-	  ("\eOl"	[kp-separator])
-	  ("\eOn"	[kp-decimal])
-	  ("\eOM"	[kp-enter])
+	    ;; These won't be set up by either
+	    ("\eOm"	[kp-subtract])
+	    ("\eOl"	[kp-separator])
+	    ("\eOn"	[kp-decimal])
+	    ("\eOM"	[kp-enter])
 
-	  ;; These won't be set up by either either
-	  ("\e[K"	[key_eol])	;; Not an X keysym
-	  ("\e[J"	[key_eos])	;; Not an X keysym
-	  ("\e[2J"	[key_clear])	;; Not an X keysym
-	  ("\e[P"	[key_dc])	;; Not an X keysym
-	  ("\e[g"	[S-tab])	;; Not an X keysym
-	  ("\e[2N"	[clearentry])	;; Not an X keysym
-	  ("\e[2K"	[S-clearentry])	;; Not an X keysym
-	  ("\e[E"	[?\C-j])	;; Not an X keysym
-	  ("\e[g"	[S-backtab])	;; Not an X keysym
-	  ("\e[?1i"	[key_sprint])	;; Not an X keysym
-	  ("\e[4h"	[key_sic])	;; Not an X keysym
-	  ("\e[4l"	[S-delete])	;; Not an X keysym
-	  ("\e[Q"	[S-insertline])	;; Not an X keysym
-	  ("\e[1Q"	[key_sdl])	;; Not an X keysym
-	  ("\e[19l"	[key_seol])	;; Not an X keysym
-	  ("\e[19h"	[S-erasepage])	;; Not an X keysym
-	  ("\e[V"	[S-page])	;; Not an X keysym
-	  ("\eS"	[send])		;; Not an X keysym
-	  ("\e5"	[S-send])	;; Not an X keysym
-	  ))
+	    ;; These won't be set up by either either
+	    ("\e[K"	[key_eol])	;; Not an X keysym
+	    ("\e[J"	[key_eos])	;; Not an X keysym
+	    ("\e[2J"	[key_clear])	;; Not an X keysym
+	    ("\e[P"	[key_dc])	;; Not an X keysym
+	    ("\e[g"	[S-tab])	;; Not an X keysym
+	    ("\e[2N"	[clearentry])	;; Not an X keysym
+	    ("\e[2K"	[S-clearentry])	;; Not an X keysym
+	    ("\e[E"	[?\C-j])	;; Not an X keysym
+	    ("\e[g"	[S-backtab])	;; Not an X keysym
+	    ("\e[?1i"	[key_sprint])	;; Not an X keysym
+	    ("\e[4h"	[key_sic])	;; Not an X keysym
+	    ("\e[4l"	[S-delete])	;; Not an X keysym
+	    ("\e[Q"	[S-insertline])	;; Not an X keysym
+	    ("\e[1Q"	[key_sdl])	;; Not an X keysym
+	    ("\e[19l"	[key_seol])	;; Not an X keysym
+	    ("\e[19h"	[S-erasepage])	;; Not an X keysym
+	    ("\e[V"	[S-page])	;; Not an X keysym
+	    ("\eS"	[send])		;; Not an X keysym
+	    ("\e5"	[S-send])	;; Not an X keysym
+	    ))
 
-;; The numeric keypad keys.
-(let ((i 0))
-  (while (< i 10)
-    (define-key function-key-map
-      (format "\eO%c" (+ i ?p))
-      (vector (intern (format "kp-%d" i))))
-    (setq i (1+ i))))
-;; The numbered function keys.
-(let ((i 0))
-  (while (< i 16)
-    (define-key function-key-map
-      (format "\e?%c" (+ i ?a))
-      (vector (intern (format "f%d" (1+ i)))))
-    (define-key function-key-map
-      (format "\e?%c" (+ i ?A))
-      (vector (intern (format "S-f%d" (1+ i)))))
-    (setq i (1+ i))))
+  ;; The numeric keypad keys.
+  (let ((i 0))
+    (while (< i 10)
+      (define-key function-key-map
+	(format "\eO%c" (+ i ?p))
+	(vector (intern (format "kp-%d" i))))
+      (setq i (1+ i))))
+  ;; The numbered function keys.
+  (let ((i 0))
+    (while (< i 16)
+      (define-key function-key-map
+	(format "\e?%c" (+ i ?a))
+	(vector (intern (format "f%d" (1+ i)))))
+      (define-key function-key-map
+	(format "\e?%c" (+ i ?A))
+	(vector (intern (format "S-f%d" (1+ i)))))
+      (setq i (1+ i))))
 
+  (tvi970-set-keypad-mode 1))
 
 ;;; Should keypad numbers send ordinary digits or distinct escape sequences?
 (defvar tvi970-keypad-numeric nil
@@ -121,7 +124,5 @@
 	  (> (prefix-numeric-value arg) 0)))
   (send-string-to-terminal (if tvi970-keypad-numeric "\e=" "\e>")))
 
-(tvi970-set-keypad-mode 1)
-
 ;;; arch-tag: c1334cf0-1462-41c3-a963-c077d175f8f0
 ;;; tvi970.el ends here
--- a/lisp/term/vt100.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt100.el	Wed Jul 27 18:02:08 2005 +0000
@@ -36,8 +36,12 @@
 ;;; Code:
 
 ;; Set up function-key-map entries that termcap and terminfo don't know.
-(load "term/lk201" nil t)
+
 
+(defun terminal-init-vt100 ()
+  "Terminal initialization function for vt100."
+  (load "term/lk201" nil t))
+  
 ;;; Controlling the screen width.
 (defvar vt100-wide-mode (= (frame-width) 132)
   "t if vt100 is in 132-column mode.")
--- a/lisp/term/vt102.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt102.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,8 @@
 ;; -*- no-byte-compile: t -*-
 
-(load "term/vt100" nil t)
+(defun terminal-init-vt102 ()
+  "Terminal initialization function for vt102."  
+  (load "term/vt100" nil t))
 
 ;;; arch-tag: 6e839cfc-125a-4574-82f1-c23a51f7c50f
 ;;; vt102.el ends here
--- a/lisp/term/vt125.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt125.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,8 @@
 ;; -*- no-byte-compile: t -*-
 
-(load "term/vt100" nil t)
+(defun terminal-init-vt125 ()
+  "Terminal initialization function for vt125."  
+  (load "term/vt100" nil t))
 
 ;;; arch-tag: 1d92d70f-dd55-4a1d-9088-e215a4883801
 ;;; vt125.el ends here
--- a/lisp/term/vt200.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt200.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,10 +1,12 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
 
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt200 ()
+  "Terminal initialization function for vt200."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: 0f78f583-9f32-4237-b106-28bcfff21d89
 ;;; vt200.el ends here
--- a/lisp/term/vt201.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt201.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,10 +1,11 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt201 ()
+  "Terminal initialization function for vt201."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: a6abb38f-60ea-449e-a9e9-3fb8572c52ae
 ;;; vt201.el ends here
--- a/lisp/term/vt220.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt220.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,10 +1,11 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt220 ()
+  "Terminal initialization function for vt220."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: 98fc4867-a20d-46a1-a276-d7be31e49871
 ;;; vt220.el ends here
--- a/lisp/term/vt240.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt240.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,10 +1,11 @@
 ;; -*- no-byte-compile: t -*-
 ;; For our purposes we can treat the vt200 and vt100 almost alike.
 ;; Most differences are handled by the termcap entry.
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt240 ()
+  "Terminal initialization function for vt240."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: d9f88e9c-02dc-49ff-871c-a415f08e4eb7
 ;;; vt240.el ends here
--- a/lisp/term/vt300.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt300.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt300 ()
+  "Terminal initialization function for vt300."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: 876831c9-a6f2-444a-b033-706e6fbc149f
 ;;; vt300.el ends here
--- a/lisp/term/vt320.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt320.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt320 ()
+  "Terminal initialization function for vt320."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: f9f4c954-0b9e-45f9-b450-a320d32abd9c
 ;;; vt320.el ends here
--- a/lisp/term/vt400.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt400.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt400 ()
+  "Terminal initialization function for vt400."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: a70809c5-6b21-42cc-ba20-536683e5e7d5
 ;;; vt400.el ends here
--- a/lisp/term/vt420.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/vt420.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,8 +1,9 @@
 ;; -*- no-byte-compile: t -*-
-(load "term/vt100" nil t)
-
-;; Make F11 an escape key.
-(define-key function-key-map "\e[23~" [?\e])
+(defun terminal-init-vt420 ()
+  "Terminal initialization function for vt420."  
+  (load "term/vt100" nil t)
+  ;; Make F11 an escape key.
+  (define-key function-key-map "\e[23~" [?\e]))
 
 ;;; arch-tag: df2f897c-3a12-4b3c-9259-df089f96c160
 ;;; vt420.el ends here
--- a/lisp/term/wyse50.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/wyse50.el	Wed Jul 27 18:02:08 2005 +0000
@@ -1,6 +1,6 @@
 ;;; wyse50.el --- terminal support code for Wyse 50 -*- no-byte-compile: t -*-
 
-;; Copyright (C) 1989, 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1989, 1993, 1994, 2005 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pfeiffer <occitan@esperanto.org>,
 ;;	Jim Blandy <jimb@occs.cs.oberlin.edu>
@@ -37,74 +37,92 @@
 
 ;;; Code:
 
-(define-key function-key-map "\C-a" (make-keymap))
-(mapcar (function (lambda (key-definition)
-		    (define-key function-key-map
-		      (car key-definition) (nth 1 key-definition))))
-	'(
-	  ;; These might be set up by termcap and terminfo
-	  ("\C-k"	[up])
-	  ("\C-j"	[down])
-	  ("\C-l"	[right])
-	  ("\C-h"	[left])
-	  ("\^a@\^m"	[f1])
-	  ("\^aA\^m"	[f2])
-	  ("\^aB\^m"	[f3])
-	  ("\^aC\^m"	[f4])
-	  ("\^aD\^m"	[f5])
-	  ("\^aE\^m"	[f6])
-	  ("\^aF\^m"	[f7])
-	  ("\^aG\^m"	[f8])
-	  ("\^aH\^m"	[f9])
+(defun terminal-init-wyse50 ()
+  "Terminal initialization function for wyse50."
+  (define-key function-key-map "\C-a" (make-keymap))
+  (mapcar (function (lambda (key-definition)
+		      (define-key function-key-map
+			(car key-definition) (nth 1 key-definition))))
+	  '(
+	    ;; These might be set up by termcap and terminfo
+	    ("\C-k"	[up])
+	    ("\C-j"	[down])
+	    ("\C-l"	[right])
+	    ("\C-h"	[left])
+	    ("\^a@\^m"	[f1])
+	    ("\^aA\^m"	[f2])
+	    ("\^aB\^m"	[f3])
+	    ("\^aC\^m"	[f4])
+	    ("\^aD\^m"	[f5])
+	    ("\^aE\^m"	[f6])
+	    ("\^aF\^m"	[f7])
+	    ("\^aG\^m"	[f8])
+	    ("\^aH\^m"	[f9])
 
-	  ;; These might be set up by terminfo
-	  ("\eK"	[next])
-	  ("\eT"	[clearline])
-	  ("\^^"	[home])
-	  ("\e\^^"	[end])
-	  ("\eQ"	[insert])
-	  ("\eE"	[insertline])
-	  ("\eR"	[deleteline])
-	  ("\eP"	[print])
-	  ("\er"	[replace])
-	  ("\^aI\^m"	[f10])
-	  ("\^aJ\^m"	[f11])
-	  ("\^aK\^m"	[f12])
-	  ("\^aL\^m"	[f13])
-	  ("\^aM\^m"	[f14])
-	  ("\^aN\^m"	[f15])
-	  ("\^aO\^m"	[f16])
-	  ("\^a`\^m"	[f17])
-	  ("\^aa\^m"	[f18])
-	  ("\^ab\^m"	[f19])
-	  ("\^ac\^m"	[f20])
-	  ("\^ad\^m"	[f21])
-	  ("\^ae\^m"	[f22])
-	  ("\^af\^m"	[f23])
-	  ("\^ag\^m"	[f24])
-	  ("\^ah\^m"	[f25])
-	  ("\^ai\^m"	[f26])
-	  ("\^aj\^m"	[f27])
-	  ("\^ak\^m"	[f28])
-	  ("\^al\^m"	[f29])
-	  ("\^am\^m"	[f30])
-	  ("\^an\^m"	[f31])
-	  ("\^ao\^m"	[f32])
+	    ;; These might be set up by terminfo
+	    ("\eK"	[next])
+	    ("\eT"	[clearline])
+	    ("\^^"	[home])
+	    ("\e\^^"	[end])
+	    ("\eQ"	[insert])
+	    ("\eE"	[insertline])
+	    ("\eR"	[deleteline])
+	    ("\eP"	[print])
+	    ("\er"	[replace])
+	    ("\^aI\^m"	[f10])
+	    ("\^aJ\^m"	[f11])
+	    ("\^aK\^m"	[f12])
+	    ("\^aL\^m"	[f13])
+	    ("\^aM\^m"	[f14])
+	    ("\^aN\^m"	[f15])
+	    ("\^aO\^m"	[f16])
+	    ("\^a`\^m"	[f17])
+	    ("\^aa\^m"	[f18])
+	    ("\^ab\^m"	[f19])
+	    ("\^ac\^m"	[f20])
+	    ("\^ad\^m"	[f21])
+	    ("\^ae\^m"	[f22])
+	    ("\^af\^m"	[f23])
+	    ("\^ag\^m"	[f24])
+	    ("\^ah\^m"	[f25])
+	    ("\^ai\^m"	[f26])
+	    ("\^aj\^m"	[f27])
+	    ("\^ak\^m"	[f28])
+	    ("\^al\^m"	[f29])
+	    ("\^am\^m"	[f30])
+	    ("\^an\^m"	[f31])
+	    ("\^ao\^m"	[f32])
 
-	  ;; Terminfo may know about these, but X won't
-	  ("\eI"	[key-stab])		;; Not an X keysym
-	  ("\eJ"	[key-snext])		;; Not an X keysym
-	  ("\eY"	[key-clear])		;; Not an X keysym
+	    ;; Terminfo may know about these, but X won't
+	    ("\eI"	[key-stab])		;; Not an X keysym
+	    ("\eJ"	[key-snext])		;; Not an X keysym
+	    ("\eY"	[key-clear])		;; Not an X keysym
+
+	    ;; These are totally strange :-)
+	    ("\eW"	[?\C-?])	    ;; Not an X keysym
+	    ("\^a\^k\^m"	[funct-up]) ;; Not an X keysym
+	    ("\^a\^j\^m"	[funct-down])  ;; Not an X keysym
+	    ("\^a\^l\^m"	[funct-right]) ;; Not an X keysym
+	    ("\^a\^h\^m"	[funct-left])  ;; Not an X keysym
+	    ("\^a\^m\^m"	[funct-return])	;; Not an X keysym
+	    ("\^a\^i\^m"	[funct-tab])	;; Not an X keysym
+	    ))
 
-	  ;; These are totally strange :-)
-	  ("\eW"	[?\C-?])	;; Not an X keysym
-	  ("\^a\^k\^m"	[funct-up])	;; Not an X keysym
-	  ("\^a\^j\^m"	[funct-down])	;; Not an X keysym
-	  ("\^a\^l\^m"	[funct-right])	;; Not an X keysym
-	  ("\^a\^h\^m"	[funct-left])	;; Not an X keysym
-	  ("\^a\^m\^m"	[funct-return])	;; Not an X keysym
-	  ("\^a\^i\^m"	[funct-tab])	;; Not an X keysym
-))
+  ;; Miscellaneous hacks
+
+  ;; This is an ugly hack for a nasty problem:
+  ;; Wyse 50 takes one character cell to store video attributes (which seems to
+  ;; explain width 79 rather than 80, column 1 is not used!!!).
+  ;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
+  ;; of the mode line is overwritten AFTER all the y-or-n questions.
+  ;; This causes the attribute to remain in effect until the mode line has
+  ;; scrolled of the screen.  Suspending (C-z) does not cause this problem.
+  ;; On such terminals, Emacs should sacrifice the first and last character of
+  ;; each mode line, rather than a whole screen column!
+  (add-hook 'kill-emacs-hook
+	    (function (lambda () (interactive)
+			(send-string-to-terminal
+			 (concat "\ea23R" (1+ (frame-width)) "C\eG0"))))))
 
 (defun enable-arrow-keys ()
   "To be called by term-setup-hook. Overrides 6 Emacs standard keys
@@ -131,22 +149,5 @@
 	    ("\er"	nil)))
   (fset 'enable-arrow-keys nil))
 
-
-;;; Miscellaneous hacks
-
-;;; This is an ugly hack for a nasty problem:
-;;; Wyse 50 takes one character cell to store video attributes (which seems to
-;;; explain width 79 rather than 80, column 1 is not used!!!).
-;;; On killing (C-x C-c) the end inverse code (on column 1 of line 24)
-;;; of the mode line is overwritten AFTER all the y-or-n questions.
-;;; This causes the attribute to remain in effect until the mode line has
-;;; scrolled of the screen.  Suspending (C-z) does not cause this problem.
-;;; On such terminals, Emacs should sacrifice the first and last character of
-;;; each mode line, rather than a whole screen column!
-(add-hook 'kill-emacs-hook
-	  (function (lambda () (interactive)
-		      (send-string-to-terminal
-		       (concat "\ea23R" (1+ (frame-width)) "C\eG0")))))
-
 ;;; arch-tag: b6a05d37-eead-4cf6-b997-0f956c68881c
 ;;; wyse50.el ends here
--- a/lisp/term/xterm.el	Wed Jul 27 15:30:42 2005 +0000
+++ b/lisp/term/xterm.el	Wed Jul 27 18:02:08 2005 +0000
@@ -26,229 +26,238 @@
 
 ;;; Code:
 
-;;; rxvt terminals sometimes set the TERM variable to "xterm", but
-;;; rxvt's keybindings that are incompatible with xterm's. It is
-;;; better in that case to load rxvt's terminal initialization file.
-(if (and (getenv "COLORTERM")
-	 (string-match "\\`rxvt" (getenv "COLORTERM")))
-    (load "term/rxvt")
+(defun terminal-init-xterm ()
+  "Terminal initialization function for xterm."
+  ;; rxvt terminals sometimes set the TERM variable to "xterm", but
+  ;; rxvt's keybindings that are incompatible with xterm's. It is
+  ;; better in that case to use rxvt's initializion function.
+  (if (and (getenv "COLORTERM")
+	   (string-match "\\`rxvt" (getenv "COLORTERM")))
+      (progn 
+	(load "term/rxvt")
+	(terminal-init-rxvt))
 
-;;; 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)
+    ;; 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 [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 [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)
+
+    (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)
 
-(let ((map (make-sparse-keymap)))
-  (define-key map "\e[A" [up])
-  (define-key map "\e[B" [down])
-  (define-key map "\e[C" [right])
-  (define-key map "\e[D" [left])
-  (define-key map "\e[1~" [home])
-  (define-key map "\e[2~" [insert])
-  (define-key map "\e[3~" [delete])
-  (define-key map "\e[4~" [select])
-  (define-key map "\e[5~" [prior])
-  (define-key map "\e[6~" [next])
-  (define-key map "\e[11~" [f1])
-  (define-key map "\e[12~" [f2])
-  (define-key map "\e[13~" [f3])
-  (define-key map "\e[14~" [f4])
-  (define-key map "\e[15~" [f5])
-  (define-key map "\e[17~" [f6])
-  (define-key map "\e[18~" [f7])
-  (define-key map "\e[19~" [f8])
-  (define-key map "\e[20~" [f9])
-  (define-key map "\e[21~" [f10])
-  (define-key map "\e[23~" [f11])
-  (define-key map "\e[24~" [f12])
-  (define-key map "\e[29~" [print])
+    (let ((map (make-sparse-keymap)))
+      (define-key map "\e[A" [up])
+      (define-key map "\e[B" [down])
+      (define-key map "\e[C" [right])
+      (define-key map "\e[D" [left])
+      (define-key map "\e[1~" [home])
+      (define-key map "\e[2~" [insert])
+      (define-key map "\e[3~" [delete])
+      (define-key map "\e[4~" [select])
+      (define-key map "\e[5~" [prior])
+      (define-key map "\e[6~" [next])
+      (define-key map "\e[11~" [f1])
+      (define-key map "\e[12~" [f2])
+      (define-key map "\e[13~" [f3])
+      (define-key map "\e[14~" [f4])
+      (define-key map "\e[15~" [f5])
+      (define-key map "\e[17~" [f6])
+      (define-key map "\e[18~" [f7])
+      (define-key map "\e[19~" [f8])
+      (define-key map "\e[20~" [f9])
+      (define-key map "\e[21~" [f10])
+      (define-key map "\e[23~" [f11])
+      (define-key map "\e[24~" [f12])
+      (define-key map "\e[29~" [print])
 
-  (define-key map "\eOP" [f1])
-  (define-key map "\eOQ" [f2])
-  (define-key map "\eOR" [f3])
-  (define-key map "\eOS" [f4])
+      (define-key map "\eOP" [f1])
+      (define-key map "\eOQ" [f2])
+      (define-key map "\eOR" [f3])
+      (define-key map "\eOS" [f4])
 
-  (define-key map "\eO2P" [S-f1])
-  (define-key map "\eO2Q" [S-f2])
-  (define-key map "\eO2R" [S-f3])
-  (define-key map "\eO2S" [S-f4])
-  (define-key map "\e[15;2~" [S-f5])
-  (define-key map "\e[17;2~" [S-f6])
-  (define-key map "\e[18;2~" [S-f7])
-  (define-key map "\e[19;2~" [S-f8])
-  (define-key map "\e[20;2~" [S-f9])
-  (define-key map "\e[21;2~" [S-f10])
-  (define-key map "\e[23;2~" [S-f11])
-  (define-key map "\e[24;2~" [S-f12])
+      (define-key map "\eO2P" [S-f1])
+      (define-key map "\eO2Q" [S-f2])
+      (define-key map "\eO2R" [S-f3])
+      (define-key map "\eO2S" [S-f4])
+      (define-key map "\e[15;2~" [S-f5])
+      (define-key map "\e[17;2~" [S-f6])
+      (define-key map "\e[18;2~" [S-f7])
+      (define-key map "\e[19;2~" [S-f8])
+      (define-key map "\e[20;2~" [S-f9])
+      (define-key map "\e[21;2~" [S-f10])
+      (define-key map "\e[23;2~" [S-f11])
+      (define-key map "\e[24;2~" [S-f12])
 
-  (define-key map "\eO5P" [C-f1])
-  (define-key map "\eO5Q" [C-f2])
-  (define-key map "\eO5R" [C-f3])
-  (define-key map "\eO5S" [C-f4])
-  (define-key map "\e[15;5~" [C-f5])
-  (define-key map "\e[17;5~" [C-f6])
-  (define-key map "\e[18;5~" [C-f7])
-  (define-key map "\e[19;5~" [C-f8])
-  (define-key map "\e[20;5~" [C-f9])
-  (define-key map "\e[21;5~" [C-f10])
-  (define-key map "\e[23;5~" [C-f11])
-  (define-key map "\e[24;5~" [C-f12])
+      (define-key map "\eO5P" [C-f1])
+      (define-key map "\eO5Q" [C-f2])
+      (define-key map "\eO5R" [C-f3])
+      (define-key map "\eO5S" [C-f4])
+      (define-key map "\e[15;5~" [C-f5])
+      (define-key map "\e[17;5~" [C-f6])
+      (define-key map "\e[18;5~" [C-f7])
+      (define-key map "\e[19;5~" [C-f8])
+      (define-key map "\e[20;5~" [C-f9])
+      (define-key map "\e[21;5~" [C-f10])
+      (define-key map "\e[23;5~" [C-f11])
+      (define-key map "\e[24;5~" [C-f12])
 
-  (define-key map "\eO6P" [C-S-f1])
-  (define-key map "\eO6Q" [C-S-f2])
-  (define-key map "\eO6R" [C-S-f3])
-  (define-key map "\eO6S" [C-S-f4])
-  (define-key map "\e[15;6~" [C-S-f5])
-  (define-key map "\e[17;6~" [C-S-f6])
-  (define-key map "\e[18;6~" [C-S-f7])
-  (define-key map "\e[19;6~" [C-S-f8])
-  (define-key map "\e[20;6~" [C-S-f9])
-  (define-key map "\e[21;6~" [C-S-f10])
-  (define-key map "\e[23;6~" [C-S-f11])
-  (define-key map "\e[24;6~" [C-S-f12])
+      (define-key map "\eO6P" [C-S-f1])
+      (define-key map "\eO6Q" [C-S-f2])
+      (define-key map "\eO6R" [C-S-f3])
+      (define-key map "\eO6S" [C-S-f4])
+      (define-key map "\e[15;6~" [C-S-f5])
+      (define-key map "\e[17;6~" [C-S-f6])
+      (define-key map "\e[18;6~" [C-S-f7])
+      (define-key map "\e[19;6~" [C-S-f8])
+      (define-key map "\e[20;6~" [C-S-f9])
+      (define-key map "\e[21;6~" [C-S-f10])
+      (define-key map "\e[23;6~" [C-S-f11])
+      (define-key map "\e[24;6~" [C-S-f12])
 
-  (define-key map "\eO3P" [A-f1])
-  (define-key map "\eO3Q" [A-f2])
-  (define-key map "\eO3R" [A-f3])
-  (define-key map "\eO3S" [A-f4])
-  (define-key map "\e[15;3~" [A-f5])
-  (define-key map "\e[17;3~" [A-f6])
-  (define-key map "\e[18;3~" [A-f7])
-  (define-key map "\e[19;3~" [A-f8])
-  (define-key map "\e[20;3~" [A-f9])
-  (define-key map "\e[21;3~" [A-f10])
-  (define-key map "\e[23;3~" [A-f11])
-  (define-key map "\e[24;3~" [A-f12])
+      (define-key map "\eO3P" [A-f1])
+      (define-key map "\eO3Q" [A-f2])
+      (define-key map "\eO3R" [A-f3])
+      (define-key map "\eO3S" [A-f4])
+      (define-key map "\e[15;3~" [A-f5])
+      (define-key map "\e[17;3~" [A-f6])
+      (define-key map "\e[18;3~" [A-f7])
+      (define-key map "\e[19;3~" [A-f8])
+      (define-key map "\e[20;3~" [A-f9])
+      (define-key map "\e[21;3~" [A-f10])
+      (define-key map "\e[23;3~" [A-f11])
+      (define-key map "\e[24;3~" [A-f12])
 
-  (define-key map "\e[1;2A" [S-up])
-  (define-key map "\e[1;2B" [S-down])
-  (define-key map "\e[1;2C" [S-right])
-  (define-key map "\e[1;2D" [S-left])
-  (define-key map "\e[1;2F" [S-end])
-  (define-key map "\e[1;2H" [S-home])
+      (define-key map "\e[1;2A" [S-up])
+      (define-key map "\e[1;2B" [S-down])
+      (define-key map "\e[1;2C" [S-right])
+      (define-key map "\e[1;2D" [S-left])
+      (define-key map "\e[1;2F" [S-end])
+      (define-key map "\e[1;2H" [S-home])
 
-  (define-key map "\e[1;5A" [C-up])
-  (define-key map "\e[1;5B" [C-down])
-  (define-key map "\e[1;5C" [C-right])
-  (define-key map "\e[1;5D" [C-left])
-  (define-key map "\e[1;5F" [C-end])
-  (define-key map "\e[1;5H" [C-home])
+      (define-key map "\e[1;5A" [C-up])
+      (define-key map "\e[1;5B" [C-down])
+      (define-key map "\e[1;5C" [C-right])
+      (define-key map "\e[1;5D" [C-left])
+      (define-key map "\e[1;5F" [C-end])
+      (define-key map "\e[1;5H" [C-home])
 
-  (define-key map "\e[1;6A" [C-S-up])
-  (define-key map "\e[1;6B" [C-S-down])
-  (define-key map "\e[1;6C" [C-S-right])
-  (define-key map "\e[1;6D" [C-S-left])
-  (define-key map "\e[1;6F" [C-S-end])
-  (define-key map "\e[1;6H" [C-S-home])
+      (define-key map "\e[1;6A" [C-S-up])
+      (define-key map "\e[1;6B" [C-S-down])
+      (define-key map "\e[1;6C" [C-S-right])
+      (define-key map "\e[1;6D" [C-S-left])
+      (define-key map "\e[1;6F" [C-S-end])
+      (define-key map "\e[1;6H" [C-S-home])
 
-  (define-key map "\e[1;3A" [A-up])
-  (define-key map "\e[1;3B" [A-down])
-  (define-key map "\e[1;3C" [A-right])
-  (define-key map "\e[1;3D" [A-left])
-  (define-key map "\e[1;3F" [A-end])
-  (define-key map "\e[1;3H" [A-home])
+      (define-key map "\e[1;3A" [A-up])
+      (define-key map "\e[1;3B" [A-down])
+      (define-key map "\e[1;3C" [A-right])
+      (define-key map "\e[1;3D" [A-left])
+      (define-key map "\e[1;3F" [A-end])
+      (define-key map "\e[1;3H" [A-home])
 
-  (define-key map "\e[2;2~" [S-insert])
-  (define-key map "\e[3;2~" [S-delete])
-  (define-key map "\e[5;2~" [S-prior])
-  (define-key map "\e[6;2~" [S-next])
+      (define-key map "\e[2;2~" [S-insert])
+      (define-key map "\e[3;2~" [S-delete])
+      (define-key map "\e[5;2~" [S-prior])
+      (define-key map "\e[6;2~" [S-next])
 
-  (define-key map "\e[2;5~" [C-insert])
-  (define-key map "\e[3;5~" [C-delete])
-  (define-key map "\e[5;5~" [C-prior])
-  (define-key map "\e[6;5~" [C-next])
+      (define-key map "\e[2;5~" [C-insert])
+      (define-key map "\e[3;5~" [C-delete])
+      (define-key map "\e[5;5~" [C-prior])
+      (define-key map "\e[6;5~" [C-next])
 
-  (define-key map "\e[2;6~" [C-S-insert])
-  (define-key map "\e[3;6~" [C-S-delete])
-  (define-key map "\e[5;6~" [C-S-prior])
-  (define-key map "\e[6;6~" [C-S-next])
+      (define-key map "\e[2;6~" [C-S-insert])
+      (define-key map "\e[3;6~" [C-S-delete])
+      (define-key map "\e[5;6~" [C-S-prior])
+      (define-key map "\e[6;6~" [C-S-next])
 
-  (define-key map "\e[2;3~" [A-insert])
-  (define-key map "\e[3;3~" [A-delete])
-  (define-key map "\e[5;3~" [A-prior])
-  (define-key map "\e[6;3~" [A-next])
+      (define-key map "\e[2;3~" [A-insert])
+      (define-key map "\e[3;3~" [A-delete])
+      (define-key map "\e[5;3~" [A-prior])
+      (define-key map "\e[6;3~" [A-next])
 
-  (define-key map "\eOA" [up])
-  (define-key map "\eOB" [down])
-  (define-key map "\eOC" [right])
-  (define-key map "\eOD" [left])
-  (define-key map "\eOF" [end])
-  (define-key map "\eOH" [home])
+      (define-key map "\eOA" [up])
+      (define-key map "\eOB" [down])
+      (define-key map "\eOC" [right])
+      (define-key map "\eOD" [left])
+      (define-key map "\eOF" [end])
+      (define-key map "\eOH" [home])
 
-  (define-key map "\eO2A" [S-up])
-  (define-key map "\eO2B" [S-down])
-  (define-key map "\eO2C" [S-right])
-  (define-key map "\eO2D" [S-left])
-  (define-key map "\eO2F" [S-end])
-  (define-key map "\eO2H" [S-home])
+      (define-key map "\eO2A" [S-up])
+      (define-key map "\eO2B" [S-down])
+      (define-key map "\eO2C" [S-right])
+      (define-key map "\eO2D" [S-left])
+      (define-key map "\eO2F" [S-end])
+      (define-key map "\eO2H" [S-home])
 
-  (define-key map "\eO5A" [C-up])
-  (define-key map "\eO5B" [C-down])
-  (define-key map "\eO5C" [C-right])
-  (define-key map "\eO5D" [C-left])
-  (define-key map "\eO5F" [C-end])
-  (define-key map "\eO5H" [C-home])
+      (define-key map "\eO5A" [C-up])
+      (define-key map "\eO5B" [C-down])
+      (define-key map "\eO5C" [C-right])
+      (define-key map "\eO5D" [C-left])
+      (define-key map "\eO5F" [C-end])
+      (define-key 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 map (keymap-parent function-key-map))
-  (set-keymap-parent function-key-map map))
+      ;; 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 map (keymap-parent function-key-map))
+      (set-keymap-parent function-key-map map))
+
+    ;; Do it!
+    (xterm-register-default-colors)
+    ;; This recomputes all the default faces given the colors we've just set up.
+    (tty-set-up-initial-frame-faces)))
 
 ;; Set up colors, for those versions of xterm that support it.
 (defvar xterm-standard-colors
@@ -366,11 +375,5 @@
     ;; right colors, so clear them.
     (clear-face-cache)))
 
-;; Do it!
-(xterm-register-default-colors)
-;; This recomputes all the default faces given the colors we've just set up.
-(tty-set-up-initial-frame-faces)
-
-)
 ;; arch-tag: 12e7ebdd-1e6c-4b25-b0f9-35ace25e855a
 ;;; xterm.el ends here