summaryrefslogtreecommitdiff
path: root/lisp/term
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/term')
-rw-r--r--lisp/term/AT386.el56
-rw-r--r--lisp/term/README50
-rw-r--r--lisp/term/apollo.el4
-rw-r--r--lisp/term/bobcat.el2
-rw-r--r--lisp/term/cygwin.el2
-rw-r--r--lisp/term/internal.el28
-rw-r--r--lisp/term/iris-ansi.el390
-rw-r--r--lisp/term/linux.el5
-rw-r--r--lisp/term/lk201.el123
-rw-r--r--lisp/term/mac-win.el197
-rw-r--r--lisp/term/news.el6
-rw-r--r--lisp/term/rxvt.el249
-rw-r--r--lisp/term/sun.el2
-rw-r--r--lisp/term/tvi970.el19
-rw-r--r--lisp/term/vt100.el3
-rw-r--r--lisp/term/vt102.el4
-rw-r--r--lisp/term/vt125.el4
-rw-r--r--lisp/term/vt200.el7
-rw-r--r--lisp/term/vt201.el6
-rw-r--r--lisp/term/vt220.el6
-rw-r--r--lisp/term/vt240.el6
-rw-r--r--lisp/term/vt300.el6
-rw-r--r--lisp/term/vt320.el6
-rw-r--r--lisp/term/vt400.el6
-rw-r--r--lisp/term/vt420.el8
-rw-r--r--lisp/term/w32-win.el294
-rw-r--r--lisp/term/wyse50.el14
-rw-r--r--lisp/term/x-win.el340
-rw-r--r--lisp/term/xterm.el711
29 files changed, 1307 insertions, 1247 deletions
diff --git a/lisp/term/AT386.el b/lisp/term/AT386.el
index 8adb94c07ca..23dfd8e2b11 100644
--- a/lisp/term/AT386.el
+++ b/lisp/term/AT386.el
@@ -29,34 +29,34 @@
;;; Code:
-(if (boundp 'AT386-keypad-map)
- nil
- ;; The terminal initialization should already have set up some keys
- (setq AT386-keypad-map (lookup-key function-key-map "\e["))
- (if (not (keymapp AT386-keypad-map))
- (error "What? Your AT386 termcap/terminfo has no keycaps in it"))
-
- ;; Equivalents of these are set up automatically by termcap/terminfo
- ;; (define-key AT386-keypad-map "A" [up])
- ;; (define-key AT386-keypad-map "B" [down])
- ;; (define-key AT386-keypad-map "C" [right])
- ;; (define-key AT386-keypad-map "D" [left])
-
- ;; These would be set up by terminfo, but not termcap
- (define-key AT386-keypad-map "H" [home])
- (define-key AT386-keypad-map "Y" [end])
- (define-key AT386-keypad-map "U" [next]) ;; PgDn
- (define-key AT386-keypad-map "V" [prior]) ;; PgUp
- (define-key AT386-keypad-map "@" [insert]) ;; Ins key
-
- ;; These are not normally set up by either
- (define-key AT386-keypad-map "G" [kp-5]) ;; Unlabeled center key
- (define-key AT386-keypad-map "S" [kp-subtract])
- (define-key AT386-keypad-map "T" [kp-add])
-
- ;; Arrange for the ALT key to be equivalent to ESC
- (define-key function-key-map "\eN" [27]) ; ALT map
- )
+(defun terminal-init-AT386 ()
+ "Terminal initialization function for AT386."
+ (let ((AT386-keypad-map (lookup-key local-function-key-map "\e[")))
+ ;; The terminal initialization should already have set up some keys
+ (if (not (keymapp AT386-keypad-map))
+ (error "What? Your AT386 termcap/terminfo has no keycaps in it"))
+
+ ;; Equivalents of these are set up automatically by termcap/terminfo
+ ;; (define-key AT386-keypad-map "A" [up])
+ ;; (define-key AT386-keypad-map "B" [down])
+ ;; (define-key AT386-keypad-map "C" [right])
+ ;; (define-key AT386-keypad-map "D" [left])
+
+ ;; These would be set up by terminfo, but not termcap
+ (define-key AT386-keypad-map "H" [home])
+ (define-key AT386-keypad-map "Y" [end])
+ (define-key AT386-keypad-map "U" [next]) ;; PgDn
+ (define-key AT386-keypad-map "V" [prior]) ;; PgUp
+ (define-key AT386-keypad-map "@" [insert]) ;; Ins key
+
+ ;; These are not normally set up by either
+ (define-key AT386-keypad-map "G" [kp-5]) ;; Unlabeled center key
+ (define-key AT386-keypad-map "S" [kp-subtract])
+ (define-key AT386-keypad-map "T" [kp-add])
+
+ ;; Arrange for the ALT key to be equivalent to ESC
+ (define-key local-function-key-map "\eN" [27]) ; ALT map
+ ))
;;; arch-tag: abec1b03-582f-49f8-b8cb-e2fd52ea4bd7
;;; AT386.el ends here
diff --git a/lisp/term/README b/lisp/term/README
index e1cfbf15901..e5fb2da83ad 100644
--- a/lisp/term/README
+++ b/lisp/term/README
@@ -6,19 +6,43 @@ See the end of the file for license conditions.
This directory contains files of elisp that customize Emacs for certain
terminal types.
- When Emacs starts, it checks the TERM environment variable to see what type
-of terminal the user is running on, checks for an elisp file named
-"term/${TERM}.el", and if one exists, loads it. If that doesn't yield a file
-that exists, the last hyphen and what follows it is stripped. If that doesn't
-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'. 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 Emacs opens a new terminal, it checks the TERM environment variable to
+see what type of terminal the user is running on, searches for an elisp file
+named "term/${TERM}.el", and if one exists, loads it. If Emacs finds no
+suitable file, then it strips the last hyphen and what follows it from TERM,
+and tries again. If that still doesn't yield a file, then 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'. Emacs stops searching at the
+first file found, and will not load more than one file for any terminal. Note
+that it is not an error if Emacs is unable to find a terminal initialization
+file; in that case, it will simply proceed with the next step without loading
+any files.
+
+ Once the file has been loaded (or the search failed), Emacs tries to call a
+function named `terminal-init-TERMINALNAME' (eg `terminal-init-aaa-48' for the
+`aaa-48' terminal) in order to initialize the terminal. Once again, if the
+function is not found, Emacs strips the last component of the name and tries
+again using the shorter name. This search is independent of the previous file
+search, so that you can have terminal initialization functions for a family of
+terminals collected in a single file named after the family name, and users
+may put terminal initialization functions directly in their .emacs files.
+
+ Note that an individual terminal file is loaded only once in an Emacs
+session; if the same terminal type is opened again, Emacs will simply call the
+initialization function without reloading the file. Therefore, all the actual
+initialization actions should be collected in terminal-init-* functions; the
+file should not contain any top-level form that is not a function or variable
+declaration. Simply loading the file should not have any side effect.
+
+ Similarly, the terminal initialization function is called only once on any
+given terminal, when the first frame is created on it. The function is not
+called for subsequent frames on the same terminal. Therefore, terminal-init-*
+functions should only modify terminal-local variables (such as
+`local-function-key-map') and terminal parameters. For example, it is not
+correct to modify frame parameters, since the modifications will only be
+applied for the first frame opened on the terminal.
+
When writing terminal packages, there are some things it is good to keep in
mind.
diff --git a/lisp/term/apollo.el b/lisp/term/apollo.el
index 749ff85a0a6..c47de919b0c 100644
--- a/lisp/term/apollo.el
+++ b/lisp/term/apollo.el
@@ -1,7 +1,7 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-apollo ()
- "Terminal initialization function for apollo."
- (load "term/vt100" nil t))
+ "Terminal initialization function for apollo."
+ (tty-run-terminal-initialization (selected-frame) "vt100"))
;;; arch-tag: c72f446f-e6b7-4749-90a4-bd68632adacf
;;; apollo.el ends here
diff --git a/lisp/term/bobcat.el b/lisp/term/bobcat.el
index 82401f7bf71..974476f6798 100644
--- a/lisp/term/bobcat.el
+++ b/lisp/term/bobcat.el
@@ -1,7 +1,7 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-bobcat ()
- "Terminal initialization function for bobcat."
+ "Terminal initialization function for bobcat."
;; HP terminals usually encourage using ^H as the rubout character
(keyboard-translate ?\177 ?\^h)
(keyboard-translate ?\^h ?\177))
diff --git a/lisp/term/cygwin.el b/lisp/term/cygwin.el
index 3bdd5d3aa05..df857ba6625 100644
--- a/lisp/term/cygwin.el
+++ b/lisp/term/cygwin.el
@@ -3,7 +3,7 @@
;;; The Cygwin terminal can't really display underlines.
(defun terminal-init-cygwin ()
- "Terminal initialization function for cygwin."
+ "Terminal initialization function for cygwin."
(tty-no-underline))
;; arch-tag: ca81ce67-3c41-4883-a29b-4c3d64a21191
diff --git a/lisp/term/internal.el b/lisp/term/internal.el
index 2db2cd93d4d..fb13f48d6ba 100644
--- a/lisp/term/internal.el
+++ b/lisp/term/internal.el
@@ -29,20 +29,20 @@
;; ---------------------------------------------------------------------------
;; keyboard setup -- that's simple!
(set-input-mode nil nil 0)
-(define-key function-key-map [backspace] "\177") ; Normal behaviour for BS
-(define-key function-key-map [delete] "\C-d") ; ... and Delete
-(define-key function-key-map [tab] [?\t])
-(define-key function-key-map [linefeed] [?\n])
-(define-key function-key-map [clear] [11])
-(define-key function-key-map [return] [13])
-(define-key function-key-map [escape] [?\e])
-(define-key function-key-map [M-backspace] [?\M-\d])
-(define-key function-key-map [M-delete] [?\M-d])
-(define-key function-key-map [M-tab] [?\M-\t])
-(define-key function-key-map [M-linefeed] [?\M-\n])
-(define-key function-key-map [M-clear] [?\M-\013])
-(define-key function-key-map [M-return] [?\M-\015])
-(define-key function-key-map [M-escape] [?\M-\e])
+(define-key local-function-key-map [backspace] "\177") ; Normal behaviour for BS
+(define-key local-function-key-map [delete] "\C-d") ; ... and Delete
+(define-key local-function-key-map [tab] [?\t])
+(define-key local-function-key-map [linefeed] [?\n])
+(define-key local-function-key-map [clear] [11])
+(define-key local-function-key-map [return] [13])
+(define-key local-function-key-map [escape] [?\e])
+(define-key local-function-key-map [M-backspace] [?\M-\d])
+(define-key local-function-key-map [M-delete] [?\M-d])
+(define-key local-function-key-map [M-tab] [?\M-\t])
+(define-key local-function-key-map [M-linefeed] [?\M-\n])
+(define-key local-function-key-map [M-clear] [?\M-\013])
+(define-key local-function-key-map [M-return] [?\M-\015])
+(define-key local-function-key-map [M-escape] [?\M-\e]))
(put 'backspace 'ascii-character 127)
(put 'delete 'ascii-character 127)
(put 'tab 'ascii-character ?\t)
diff --git a/lisp/term/iris-ansi.el b/lisp/term/iris-ansi.el
index 2f193007051..a941a0399f3 100644
--- a/lisp/term/iris-ansi.el
+++ b/lisp/term/iris-ansi.el
@@ -26,306 +26,314 @@
;;; Code:
-(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])
+(defvar iris-function-map (make-sparse-keymap)
+ "Function key definitions for SGI xwsh and winterm apps.")
+
+(define-key iris-function-map "\e[120q" [S-escape])
+(define-key iris-function-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 iris-function-map "\e[001q" [f1])
+(define-key iris-function-map "\e[013q" [S-f1])
+(define-key iris-function-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 iris-function-map "\e[002q" [f2])
+(define-key iris-function-map "\e[014q" [S-f2])
+(define-key iris-function-map "\e[026q" [C-f2])
+(define-key iris-function-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])
+(define-key iris-function-map "\e[003q" [f3])
+(define-key iris-function-map "\e[015q" [S-f3])
+(define-key iris-function-map "\e[027q" [C-f3])
- (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 iris-function-map "\e[004q" [f4])
+(define-key iris-function-map "\e[016q" [S-f4])
+(define-key iris-function-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 iris-function-map "\e[005q" [f5])
+(define-key iris-function-map "\e[017q" [S-f5])
+(define-key iris-function-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 iris-function-map "\e[006q" [f6])
+(define-key iris-function-map "\e[018q" [S-f6])
+(define-key iris-function-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 iris-function-map "\e[007q" [f7])
+(define-key iris-function-map "\e[019q" [S-f7])
+(define-key iris-function-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 iris-function-map "\e[008q" [f8])
+(define-key iris-function-map "\e[020q" [S-f8])
+(define-key iris-function-map "\e[032q" [C-f8])
- (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 iris-function-map "\e[009q" [f9])
+(define-key iris-function-map "\e[021q" [S-f9])
+(define-key iris-function-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 iris-function-map "\e[010q" [f10])
+(define-key iris-function-map "\e[022q" [S-f10])
+(define-key iris-function-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 iris-function-map "\e[011q" [f11])
+(define-key iris-function-map "\e[023q" [S-f11])
+(define-key iris-function-map "\e[035q" [C-f11])
+(define-key iris-function-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 iris-function-map "\e[012q" [f12])
+(define-key iris-function-map "\e[024q" [S-f12])
+(define-key iris-function-map "\e[036q" [C-f12])
+(define-key iris-function-map "\e[048q" [M-f12])
- (define-key function-key-map "\e[057q" [?\C-`])
- (define-key function-key-map "\e[115q" [?\M-`])
+(define-key iris-function-map "\e[057q" [?\C-`])
+(define-key iris-function-map "\e[115q" [?\M-`])
- (define-key function-key-map "\e[049q" [?\C-1])
- (define-key function-key-map "\e[058q" [?\M-1])
+(define-key iris-function-map "\e[049q" [?\C-1])
+(define-key iris-function-map "\e[058q" [?\M-1])
- (define-key function-key-map "\e[059q" [?\M-2])
+(define-key iris-function-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 iris-function-map "\e[050q" [?\C-3])
+(define-key iris-function-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 iris-function-map "\e[051q" [?\C-4])
+(define-key iris-function-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 iris-function-map "\e[052q" [?\C-5])
+(define-key iris-function-map "\e[062q" [?\M-5])
- (define-key function-key-map "\e[063q" [?\M-6])
+(define-key iris-function-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 iris-function-map "\e[053q" [?\C-7])
+(define-key iris-function-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 iris-function-map "\e[054q" [?\C-8])
+(define-key iris-function-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 iris-function-map "\e[055q" [?\C-9])
+(define-key iris-function-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 iris-function-map "\e[056q" [?\C-0])
+(define-key iris-function-map "\e[067q" [?\M-0])
- (define-key function-key-map "\e[068q" [?\M--])
+(define-key iris-function-map "\e[068q" [?\M--])
- (define-key function-key-map "\e[069q" [?\C-=])
- (define-key function-key-map "\e[070q" [?\M-=])
+(define-key iris-function-map "\e[069q" [?\C-=])
+(define-key iris-function-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>])
+;; I don't know what to do with those.
+;;(define-key iris-function-map "^H" [<del>])
+;;(define-key iris-function-map "^H" [S-<del>])
+;;(define-key iris-function-map "\177" [C-<del>])
+;;(define-key iris-function-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 iris-function-map "\e[Z" [?\S-\t])
+(define-key iris-function-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 iris-function-map "\e[073q" [?\M-\t])
- (define-key function-key-map "\e[074q" [?\M-q])
+(define-key iris-function-map "\e[074q" [?\M-q])
- (define-key function-key-map "\e[075q" [?\M-w])
+(define-key iris-function-map "\e[075q" [?\M-w])
- (define-key function-key-map "\e[076q" [?\M-e])
+(define-key iris-function-map "\e[076q" [?\M-e])
- (define-key function-key-map "\e[077q" [?\M-r])
+(define-key iris-function-map "\e[077q" [?\M-r])
- (define-key function-key-map "\e[078q" [?\M-t])
+(define-key iris-function-map "\e[078q" [?\M-t])
- (define-key function-key-map "\e[079q" [?\M-y])
+(define-key iris-function-map "\e[079q" [?\M-y])
- (define-key function-key-map "\e[080q" [?\M-u])
+(define-key iris-function-map "\e[080q" [?\M-u])
- (define-key function-key-map "\e[081q" [?\M-i])
+(define-key iris-function-map "\e[081q" [?\M-i])
- (define-key function-key-map "\e[082q" [?\M-o])
+(define-key iris-function-map "\e[082q" [?\M-o])
- (define-key function-key-map "\e[083q" [?\M-p])
+(define-key iris-function-map "\e[083q" [?\M-p])
- (define-key function-key-map "\e[084q" [?\M-\[])
+(define-key iris-function-map "\e[084q" [?\M-\[])
- (define-key function-key-map "\e[085q" [?\M-\]])
+(define-key iris-function-map "\e[085q" [?\M-\]])
- (define-key function-key-map "\e[086q" [?\M-\\])
+(define-key iris-function-map "\e[086q" [?\M-\\])
- (define-key function-key-map "\e[087q" [?\M-a])
+(define-key iris-function-map "\e[087q" [?\M-a])
- (define-key function-key-map "\e[088q" [?\M-s])
+(define-key iris-function-map "\e[088q" [?\M-s])
- (define-key function-key-map "\e[089q" [?\M-d])
+(define-key iris-function-map "\e[089q" [?\M-d])
- (define-key function-key-map "\e[090q" [?\M-f])
+(define-key iris-function-map "\e[090q" [?\M-f])
- (define-key function-key-map "\e[091q" [?\M-g])
+(define-key iris-function-map "\e[091q" [?\M-g])
- (define-key function-key-map "\e[092q" [?\M-h])
+(define-key iris-function-map "\e[092q" [?\M-h])
- (define-key function-key-map "\e[093q" [?\M-j])
+(define-key iris-function-map "\e[093q" [?\M-j])
- (define-key function-key-map "\e[094q" [?\M-k])
+(define-key iris-function-map "\e[094q" [?\M-k])
- (define-key function-key-map "\e[095q" [?\M-l])
+(define-key iris-function-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 iris-function-map "\e[096q" [?\C-\;])
+(define-key iris-function-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 iris-function-map "\e[098q" [?\C-'])
+(define-key iris-function-map "\e[099q" [?\M-'])
- (define-key function-key-map "\e[100q" [?\M-\n])
+(define-key iris-function-map "\e[100q" [?\M-\n])
- (define-key function-key-map "\e[101q" [?\M-z])
+(define-key iris-function-map "\e[101q" [?\M-z])
- (define-key function-key-map "\e[102q" [?\M-x])
+(define-key iris-function-map "\e[102q" [?\M-x])
- (define-key function-key-map "\e[103q" [?\M-c])
+(define-key iris-function-map "\e[103q" [?\M-c])
- (define-key function-key-map "\e[104q" [?\M-v])
+(define-key iris-function-map "\e[104q" [?\M-v])
- (define-key function-key-map "\e[105q" [?\M-b])
+(define-key iris-function-map "\e[105q" [?\M-b])
- (define-key function-key-map "\e[106q" [M-n])
+(define-key iris-function-map "\e[106q" [M-n])
- (define-key function-key-map "\e[107q" [M-m])
+(define-key iris-function-map "\e[107q" [M-m])
- (define-key function-key-map "\e[108q" [?\C-,])
- (define-key function-key-map "\e[109q" [?\M-,])
+(define-key iris-function-map "\e[108q" [?\C-,])
+(define-key iris-function-map "\e[109q" [?\M-,])
- (define-key function-key-map "\e[110q" [?\C-.])
- (define-key function-key-map "\e[111q" [?\M-.])
+(define-key iris-function-map "\e[110q" [?\C-.])
+(define-key iris-function-map "\e[111q" [?\M-.])
- (define-key function-key-map "\e[112q" [?\C-/])
- (define-key function-key-map "\e[113q" [?\M-/])
+(define-key iris-function-map "\e[112q" [?\C-/])
+(define-key iris-function-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 iris-function-map "\e[139q" [insert])
+(define-key iris-function-map "\e[139q" [S-insert])
+(define-key iris-function-map "\e[140q" [C-insert])
+(define-key iris-function-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 iris-function-map "\e[H" [home])
+(define-key iris-function-map "\e[143q" [S-home])
+(define-key iris-function-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 to
- ;; generate
+(define-key iris-function-map "\e[150q" [prior])
+(define-key iris-function-map "\e[151q" [S-prior]) ;; those don't seem
+ ;; to generate
;; anything
- (define-key function-key-map "\e[152q" [C-prior])
+(define-key iris-function-map "\e[152q" [C-prior])
- ;; (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 iris-function-map "^?" [delete]) ?? something else seems to take care of this.
+(define-key iris-function-map "\e[P" [S-delete])
+(define-key iris-function-map "\e[142q" [C-delete])
+(define-key iris-function-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 iris-function-map "\e[146q" [end])
+(define-key iris-function-map "\e[147q" [S-end]) ;; those don't seem to
+ ;; generate anything
+(define-key iris-function-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 iris-function-map "\e[154q" [next])
+(define-key iris-function-map "\e[155q" [S-next])
+(define-key iris-function-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 iris-function-map "\e[161q" [S-up])
+(define-key iris-function-map "\e[162q" [C-up])
+(define-key iris-function-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 iris-function-map "\e[158q" [S-left])
+(define-key iris-function-map "\e[159q" [C-left])
+(define-key iris-function-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 iris-function-map "\e[164q" [S-down])
+(define-key iris-function-map "\e[165q" [C-down])
+(define-key iris-function-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])
+(define-key iris-function-map "\e[167q" [S-right])
+(define-key iris-function-map "\e[168q" [C-right])
+(define-key iris-function-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-/])
+;; Keypad functions, most of those are untested.
+(define-key iris-function-map "\e[179q" [?\C-/])
+(define-key iris-function-map "\e[180q" [?\M-/])
- (define-key function-key-map "\e[187q" [?\C-*])
- (define-key function-key-map "\e[188q" [?\M-*])
+(define-key iris-function-map "\e[187q" [?\C-*])
+(define-key iris-function-map "\e[188q" [?\M-*])
- (define-key function-key-map "\e[198q" [?\C--])
- (define-key function-key-map "\e[199q" [?\M--])
+(define-key iris-function-map "\e[198q" [?\C--])
+(define-key iris-function-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])
+;; Something else takes care of home, up, prior, down, left, right, next
+;(define-key iris-function-map "\e[H" [home])
+(define-key iris-function-map "\e[172q" [C-home])
- ;;(define-key function-key-map "\e[A" [up])
- (define-key function-key-map "\e[182q" [C-up])
+;(define-key iris-function-map "\e[A" [up])
+(define-key iris-function-map "\e[182q" [C-up])
- ;;(define-key function-key-map "\e[150q" [prior])
- (define-key function-key-map "\e[190q" [C-prior])
+;(define-key iris-function-map "\e[150q" [prior])
+(define-key iris-function-map "\e[190q" [C-prior])
- (define-key function-key-map "\e[200q" [?\C-+])
- (define-key function-key-map "\e[201q" [?\M-+])
+(define-key iris-function-map "\e[200q" [?\C-+])
+(define-key iris-function-map "\e[201q" [?\M-+])
- ;;(define-key function-key-map "\e[D" [left])
- (define-key function-key-map "\e[174q" [C-left])
+;(define-key iris-function-map "\e[D" [left])
+(define-key iris-function-map "\e[174q" [C-left])
- (define-key function-key-map "\e[000q" [begin])
- (define-key function-key-map "\e[184q" [C-begin])
+(define-key iris-function-map "\e[000q" [begin])
+(define-key iris-function-map "\e[184q" [C-begin])
- ;;(define-key function-key-map "\e[C" [right])
- (define-key function-key-map "\e[192q" [C-right])
+;(define-key iris-function-map "\e[C" [right])
+(define-key iris-function-map "\e[192q" [C-right])
- ;;(define-key function-key-map "\e[146q" [end])
- (define-key function-key-map "\e[176q" [C-end])
+;(define-key iris-function-map "\e[146q" [end])
+(define-key iris-function-map "\e[176q" [C-end])
- ;;(define-key function-key-map "\e[B" [down])
- (define-key function-key-map "\e[186q" [C-down])
+;(define-key iris-function-map "\e[B" [down])
+(define-key iris-function-map "\e[186q" [C-down])
- ;;(define-key function-key-map "\e[154q" [next])
- (define-key function-key-map "\e[194q" [C-next])
+;(define-key iris-function-map "\e[154q" [next])
+(define-key iris-function-map "\e[194q" [C-next])
- (define-key function-key-map "\e[100q" [M-enter])
+(define-key iris-function-map "\e[100q" [M-enter])
- (define-key function-key-map "\e[139q" [insert])
- (define-key function-key-map "\e[178q" [C-inset])
+(define-key iris-function-map "\e[139q" [insert])
+(define-key iris-function-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 iris-function-map "\e[P" [delete])
+(define-key iris-function-map "\e[196q" [C-delete])
+(define-key iris-function-map "\e[197q" [M-delete])
+
+(defun terminal-init-iris-ansi ()
+ "Terminal initialization function for iris-ansi."
+ ;; Use inheritance to let the main keymap override these defaults.
+ ;; This way we don't override terminfo-derived settings or settings
+ ;; made in the .emacs file.
+ (let ((m (copy-keymap iris-function-map)))
+ (set-keymap-parent m (keymap-parent local-function-key-map))
+ (set-keymap-parent local-function-key-map m)))
;;; arch-tag: b1d0e73a-bb7d-47be-9fb2-6fb126469a1b
;;; iris-ansi.el ends here
diff --git a/lisp/term/linux.el b/lisp/term/linux.el
index 84de5966a88..fdd8e2229ac 100644
--- a/lisp/term/linux.el
+++ b/lisp/term/linux.el
@@ -16,9 +16,8 @@
;; 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))))
+ ;; The arg only matters in that it is not t or nil.
+ (set-input-meta-mode 'iso-latin-1))
;;; arch-tag: 5d0c4f63-739b-4862-abf3-041fe42adb8f
;;; linux.el ends here
diff --git a/lisp/term/lk201.el b/lisp/term/lk201.el
index 1f8d9ca77a3..17ac3474ff0 100644
--- a/lisp/term/lk201.el
+++ b/lisp/term/lk201.el
@@ -1,72 +1,83 @@
;; -*- no-byte-compile: t -*-
;; Define function key sequences for DEC terminals.
+(defvar lk201-function-map (make-sparse-keymap)
+ "Function key definitions for DEC terminals.")
+
;; Termcap or terminfo should set these.
-;; (define-key function-key-map "\e[A" [up])
-;; (define-key function-key-map "\e[B" [down])
-;; (define-key function-key-map "\e[C" [right])
-;; (define-key function-key-map "\e[D" [left])
+;; (define-key lk201-function-map "\e[A" [up])
+;; (define-key lk201-function-map "\e[B" [down])
+;; (define-key lk201-function-map "\e[C" [right])
+;; (define-key lk201-function-map "\e[D" [left])
-(define-key function-key-map "\e[1~" [find])
-(define-key function-key-map "\e[2~" [insert])
-(define-key function-key-map "\e[3~" [delete])
-(define-key function-key-map "\e[4~" [select])
-(define-key function-key-map "\e[5~" [prior])
-(define-key function-key-map "\e[6~" [next])
-(define-key function-key-map "\e[11~" [f1])
-(define-key function-key-map "\e[12~" [f2])
-(define-key function-key-map "\e[13~" [f3])
-(define-key function-key-map "\e[14~" [f4])
-(define-key function-key-map "\e[15~" [f5])
-(define-key function-key-map "\e[17~" [f6])
-(define-key function-key-map "\e[18~" [f7])
-(define-key function-key-map "\e[19~" [f8])
-(define-key function-key-map "\e[20~" [f9])
-(define-key function-key-map "\e[21~" [f10])
+(define-key lk201-function-map "\e[1~" [find])
+(define-key lk201-function-map "\e[2~" [insert])
+(define-key lk201-function-map "\e[3~" [delete])
+(define-key lk201-function-map "\e[4~" [select])
+(define-key lk201-function-map "\e[5~" [prior])
+(define-key lk201-function-map "\e[6~" [next])
+(define-key lk201-function-map "\e[11~" [f1])
+(define-key lk201-function-map "\e[12~" [f2])
+(define-key lk201-function-map "\e[13~" [f3])
+(define-key lk201-function-map "\e[14~" [f4])
+(define-key lk201-function-map "\e[15~" [f5])
+(define-key lk201-function-map "\e[17~" [f6])
+(define-key lk201-function-map "\e[18~" [f7])
+(define-key lk201-function-map "\e[19~" [f8])
+(define-key lk201-function-map "\e[20~" [f9])
+(define-key lk201-function-map "\e[21~" [f10])
;; Customarily F11 is used as the ESC key.
;; The file that includes this one, takes care of that.
-(define-key function-key-map "\e[23~" [f11])
-(define-key function-key-map "\e[24~" [f12])
-(define-key function-key-map "\e[25~" [f13])
-(define-key function-key-map "\e[26~" [f14])
-(define-key function-key-map "\e[28~" [help])
-(define-key function-key-map "\e[29~" [menu])
-(define-key function-key-map "\e[31~" [f17])
-(define-key function-key-map "\e[32~" [f18])
-(define-key function-key-map "\e[33~" [f19])
-(define-key function-key-map "\e[34~" [f20])
+(define-key lk201-function-map "\e[23~" [f11])
+(define-key lk201-function-map "\e[24~" [f12])
+(define-key lk201-function-map "\e[25~" [f13])
+(define-key lk201-function-map "\e[26~" [f14])
+(define-key lk201-function-map "\e[28~" [help])
+(define-key lk201-function-map "\e[29~" [menu])
+(define-key lk201-function-map "\e[31~" [f17])
+(define-key lk201-function-map "\e[32~" [f18])
+(define-key lk201-function-map "\e[33~" [f19])
+(define-key lk201-function-map "\e[34~" [f20])
;; Termcap or terminfo should set these.
-;; (define-key function-key-map "\eOA" [up])
-;; (define-key function-key-map "\eOB" [down])
-;; (define-key function-key-map "\eOC" [right])
-;; (define-key function-key-map "\eOD" [left])
+;; (define-key lk201-function-map "\eOA" [up])
+;; (define-key lk201-function-map "\eOB" [down])
+;; (define-key lk201-function-map "\eOC" [right])
+;; (define-key lk201-function-map "\eOD" [left])
;; Termcap or terminfo should set these, but doesn't properly.
;; Termcap sets these to k1-k4, which get mapped to f1-f4 in term.c
-(define-key function-key-map "\eOP" [kp-f1])
-(define-key function-key-map "\eOQ" [kp-f2])
-(define-key function-key-map "\eOR" [kp-f3])
-(define-key function-key-map "\eOS" [kp-f4])
+(define-key lk201-function-map "\eOP" [kp-f1])
+(define-key lk201-function-map "\eOQ" [kp-f2])
+(define-key lk201-function-map "\eOR" [kp-f3])
+(define-key lk201-function-map "\eOS" [kp-f4])
+
+(define-key lk201-function-map "\eOI" [kp-tab])
+(define-key lk201-function-map "\eOj" [kp-multiply])
+(define-key lk201-function-map "\eOk" [kp-add])
+(define-key lk201-function-map "\eOl" [kp-separator])
+(define-key lk201-function-map "\eOM" [kp-enter])
+(define-key lk201-function-map "\eOm" [kp-subtract])
+(define-key lk201-function-map "\eOn" [kp-decimal])
+(define-key lk201-function-map "\eOo" [kp-divide])
+(define-key lk201-function-map "\eOp" [kp-0])
+(define-key lk201-function-map "\eOq" [kp-1])
+(define-key lk201-function-map "\eOr" [kp-2])
+(define-key lk201-function-map "\eOs" [kp-3])
+(define-key lk201-function-map "\eOt" [kp-4])
+(define-key lk201-function-map "\eOu" [kp-5])
+(define-key lk201-function-map "\eOv" [kp-6])
+(define-key lk201-function-map "\eOw" [kp-7])
+(define-key lk201-function-map "\eOx" [kp-8])
+(define-key lk201-function-map "\eOy" [kp-9])
-(define-key function-key-map "\eOI" [kp-tab])
-(define-key function-key-map "\eOj" [kp-multiply])
-(define-key function-key-map "\eOk" [kp-add])
-(define-key function-key-map "\eOl" [kp-separator])
-(define-key function-key-map "\eOM" [kp-enter])
-(define-key function-key-map "\eOm" [kp-subtract])
-(define-key function-key-map "\eOn" [kp-decimal])
-(define-key function-key-map "\eOo" [kp-divide])
-(define-key function-key-map "\eOp" [kp-0])
-(define-key function-key-map "\eOq" [kp-1])
-(define-key function-key-map "\eOr" [kp-2])
-(define-key function-key-map "\eOs" [kp-3])
-(define-key function-key-map "\eOt" [kp-4])
-(define-key function-key-map "\eOu" [kp-5])
-(define-key function-key-map "\eOv" [kp-6])
-(define-key function-key-map "\eOw" [kp-7])
-(define-key function-key-map "\eOx" [kp-8])
-(define-key function-key-map "\eOy" [kp-9])
+(defun terminal-init-lk201 ()
+ ;; Use inheritance to let the main keymap override these defaults.
+ ;; This way we don't override terminfo-derived settings or settings
+ ;; made in the .emacs file.
+ (let ((m (copy-keymap lk201-function-map)))
+ (set-keymap-parent m (keymap-parent local-function-key-map))
+ (set-keymap-parent local-function-key-map m)))
;;; arch-tag: 7ffb4444-6a23-43e1-b457-43cf4f673c0d
;;; lk201.el ends here
diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el
index e39e1fffeb0..d20ecc161aa 100644
--- a/lisp/term/mac-win.el
+++ b/lisp/term/mac-win.el
@@ -65,8 +65,8 @@
;; An alist of X options and the function which handles them. See
;; ../startup.el.
-(if (not (eq window-system 'mac))
- (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
+;; (if (not (eq window-system 'mac))
+;; (error "%s: Loading mac-win.el but not compiled for Mac" (invocation-name)))
(require 'frame)
(require 'mouse)
@@ -1062,22 +1062,25 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
global-map)
+(defun x-setup-function-keys (frame)
+ "Setup Function Keys for mac."
;; Map certain keypad keys into ASCII characters
;; that people usually expect.
-(define-key function-key-map [backspace] [?\d])
-(define-key function-key-map [delete] [?\d])
-(define-key function-key-map [tab] [?\t])
-(define-key function-key-map [linefeed] [?\n])
-(define-key function-key-map [clear] [?\C-l])
-(define-key function-key-map [return] [?\C-m])
-(define-key function-key-map [escape] [?\e])
-(define-key function-key-map [M-backspace] [?\M-\d])
-(define-key function-key-map [M-delete] [?\M-\d])
-(define-key function-key-map [M-tab] [?\M-\t])
-(define-key function-key-map [M-linefeed] [?\M-\n])
-(define-key function-key-map [M-clear] [?\M-\C-l])
-(define-key function-key-map [M-return] [?\M-\C-m])
-(define-key function-key-map [M-escape] [?\M-\e])
+(define-key local-function-key-map [backspace] [?\d])
+(define-key local-function-key-map [delete] [?\d])
+(define-key local-function-key-map [tab] [?\t])
+(define-key local-function-key-map [linefeed] [?\n])
+(define-key local-function-key-map [clear] [?\C-l])
+(define-key local-function-key-map [return] [?\C-m])
+(define-key local-function-key-map [escape] [?\e])
+(define-key local-function-key-map [M-backspace] [?\M-\d])
+(define-key local-function-key-map [M-delete] [?\M-\d])
+(define-key local-function-key-map [M-tab] [?\M-\t])
+(define-key local-function-key-map [M-linefeed] [?\M-\n])
+(define-key local-function-key-map [M-clear] [?\M-\C-l])
+(define-key local-function-key-map [M-return] [?\M-\C-m])
+(define-key local-function-key-map [M-escape] [?\M-\e])
+)
;; These tell read-char how to convert
;; these special chars to ASCII.
@@ -2294,34 +2297,6 @@ See also `mac-dnd-known-types'."
(mac-dnd-drop-data event (selected-frame) window
(cdr item) (car item) action)))))
-;;; Do the actual Windows setup here; the above code just defines
-;;; functions and variables that we use now.
-
-(setq command-line-args (x-handle-args command-line-args))
-
-;;; Make sure we have a valid resource name.
-(or (stringp x-resource-name)
- (let (i)
- (setq x-resource-name (invocation-name))
-
- ;; Change any . or * characters in x-resource-name to hyphens,
- ;; so as not to choke when we use it in X resource queries.
- (while (setq i (string-match "[.*]" x-resource-name))
- (aset x-resource-name i ?-))))
-
-(if (x-display-list)
- ;; On Mac OS 8/9, Most coding systems used in code conversion for
- ;; font names are not ready at the time when the terminal frame is
- ;; created. So we reconstruct font name table for the initial
- ;; frame.
- (mac-clear-font-name-table)
- (x-open-connection "Mac"
- x-command-line-resources
- ;; Exit Emacs with fatal error if this fails.
- t))
-
-(setq frame-creation-function 'x-create-frame-with-faces)
-
(defvar mac-font-encoder-list
'(("mac-roman" mac-roman-encoder
ccl-encode-mac-roman-font "%s")
@@ -2499,6 +2474,88 @@ It returns a name of the created fontset."
(fontset-add-mac-fonts fontset t)
fontset))
+(defun x-win-suspend-error ()
+ (error "Suspending an Emacs running under Mac makes no sense"))
+
+(defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
+
+(defvar mac-initialized nil
+ "Non-nil if the w32 window system has been initialized.")
+
+(defun mac-initialize-window-system ()
+ "Initialize Emacs for Mac GUI frames."
+
+;;; Do the actual Windows setup here; the above code just defines
+;;; functions and variables that we use now.
+
+(setq command-line-args (x-handle-args command-line-args))
+
+;;; Make sure we have a valid resource name.
+(or (stringp x-resource-name)
+ (let (i)
+ (setq x-resource-name (invocation-name))
+
+ ;; Change any . or * characters in x-resource-name to hyphens,
+ ;; so as not to choke when we use it in X resource queries.
+ (while (setq i (string-match "[.*]" x-resource-name))
+ (aset x-resource-name i ?-))))
+
+(if (x-display-list)
+ ;; On Mac OS 8/9, Most coding systems used in code conversion for
+ ;; font names are not ready at the time when the terminal frame is
+ ;; created. So we reconstruct font name table for the initial
+ ;; frame.
+ (mac-clear-font-name-table)
+ (x-open-connection "Mac"
+ x-command-line-resources
+ ;; Exit Emacs with fatal error if this fails.
+ t))
+
+(add-hook 'suspend-hook 'x-win-suspend-error)
+
+;;; Arrange for the kill and yank functions to set and check the clipboard.
+(setq interprogram-cut-function 'x-select-text)
+(setq interprogram-paste-function 'x-get-selection-value)
+
+
+
+
+;;; Turn off window-splitting optimization; Mac is usually fast enough
+;;; that this is only annoying.
+(setq split-window-keep-point t)
+
+;; Don't show the frame name; that's redundant.
+(setq-default mode-line-frame-identification " ")
+
+;; Turn on support for mouse wheels.
+(mouse-wheel-mode 1)
+
+
+;; Enable CLIPBOARD copy/paste through menu bar commands.
+(menu-bar-enable-clipboard)
+
+
+;; Initiate drag and drop
+
+(define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
+
+
+;;;; Non-toolkit Scroll bars
+
+(unless x-toolkit-scroll-bars
+
+;; for debugging
+;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
+
+;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
+
+(global-set-key
+ [vertical-scroll-bar down-mouse-1]
+ 'mac-handle-scroll-bar-event)
+
+(global-unset-key [vertical-scroll-bar drag-mouse-1])
+(global-unset-key [vertical-scroll-bar mouse-1])
+
;; Adjust Courier font specifications in x-fixed-font-alist.
(let ((courier-fonts (assoc "Courier" x-fixed-font-alist)))
(if courier-fonts
@@ -2605,50 +2662,7 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
(setq default-frame-alist
(cons '(reverse . t) default-frame-alist)))))
-(defun x-win-suspend-error ()
- (error "Suspending an Emacs running under Mac makes no sense"))
-(add-hook 'suspend-hook 'x-win-suspend-error)
-
-;;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
-(setq interprogram-paste-function 'x-get-selection-value)
-
-(defalias 'x-cut-buffer-or-selection-value 'x-get-selection-value)
-
-;;; Turn off window-splitting optimization; Mac is usually fast enough
-;;; that this is only annoying.
-(setq split-window-keep-point t)
-
-;; Don't show the frame name; that's redundant.
-(setq-default mode-line-frame-identification " ")
-
-;; Turn on support for mouse wheels.
-(mouse-wheel-mode 1)
-
-
-;; Enable CLIPBOARD copy/paste through menu bar commands.
-(menu-bar-enable-clipboard)
-
-;; Initiate drag and drop
-
-(define-key special-event-map [drag-n-drop] 'mac-dnd-handle-drag-n-drop-event)
-
-
-;;;; Non-toolkit Scroll bars
-
-(unless x-toolkit-scroll-bars
-
-;; for debugging
-;; (defun mac-handle-scroll-bar-event (event) (interactive "e") (princ event))
-
-;;(global-set-key [vertical-scroll-bar mouse-1] 'mac-handle-scroll-bar-event)
-
-(global-set-key
- [vertical-scroll-bar down-mouse-1]
- 'mac-handle-scroll-bar-event)
-
-(global-unset-key [vertical-scroll-bar drag-mouse-1])
-(global-unset-key [vertical-scroll-bar mouse-1])
+(setq mac-initialized t)))
(defun mac-handle-scroll-bar-event (event)
"Handle scroll bar EVENT to emulate Mac Toolbox style scrolling."
@@ -2696,7 +2710,6 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
(mac-scroll-ignore-events)
(scroll-up 1)))
-)
;;;; Others
@@ -2734,5 +2747,11 @@ ascii:-*-Monaco-*-*-*-*-12-*-*-*-*-*-mac-roman")
;; or bold bitmap versions will not display these variants correctly.
(setq scalable-fonts-allowed t)
+(add-to-list 'handle-args-function-alist '(mac . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(mac . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(mac . mac-initialize-window-system))
+
+(provide 'mac-win)
+
;; arch-tag: 71dfcd14-cde8-4d66-b05c-85ec94fb23a6
;;; mac-win.el ends here
diff --git a/lisp/term/news.el b/lisp/term/news.el
index 57d8fd6cb14..514f363314d 100644
--- a/lisp/term/news.el
+++ b/lisp/term/news.el
@@ -31,10 +31,8 @@
(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"))
+ ;; The terminal initialization should already have set up some keys
+ (let ((news-fkey-prefix (lookup-key local-function-key-map "\eO")))
(if (not (keymapp news-fkey-prefix))
(error "What? Your news termcap/terminfo has no keycaps in it"))
diff --git a/lisp/term/rxvt.el b/lisp/term/rxvt.el
index 64c09e0e1bd..d0411161773 100644
--- a/lisp/term/rxvt.el
+++ b/lisp/term/rxvt.el
@@ -26,8 +26,95 @@
;;; Code:
+(defvar rxvt-function-map (make-sparse-keymap)
+ "Function key overrides for rxvt.")
+
+;; Set up function-key-map entries that termcap and terminfo don't know.
+(define-key rxvt-function-map "\e[A" [up])
+(define-key rxvt-function-map "\e[B" [down])
+(define-key rxvt-function-map "\e[C" [right])
+(define-key rxvt-function-map "\e[D" [left])
+(define-key rxvt-function-map "\e[2~" [insert])
+(define-key rxvt-function-map "\e[3~" [delete])
+(define-key rxvt-function-map "\e[4~" [select])
+(define-key rxvt-function-map "\e[5~" [prior])
+(define-key rxvt-function-map "\e[6~" [next])
+(define-key rxvt-function-map "\e[7~" [home])
+(define-key rxvt-function-map "\e[8~" [end])
+(define-key rxvt-function-map "\e[11~" [f1])
+(define-key rxvt-function-map "\e[12~" [f2])
+(define-key rxvt-function-map "\e[13~" [f3])
+(define-key rxvt-function-map "\e[14~" [f4])
+(define-key rxvt-function-map "\e[15~" [f5])
+(define-key rxvt-function-map "\e[17~" [f6])
+(define-key rxvt-function-map "\e[18~" [f7])
+(define-key rxvt-function-map "\e[19~" [f8])
+(define-key rxvt-function-map "\e[20~" [f9])
+(define-key rxvt-function-map "\e[21~" [f10])
+;; 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 rxvt-function-map "\e[23~" [f11])
+;; (define-key rxvt-function-map "\e[24~" [f12])
+(define-key rxvt-function-map "\e[29~" [print])
+
+(define-key rxvt-function-map "\e[11^" [C-f1])
+(define-key rxvt-function-map "\e[12^" [C-f2])
+(define-key rxvt-function-map "\e[13^" [C-f3])
+(define-key rxvt-function-map "\e[14^" [C-f4])
+(define-key rxvt-function-map "\e[15^" [C-f5])
+(define-key rxvt-function-map "\e[17^" [C-f6])
+(define-key rxvt-function-map "\e[18^" [C-f7])
+(define-key rxvt-function-map "\e[19^" [C-f8])
+(define-key rxvt-function-map "\e[20^" [C-f9])
+(define-key rxvt-function-map "\e[21^" [C-f10])
+
+(define-key rxvt-function-map "\e[23~" [S-f1])
+(define-key rxvt-function-map "\e[24~" [S-f2])
+(define-key rxvt-function-map "\e[25~" [S-f3])
+(define-key rxvt-function-map "\e[26~" [S-f4])
+(define-key rxvt-function-map "\e[28~" [S-f5])
+(define-key rxvt-function-map "\e[29~" [S-f6])
+(define-key rxvt-function-map "\e[31~" [S-f7])
+(define-key rxvt-function-map "\e[32~" [S-f8])
+(define-key rxvt-function-map "\e[33~" [S-f9])
+(define-key rxvt-function-map "\e[34~" [S-f10])
+
+(define-key rxvt-function-map "\e[23^" [C-S-f1])
+(define-key rxvt-function-map "\e[24^" [C-S-f2])
+(define-key rxvt-function-map "\e[25^" [C-S-f3])
+(define-key rxvt-function-map "\e[26^" [C-S-f4])
+(define-key rxvt-function-map "\e[28^" [C-S-f5])
+(define-key rxvt-function-map "\e[29^" [C-S-f6])
+(define-key rxvt-function-map "\e[31^" [C-S-f7])
+(define-key rxvt-function-map "\e[32^" [C-S-f8])
+(define-key rxvt-function-map "\e[33^" [C-S-f9])
+(define-key rxvt-function-map "\e[34^" [C-S-f10])
+
+(define-key rxvt-function-map "\e[2^" [C-insert])
+(define-key rxvt-function-map "\e[3^" [C-delete])
+(define-key rxvt-function-map "\e[5^" [C-prior])
+(define-key rxvt-function-map "\e[6^" [C-next])
+(define-key rxvt-function-map "\e[7^" [C-home])
+(define-key rxvt-function-map "\e[8^" [C-end])
+(define-key rxvt-function-map "\eOd" [C-left])
+(define-key rxvt-function-map "\eOc" [C-right])
+(define-key rxvt-function-map "\eOa" [C-up])
+(define-key rxvt-function-map "\eOb" [C-down])
+
+(define-key rxvt-function-map "\e[2;2~" [S-insert])
+(define-key rxvt-function-map "\e[3$" [S-delete])
+(define-key rxvt-function-map "\e[5$" [S-prior])
+(define-key rxvt-function-map "\e[6$" [S-next])
+(define-key rxvt-function-map "\e[7$" [S-home])
+(define-key rxvt-function-map "\e[8$" [S-end])
+(define-key rxvt-function-map "\e[d" [S-left])
+(define-key rxvt-function-map "\e[c" [S-right])
+(define-key rxvt-function-map "\e[a" [S-up])
+(define-key rxvt-function-map "\e[b" [S-down])
+
(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
@@ -36,128 +123,45 @@
;; 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 [f11] [S-f1] local-function-key-map)
+ (substitute-key-definition [f12] [S-f2] local-function-key-map)
+ (substitute-key-definition [f13] [S-f3] local-function-key-map)
+ (substitute-key-definition [f14] [S-f4] local-function-key-map)
+ (substitute-key-definition [f15] [S-f5] local-function-key-map)
+ (substitute-key-definition [f16] [S-f6] local-function-key-map)
+ (substitute-key-definition [f17] [S-f7] local-function-key-map)
+ (substitute-key-definition [f18] [S-f8] local-function-key-map)
+ (substitute-key-definition [f19] [S-f9] local-function-key-map)
+ (substitute-key-definition [f20] [S-f10] local-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] local-function-key-map)
+ (substitute-key-definition [f24] [C-f2] local-function-key-map)
+ (substitute-key-definition [f25] [C-f3] local-function-key-map)
+ (substitute-key-definition [f26] [C-f4] local-function-key-map)
+ (substitute-key-definition [f27] [C-f5] local-function-key-map)
+ (substitute-key-definition [f28] [C-f6] local-function-key-map)
+ (substitute-key-definition [f29] [C-f7] local-function-key-map)
+ (substitute-key-definition [f30] [C-f8] local-function-key-map)
+ (substitute-key-definition [f31] [C-f9] local-function-key-map)
+ (substitute-key-definition [f32] [C-f10] local-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] local-function-key-map)
+ (substitute-key-definition [f34] [C-S-f2] local-function-key-map)
+ (substitute-key-definition [f35] [C-S-f3] local-function-key-map)
+ (substitute-key-definition [f36] [C-S-f4] local-function-key-map)
+ (substitute-key-definition [f37] [C-S-f5] local-function-key-map)
+ (substitute-key-definition [f38] [C-S-f6] local-function-key-map)
+ (substitute-key-definition [f39] [C-S-f7] local-function-key-map)
+ (substitute-key-definition [f40] [C-S-f8] local-function-key-map)
+ (substitute-key-definition [f41] [C-S-f9] local-function-key-map)
+ (substitute-key-definition [f42] [C-S-f10] local-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[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[7~" [home])
- (define-key map "\e[8~" [end])
- (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[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[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[7$" [S-home])
- (define-key map "\e[8$" [S-end])
- (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.
+ (let ((m (copy-keymap rxvt-function-map)))
+ (set-keymap-parent m (keymap-parent local-function-key-map))
+ (set-keymap-parent local-function-key-map m))
;; Initialize colors and background mode.
(rxvt-register-default-colors)
@@ -239,7 +243,7 @@ for the currently selected frame."
(- 256 ncolors)
(list color color color))
(setq ncolors (1- ncolors))))
-
+
((= ncolors 72) ; rxvt-unicode
;; 64 non-gray colors
(let ((levels '(0 139 205 255))
@@ -282,7 +286,7 @@ for the currently selected frame."
"Set background mode as appropriate for the default rxvt colors."
(let ((fgbg (getenv "COLORFGBG"))
bg rgb)
- (setq default-frame-background-mode 'light)
+ (set-terminal-parameter nil 'background-mode 'light)
(when (and fgbg
(string-match ".*;\\([0-9][0-9]?\\)\\'" fgbg))
(setq bg (string-to-number (substring fgbg (match-beginning 1))))
@@ -295,8 +299,7 @@ for the currently selected frame."
;; The following line assumes that white is the 15th
;; color in rxvt-standard-colors.
(* (apply '+ (car (cddr (nth 15 rxvt-standard-colors)))) 0.6))
- (setq default-frame-background-mode 'dark)))
- (frame-set-background-mode (selected-frame))))
+ (set-terminal-parameter nil 'background-mode 'dark)))))
;; arch-tag: 20cf2fb6-6318-4bab-9dbf-1d15048f2257
;;; rxvt.el ends here
diff --git a/lisp/term/sun.el b/lisp/term/sun.el
index c3dc773e26b..5743272d96a 100644
--- a/lisp/term/sun.el
+++ b/lisp/term/sun.el
@@ -150,7 +150,7 @@
(defun terminal-init-sun ()
"Terminal initialization function for sun."
- (define-key function-key-map "\e[" sun-raw-prefix)
+ (define-key local-function-key-map "\e[" sun-raw-prefix)
(define-key sun-raw-prefix "210z" [r3])
(define-key sun-raw-prefix "213z" [r6])
diff --git a/lisp/term/tvi970.el b/lisp/term/tvi970.el
index 1c0bda519ac..d090df55411 100644
--- a/lisp/term/tvi970.el
+++ b/lisp/term/tvi970.el
@@ -31,14 +31,14 @@
(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)))
+ (or (lookup-key local-function-key-map "\e[")
+ (define-key local-function-key-map "\e[" (make-keymap)))
+ ;; (or (lookup-key local-function-key-map "\eO")
+ ;; (define-key local-function-key-map "\eO" (make-keymap)))
;; Miscellaneous keys
(mapcar (function (lambda (key-binding)
- (define-key function-key-map
+ (define-key local-function-key-map
(car key-binding) (nth 1 key-binding))))
'(
;; These are set up by termcap or terminfo
@@ -54,7 +54,7 @@
("\e[@" [insert])
("\e[L" [insertline])
("\e[M" [deleteline])
- ("\e[U" [next]) ;; actually the `page' key
+ ("\e[U" [next]) ;; actually the `page' key
;; These won't be set up by either
("\eOm" [kp-subtract])
@@ -87,22 +87,23 @@
;; The numeric keypad keys.
(let ((i 0))
(while (< i 10)
- (define-key function-key-map
+ (define-key local-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
+ (define-key local-function-key-map
(format "\e?%c" (+ i ?a))
(vector (intern (format "f%d" (1+ i)))))
- (define-key function-key-map
+ (define-key local-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
diff --git a/lisp/term/vt100.el b/lisp/term/vt100.el
index b185a7bb02f..17627db8923 100644
--- a/lisp/term/vt100.el
+++ b/lisp/term/vt100.el
@@ -38,10 +38,9 @@
;; Set up function-key-map entries that termcap and terminfo don't know.
-
(defun terminal-init-vt100 ()
"Terminal initialization function for vt100."
- (load "term/lk201" nil t))
+ (tty-run-terminal-initialization (selected-frame) "lk201"))
;;; Controlling the screen width.
(defvar vt100-wide-mode (= (frame-width) 132)
diff --git a/lisp/term/vt102.el b/lisp/term/vt102.el
index ad780ed5081..67a90a8242c 100644
--- a/lisp/term/vt102.el
+++ b/lisp/term/vt102.el
@@ -1,8 +1,8 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-vt102 ()
- "Terminal initialization function for vt102."
- (load "term/vt100" nil t))
+ "Terminal initialization function for vt102."
+ (tty-run-terminal-initialization (selected-frame) "vt100"))
;;; arch-tag: 6e839cfc-125a-4574-82f1-c23a51f7c50f
;;; vt102.el ends here
diff --git a/lisp/term/vt125.el b/lisp/term/vt125.el
index 2221e597aed..82a7047fef1 100644
--- a/lisp/term/vt125.el
+++ b/lisp/term/vt125.el
@@ -1,8 +1,8 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-vt125 ()
- "Terminal initialization function for vt125."
- (load "term/vt100" nil t))
+ "Terminal initialization function for vt125."
+ (tty-run-terminal-initialization (selected-frame) "vt100"))
;;; arch-tag: 1d92d70f-dd55-4a1d-9088-e215a4883801
;;; vt125.el ends here
diff --git a/lisp/term/vt200.el b/lisp/term/vt200.el
index e1215d15023..7e7b3281d92 100644
--- a/lisp/term/vt200.el
+++ b/lisp/term/vt200.el
@@ -1,12 +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.
-
(defun terminal-init-vt200 ()
- "Terminal initialization function for vt200."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt200."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: 0f78f583-9f32-4237-b106-28bcfff21d89
;;; vt200.el ends here
diff --git a/lisp/term/vt201.el b/lisp/term/vt201.el
index 315030ab687..a63f9561a6d 100644
--- a/lisp/term/vt201.el
+++ b/lisp/term/vt201.el
@@ -2,10 +2,10 @@
;; For our purposes we can treat the vt200 and vt100 almost alike.
;; Most differences are handled by the termcap entry.
(defun terminal-init-vt201 ()
- "Terminal initialization function for vt201."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt201."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: a6abb38f-60ea-449e-a9e9-3fb8572c52ae
;;; vt201.el ends here
diff --git a/lisp/term/vt220.el b/lisp/term/vt220.el
index cccd2a6dfb7..b2b8fc944cf 100644
--- a/lisp/term/vt220.el
+++ b/lisp/term/vt220.el
@@ -2,10 +2,10 @@
;; For our purposes we can treat the vt200 and vt100 almost alike.
;; Most differences are handled by the termcap entry.
(defun terminal-init-vt220 ()
- "Terminal initialization function for vt220."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt220."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: 98fc4867-a20d-46a1-a276-d7be31e49871
;;; vt220.el ends here
diff --git a/lisp/term/vt240.el b/lisp/term/vt240.el
index bb3931edac8..cb26ebf4069 100644
--- a/lisp/term/vt240.el
+++ b/lisp/term/vt240.el
@@ -2,10 +2,10 @@
;; For our purposes we can treat the vt200 and vt100 almost alike.
;; Most differences are handled by the termcap entry.
(defun terminal-init-vt240 ()
- "Terminal initialization function for vt240."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt240."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: d9f88e9c-02dc-49ff-871c-a415f08e4eb7
;;; vt240.el ends here
diff --git a/lisp/term/vt300.el b/lisp/term/vt300.el
index ff600f47a1e..9a09ad5e8cb 100644
--- a/lisp/term/vt300.el
+++ b/lisp/term/vt300.el
@@ -1,9 +1,9 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-vt300 ()
- "Terminal initialization function for vt300."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt300."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: 876831c9-a6f2-444a-b033-706e6fbc149f
;;; vt300.el ends here
diff --git a/lisp/term/vt320.el b/lisp/term/vt320.el
index fb7772c7b5b..803d7286067 100644
--- a/lisp/term/vt320.el
+++ b/lisp/term/vt320.el
@@ -1,9 +1,9 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-vt320 ()
- "Terminal initialization function for vt320."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt320."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: f9f4c954-0b9e-45f9-b450-a320d32abd9c
;;; vt320.el ends here
diff --git a/lisp/term/vt400.el b/lisp/term/vt400.el
index 97c0c5d7372..f73f4660b94 100644
--- a/lisp/term/vt400.el
+++ b/lisp/term/vt400.el
@@ -1,9 +1,9 @@
;; -*- no-byte-compile: t -*-
(defun terminal-init-vt400 ()
- "Terminal initialization function for vt400."
- (load "term/vt100" nil t)
+ "Terminal initialization function for vt400."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: a70809c5-6b21-42cc-ba20-536683e5e7d5
;;; vt400.el ends here
diff --git a/lisp/term/vt420.el b/lisp/term/vt420.el
index 65ffa759c17..e65ba1a61d5 100644
--- a/lisp/term/vt420.el
+++ b/lisp/term/vt420.el
@@ -1,9 +1,9 @@
;; -*- no-byte-compile: t -*-
-(defun terminal-init-vt420 ()
- "Terminal initialization function for vt420."
- (load "term/vt100" nil t)
+(defun terminal-init-vt420
+ "Terminal initialization function for vt420."
+ (tty-run-terminal-initialization (selected-frame) "vt100")
;; Make F11 an escape key.
- (define-key function-key-map "\e[23~" [?\e]))
+ (define-key local-function-key-map "\e[23~" [?\e]))
;;; arch-tag: df2f897c-3a12-4b3c-9259-df089f96c160
;;; vt420.el ends here
diff --git a/lisp/term/w32-win.el b/lisp/term/w32-win.el
index dfe94aaf133..e2b88086eac 100644
--- a/lisp/term/w32-win.el
+++ b/lisp/term/w32-win.el
@@ -68,8 +68,8 @@
;; An alist of X options and the function which handles them. See
;; ../startup.el.
-(if (not (eq window-system 'w32))
- (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
+;; (if (not (eq window-system 'w32))
+;; (error "%s: Loading w32-win.el but not compiled for w32" (invocation-name)))
(require 'frame)
(require 'mouse)
@@ -89,9 +89,6 @@
;; The following definition is used for debugging scroll bar events.
;(defun w32-handle-scroll-bar-event (event) (interactive "e") (princ event))
-;; Handle mouse-wheel events with mwheel.
-(mouse-wheel-mode 1)
-
(defun w32-drag-n-drop-debug (event)
"Print the drag-n-drop EVENT in a readable form."
(interactive "e")
@@ -1039,58 +1036,30 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
;;;; Function keys
-;;; make f10 activate the real menubar rather than the mini-buffer menu
-;;; navigation feature.
-(defun menu-bar-open (&optional frame)
- "Start key navigation of the menu bar in FRAME.
-
-This initially activates the first menu-bar item, and you can then navigate
-with the arrow keys, select a menu entry with the Return key or cancel with
-the Escape key. If FRAME has no menu bar, this function does nothing.
-
-If FRAME is nil or not given, use the selected frame."
- (interactive "i")
- (w32-send-sys-command ?\xf100 frame))
-;
-(global-set-key [f10] 'menu-bar-open)
-
-(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
- global-map)
-
-(define-key function-key-map [S-tab] [backtab])
-
+ ;;; make f10 activate the real menubar rather than the mini-buffer menu
+ ;;; navigation feature.
+ (defun menu-bar-open (&optional frame)
+ "Start key navigation of the menu bar in FRAME.
+
+ This initially activates the first menu-bar item, and you can then navigate
+ with the arrow keys, select a menu entry with the Return key or cancel with
+ the Escape key. If FRAME has no menu bar, this function does nothing.
+
+ If FRAME is nil or not given, use the selected frame."
+ (interactive "i")
+ (w32-send-sys-command ?\xf100 frame))
+
+(defun x-setup-function-keys (frame)
+ "Setup Function Keys for w32."
+ (with-selected-frame frame
+ (define-key local-function-key-map [f10] 'menu-bar-open)
+
+ (substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
+ local-function-key-map global-map)
+
+ (define-key local-function-key-map [S-tab] [backtab]))
+ (set-terminal-parameter frame 'x-setup-function-keys t))
-;;; Do the actual Windows setup here; the above code just defines
-;;; functions and variables that we use now.
-
-(setq command-line-args (x-handle-args command-line-args))
-
-;;; Make sure we have a valid resource name.
-(or (stringp x-resource-name)
- (setq x-resource-name
- ;; Change any . or * characters in x-resource-name to hyphens,
- ;; so as not to choke when we use it in X resource queries.
- (replace-regexp-in-string "[.*]" "-" (invocation-name))))
-
-;; For the benefit of older Emacses (19.27 and earlier) that are sharing
-;; the same lisp directory, don't pass the third argument unless we seem
-;; to have the multi-display support.
-(if (fboundp 'x-close-connection)
- (x-open-connection ""
- x-command-line-resources
- ;; Exit Emacs with fatal error if this fails.
- t)
- (x-open-connection ""
- x-command-line-resources))
-
-(setq frame-creation-function 'x-create-frame-with-faces)
-
-(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
- x-cut-buffer-max))
-
-;; W32 expects the menu bar cut and paste commands to use the clipboard.
-;; This has ,? to match both on Sunos and on Solaris.
-(menu-bar-enable-clipboard)
;; W32 systems have different fonts than commonly found on X, so
;; we define our own standard fontset here.
@@ -1103,111 +1072,10 @@ European languages which are distributed with Windows as
See the documentation of `create-fontset-from-fontset-spec' for the format.")
-;; Conditional on new-fontset so bootstrapping works on non-GUI compiles
-(if (fboundp 'new-fontset)
- (progn
- ;; Setup the default fontset.
- (setup-default-fontset)
- ;; Create the standard fontset.
- (create-fontset-from-fontset-spec w32-standard-fontset-spec t)
- ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1,...).
- (create-fontset-from-x-resource)
- ;; Try to create a fontset from a font specification which comes
- ;; from initial-frame-alist, default-frame-alist, or X resource.
- ;; A font specification in command line argument (i.e. -fn XXXX)
- ;; should be already in default-frame-alist as a `font'
- ;; parameter. However, any font specifications in site-start
- ;; library, user's init file (.emacs), and default.el are not
- ;; yet handled here.
-
- (let ((font (or (cdr (assq 'font initial-frame-alist))
- (cdr (assq 'font default-frame-alist))
- (x-get-resource "font" "Font")))
- xlfd-fields resolved-name)
- (if (and font
- (not (query-fontset font))
- (setq resolved-name (x-resolve-font-name font))
- (setq xlfd-fields (x-decompose-font-name font)))
- (if (string= "fontset"
- (aref xlfd-fields xlfd-regexp-registry-subnum))
- (new-fontset font
- (x-complement-fontset-spec xlfd-fields nil))
- ;; Create a fontset from FONT. The fontset name is
- ;; generated from FONT.
- (create-fontset-from-ascii-font font
- resolved-name "startup"))))))
-
-;; Apply a geometry resource to the initial frame. Put it at the end
-;; of the alist, so that anything specified on the command line takes
-;; precedence.
-(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
- parsed)
- (if res-geometry
- (progn
- (setq parsed (x-parse-geometry res-geometry))
- ;; If the resource specifies a position,
- ;; call the position and size "user-specified".
- (if (or (assq 'top parsed) (assq 'left parsed))
- (setq parsed (cons '(user-position . t)
- (cons '(user-size . t) parsed))))
- ;; All geometry parms apply to the initial frame.
- (setq initial-frame-alist (append initial-frame-alist parsed))
- ;; The size parms apply to all frames.
- (if (assq 'height parsed)
- (push (cons 'height (cdr (assq 'height parsed)))
- default-frame-alist))
- (if (assq 'width parsed)
- (push (cons 'width (cdr (assq 'width parsed)))
- default-frame-alist)))))
-
-;; Check the reverseVideo resource.
-(let ((case-fold-search t))
- (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
- (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv))
- (push '(reverse . t) default-frame-alist))))
-
(defun x-win-suspend-error ()
"Report an error when a suspend is attempted."
(error "Suspending an Emacs running under W32 makes no sense"))
-(add-hook 'suspend-hook 'x-win-suspend-error)
-
-;;; Turn off window-splitting optimization; w32 is usually fast enough
-;;; that this is only annoying.
-(setq split-window-keep-point t)
-
-;; Don't show the frame name; that's redundant.
-(setq-default mode-line-frame-identification " ")
-
-;;; Set to a system sound if you want a fancy bell.
-(set-message-beep 'ok)
-
-;; Remap some functions to call w32 common dialogs
-
-(defun internal-face-interactive (what &optional bool)
- (let* ((fn (intern (concat "face-" what)))
- (prompt (concat "Set " what " of face "))
- (face (read-face-name prompt))
- (default (if (fboundp fn)
- (or (funcall fn face (selected-frame))
- (funcall fn 'default (selected-frame)))))
- (fn-win (intern (concat (symbol-name window-system) "-select-" what)))
- value)
- (setq value
- (cond ((fboundp fn-win)
- (funcall fn-win))
- ((eq bool 'color)
- (completing-read (concat prompt " " (symbol-name face) " to: ")
- (mapcar (function (lambda (color)
- (cons color color)))
- x-colors)
- nil nil nil nil default))
- (bool
- (y-or-n-p (concat "Should face " (symbol-name face)
- " be " bool "? ")))
- (t
- (read-string (concat prompt " " (symbol-name face) " to: ")
- nil nil default))))
- (list face (if (equal value "") nil value))))
+
;;; Enable Japanese fonts on Windows to be used by default.
(set-fontset-font nil (make-char 'katakana-jisx0201) '("*" . "JISX0208-SJIS"))
@@ -1256,5 +1124,115 @@ pop-up menu are unaffected by `w32-list-proportional-fonts')."
(tiff "libtiff3.dll" "libtiff.dll")
(gif "giflib4.dll" "libungif4.dll" "libungif.dll")))
+;;; multi-tty support
+(defvar w32-initialized nil
+ "Non-nil if the w32 window system has been initialized.")
+
+(defun w32-initialize-window-system ()
+ "Initialize Emacs for W32 GUI frames."
+
+ ;; Do the actual Windows setup here; the above code just defines
+ ;; functions and variables that we use now.
+
+ (setq command-line-args (x-handle-args command-line-args))
+
+ ;; Make sure we have a valid resource name.
+ (or (stringp x-resource-name)
+ (setq x-resource-name
+ ;; Change any . or * characters in x-resource-name to hyphens,
+ ;; so as not to choke when we use it in X resource queries.
+ (replace-regexp-in-string "[.*]" "-" (invocation-name))))
+
+ (x-open-connection "" x-command-line-resources
+ ;; Exit with a fatal error if this fails and we
+ ;; are the initial display
+ (eq initial-window-system 'w32))
+
+ ;; Setup the default fontset.
+ (setup-default-fontset)
+ ;; Create the standard fontset.
+ (create-fontset-from-fontset-spec w32-standard-fontset-spec t)
+ ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1,...).
+ (create-fontset-from-x-resource)
+ ;; Try to create a fontset from a font specification which comes
+ ;; from initial-frame-alist, default-frame-alist, or X resource.
+ ;; A font specification in command line argument (i.e. -fn XXXX)
+ ;; should be already in default-frame-alist as a `font'
+ ;; parameter. However, any font specifications in site-start
+ ;; library, user's init file (.emacs), and default.el are not
+ ;; yet handled here.
+
+ (let ((font (or (cdr (assq 'font initial-frame-alist))
+ (cdr (assq 'font default-frame-alist))
+ (x-get-resource "font" "Font")))
+ xlfd-fields resolved-name)
+ (if (and font
+ (not (query-fontset font))
+ (setq resolved-name (x-resolve-font-name font))
+ (setq xlfd-fields (x-decompose-font-name font)))
+ (if (string= "fontset"
+ (aref xlfd-fields xlfd-regexp-registry-subnum))
+ (new-fontset font
+ (x-complement-fontset-spec xlfd-fields nil))
+ ;; Create a fontset from FONT. The fontset name is
+ ;; generated from FONT.
+ (create-fontset-from-ascii-font font
+ resolved-name "startup"))))
+
+ ;; Apply a geometry resource to the initial frame. Put it at the end
+ ;; of the alist, so that anything specified on the command line takes
+ ;; precedence.
+ (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
+ parsed)
+ (if res-geometry
+ (progn
+ (setq parsed (x-parse-geometry res-geometry))
+ ;; If the resource specifies a position,
+ ;; call the position and size "user-specified".
+ (if (or (assq 'top parsed) (assq 'left parsed))
+ (setq parsed (cons '(user-position . t)
+ (cons '(user-size . t) parsed))))
+ ;; All geometry parms apply to the initial frame.
+ (setq initial-frame-alist (append initial-frame-alist parsed))
+ ;; The size parms apply to all frames.
+ (if (assq 'height parsed)
+ (push (cons 'height (cdr (assq 'height parsed)))
+ default-frame-alist))
+ (if (assq 'width parsed)
+ (push (cons 'width (cdr (assq 'width parsed)))
+ default-frame-alist)))))
+
+ ;; Check the reverseVideo resource.
+ (let ((case-fold-search t))
+ (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
+ (if (and rv (string-match "^\\(true\\|yes\\|on\\)$" rv))
+ (push '(reverse . t) default-frame-alist))))
+
+ ;; Don't let Emacs suspend under w32 gui
+ (add-hook 'suspend-hook 'x-win-suspend-error)
+
+ ;; Turn off window-splitting optimization; w32 is usually fast enough
+ ;; that this is only annoying.
+ (setq split-window-keep-point t)
+
+ ;; Turn on support for mouse wheels
+ (mouse-wheel-mode 1)
+
+ ;; W32 expects the menu bar cut and paste commands to use the clipboard.
+ (menu-bar-enable-clipboard)
+
+ ;; Don't show the frame name; that's redundant.
+ (setq-default mode-line-frame-identification " ")
+
+ ;; Set to a system sound if you want a fancy bell.
+ (set-message-beep 'ok)
+ (setq w32-initialized t))
+
+(add-to-list 'handle-args-function-alist '(w32 . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(w32 . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(w32 . w32-initialize-window-system))
+
+(provide 'w32-win)
+
;; arch-tag: 69fb1701-28c2-4890-b351-3d1fe4b4f166
;;; w32-win.el ends here
diff --git a/lisp/term/wyse50.el b/lisp/term/wyse50.el
index c0e4334f522..e241224c637 100644
--- a/lisp/term/wyse50.el
+++ b/lisp/term/wyse50.el
@@ -40,9 +40,9 @@
(defun terminal-init-wyse50 ()
"Terminal initialization function for wyse50."
- (define-key function-key-map "\C-a" (make-keymap))
+ (define-key local-function-key-map "\C-a" (make-keymap))
(mapcar (function (lambda (key-definition)
- (define-key function-key-map
+ (define-key local-function-key-map
(car key-definition) (nth 1 key-definition))))
'(
;; These might be set up by termcap and terminfo
@@ -100,11 +100,11 @@
("\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
+ ("\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
))
diff --git a/lisp/term/x-win.el b/lisp/term/x-win.el
index ed4330ee969..478d63d6057 100644
--- a/lisp/term/x-win.el
+++ b/lisp/term/x-win.el
@@ -25,10 +25,16 @@
;;; Commentary:
-;; X-win.el: this file is loaded from ../lisp/startup.el when it recognizes
-;; that X windows are to be used. Command line switches are parsed and those
-;; pertaining to X are processed and removed from the command line. The
-;; X display is opened and hooks are set for popping up the initial window.
+;; X-win.el: this file defines functions to initialize the X window
+;; system and process X-specific command line parameters before
+;; creating the first X frame.
+
+;; Note that contrary to previous Emacs versions, the act of loading
+;; this file should not have the side effect of initializing the
+;; window system or processing command line arguments (this file is
+;; now loaded in loadup.el). See the variables
+;; `handle-args-function-alist' and
+;; `window-system-initialization-alist' for more details.
;; startup.el will then examine startup files, and eventually call the hooks
;; which create the first window(s).
@@ -65,7 +71,7 @@
;; An alist of X options and the function which handles them. See
;; ../startup.el.
-(if (not (eq window-system 'x))
+(if (not (fboundp 'x-create-frame))
(error "%s: Loading x-win.el but not compiled for X" (invocation-name)))
(require 'frame)
@@ -1170,27 +1176,30 @@ XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp")
;;;; Function keys
-(substitute-key-definition 'suspend-emacs 'iconify-or-deiconify-frame
- global-map)
-
-;; Map certain keypad keys into ASCII characters
-;; that people usually expect.
-(define-key function-key-map [backspace] [127])
-(define-key function-key-map [delete] [127])
-(define-key function-key-map [tab] [?\t])
-(define-key function-key-map [linefeed] [?\n])
-(define-key function-key-map [clear] [?\C-l])
-(define-key function-key-map [return] [?\C-m])
-(define-key function-key-map [escape] [?\e])
-(define-key function-key-map [M-backspace] [?\M-\d])
-(define-key function-key-map [M-delete] [?\M-\d])
-(define-key function-key-map [M-tab] [?\M-\t])
-(define-key function-key-map [M-linefeed] [?\M-\n])
-(define-key function-key-map [M-clear] [?\M-\C-l])
-(define-key function-key-map [M-return] [?\M-\C-m])
-(define-key function-key-map [M-escape] [?\M-\e])
-(define-key function-key-map [iso-lefttab] [backtab])
-(define-key function-key-map [S-iso-lefttab] [backtab])
+(defun x-setup-function-keys (frame)
+ "Set up `function-key-map' on FRAME for the X window system."
+ ;; Don't do this twice on the same display, or it would break
+ ;; normal-erase-is-backspace-mode.
+ (unless (terminal-parameter frame 'x-setup-function-keys)
+ ;; Map certain keypad keys into ASCII characters that people usually expect.
+ (with-selected-frame frame
+ (define-key local-function-key-map [backspace] [127])
+ (define-key local-function-key-map [delete] [127])
+ (define-key local-function-key-map [tab] [?\t])
+ (define-key local-function-key-map [linefeed] [?\n])
+ (define-key local-function-key-map [clear] [?\C-l])
+ (define-key local-function-key-map [return] [?\C-m])
+ (define-key local-function-key-map [escape] [?\e])
+ (define-key local-function-key-map [M-backspace] [?\M-\d])
+ (define-key local-function-key-map [M-delete] [?\M-\d])
+ (define-key local-function-key-map [M-tab] [?\M-\t])
+ (define-key local-function-key-map [M-linefeed] [?\M-\n])
+ (define-key local-function-key-map [M-clear] [?\M-\C-l])
+ (define-key local-function-key-map [M-return] [?\M-\C-m])
+ (define-key local-function-key-map [M-escape] [?\M-\e])
+ (define-key local-function-key-map [iso-lefttab] [backtab])
+ (define-key local-function-key-map [S-iso-lefttab] [backtab]))
+ (set-terminal-parameter frame 'x-setup-function-keys t)))
;; These tell read-char how to convert
;; these special chars to ASCII.
@@ -2393,154 +2402,165 @@ order until succeed.")
(or clip-text primary-text cut-text)
))
-
-;; Do the actual X Windows setup here; the above code just defines
-;; functions and variables that we use now.
-
-(setq command-line-args (x-handle-args command-line-args))
-
-;; Make sure we have a valid resource name.
-(or (stringp x-resource-name)
- (let (i)
- (setq x-resource-name (invocation-name))
-
- ;; Change any . or * characters in x-resource-name to hyphens,
- ;; so as not to choke when we use it in X resource queries.
- (while (setq i (string-match "[.*]" x-resource-name))
- (aset x-resource-name i ?-))))
-
-(x-open-connection (or x-display-name
- (setq x-display-name (getenv "DISPLAY")))
- x-command-line-resources
- ;; Exit Emacs with fatal error if this fails.
- t)
-
-(setq frame-creation-function 'x-create-frame-with-faces)
-
-(setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
- x-cut-buffer-max))
-
-;; Setup the default fontset.
-(setup-default-fontset)
-
-;; Create the standard fontset.
-(create-fontset-from-fontset-spec standard-fontset-spec t)
-
-;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
-(create-fontset-from-x-resource)
-
-;; Try to create a fontset from a font specification which comes
-;; from initial-frame-alist, default-frame-alist, or X resource.
-;; A font specification in command line argument (i.e. -fn XXXX)
-;; should be already in default-frame-alist as a `font'
-;; parameter. However, any font specifications in site-start
-;; library, user's init file (.emacs), and default.el are not
-;; yet handled here.
-
-(let ((font (or (cdr (assq 'font initial-frame-alist))
- (cdr (assq 'font default-frame-alist))
- (x-get-resource "font" "Font")))
- xlfd-fields resolved-name)
- (if (and font
- (not (query-fontset font))
- (setq resolved-name (x-resolve-font-name font))
- (setq xlfd-fields (x-decompose-font-name font)))
- (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
- (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
- ;; Create a fontset from FONT. The fontset name is
- ;; generated from FONT.
- (create-fontset-from-ascii-font font resolved-name "startup"))))
-
-;; Apply a geometry resource to the initial frame. Put it at the end
-;; of the alist, so that anything specified on the command line takes
-;; precedence.
-(let* ((res-geometry (x-get-resource "geometry" "Geometry"))
- parsed)
- (if res-geometry
- (progn
- (setq parsed (x-parse-geometry res-geometry))
- ;; If the resource specifies a position,
- ;; call the position and size "user-specified".
- (if (or (assq 'top parsed) (assq 'left parsed))
- (setq parsed (cons '(user-position . t)
- (cons '(user-size . t) parsed))))
- ;; All geometry parms apply to the initial frame.
- (setq initial-frame-alist (append initial-frame-alist parsed))
- ;; The size parms apply to all frames. Don't set it if there are
- ;; sizes there already (from command line).
- (if (and (assq 'height parsed)
- (not (assq 'height default-frame-alist)))
- (setq default-frame-alist
- (cons (cons 'height (cdr (assq 'height parsed)))
- default-frame-alist)))
- (if (and (assq 'width parsed)
- (not (assq 'width default-frame-alist)))
- (setq default-frame-alist
- (cons (cons 'width (cdr (assq 'width parsed)))
- default-frame-alist))))))
-
-;; Check the reverseVideo resource.
-(let ((case-fold-search t))
- (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
- (if (and rv
- (string-match "^\\(true\\|yes\\|on\\)$" rv))
- (setq default-frame-alist
- (cons '(reverse . t) default-frame-alist)))))
+(defun x-clipboard-yank ()
+ "Insert the clipboard contents, or the last stretch of killed text."
+ (interactive "*")
+ (let ((clipboard-text (x-selection-value 'CLIPBOARD))
+ (x-select-enable-clipboard t))
+ (if (and clipboard-text (> (length clipboard-text) 0))
+ (kill-new clipboard-text))
+ (yank)))
-;; Set x-selection-timeout, measured in milliseconds.
-(let ((res-selection-timeout
- (x-get-resource "selectionTimeout" "SelectionTimeout")))
- (setq x-selection-timeout 20000)
- (if res-selection-timeout
- (setq x-selection-timeout (string-to-number res-selection-timeout))))
+(defun x-menu-bar-open (&optional frame)
+ "Open the menu bar if `menu-bar-mode' is on. otherwise call `tmm-menubar'."
+ (interactive "i")
+ (if menu-bar-mode (accelerate-menu frame)
+ (tmm-menubar)))
-;; Set scroll bar mode to right if set by X resources. Default is left.
-(if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
- (customize-set-variable 'scroll-bar-mode 'right))
+
+;;; Window system initialization.
(defun x-win-suspend-error ()
(error "Suspending an Emacs running under X makes no sense"))
-(add-hook 'suspend-hook 'x-win-suspend-error)
-;; Arrange for the kill and yank functions to set and check the clipboard.
-(setq interprogram-cut-function 'x-select-text)
-(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
+(defvar x-initialized nil
+ "Non-nil if the X window system has been initialized.")
+
+(defun x-initialize-window-system ()
+ "Initialize Emacs for X frames and open the first connection to an X server."
+ ;; Make sure we have a valid resource name.
+ (or (stringp x-resource-name)
+ (let (i)
+ (setq x-resource-name (invocation-name))
+
+ ;; Change any . or * characters in x-resource-name to hyphens,
+ ;; so as not to choke when we use it in X resource queries.
+ (while (setq i (string-match "[.*]" x-resource-name))
+ (aset x-resource-name i ?-))))
+
+ (x-open-connection (or x-display-name
+ (setq x-display-name (or (getenv "DISPLAY" (selected-frame))
+ (getenv "DISPLAY"))))
+ x-command-line-resources
+ ;; Exit Emacs with fatal error if this fails and we
+ ;; are the initial display.
+ (eq initial-window-system 'x))
+
+ (setq x-cut-buffer-max (min (- (/ (x-server-max-request-size) 2) 100)
+ x-cut-buffer-max))
+
+ ;; Setup the default fontset.
+ (setup-default-fontset)
+
+ ;; Create the standard fontset.
+ (create-fontset-from-fontset-spec standard-fontset-spec t)
+
+ ;; Create fontset specified in X resources "Fontset-N" (N is 0, 1, ...).
+ (create-fontset-from-x-resource)
+
+ ;; Try to create a fontset from a font specification which comes
+ ;; from initial-frame-alist, default-frame-alist, or X resource.
+ ;; A font specification in command line argument (i.e. -fn XXXX)
+ ;; should be already in default-frame-alist as a `font'
+ ;; parameter. However, any font specifications in site-start
+ ;; library, user's init file (.emacs), and default.el are not
+ ;; yet handled here.
+
+ (let ((font (or (cdr (assq 'font initial-frame-alist))
+ (cdr (assq 'font default-frame-alist))
+ (x-get-resource "font" "Font")))
+ xlfd-fields resolved-name)
+ (if (and font
+ (not (query-fontset font))
+ (setq resolved-name (x-resolve-font-name font))
+ (setq xlfd-fields (x-decompose-font-name font)))
+ (if (string= "fontset" (aref xlfd-fields xlfd-regexp-registry-subnum))
+ (new-fontset font (x-complement-fontset-spec xlfd-fields nil))
+ ;; Create a fontset from FONT. The fontset name is
+ ;; generated from FONT.
+ (create-fontset-from-ascii-font font resolved-name "startup"))))
+
+ ;; Set scroll bar mode to right if set by X resources. Default is left.
+ (if (equal (x-get-resource "verticalScrollBars" "ScrollBars") "right")
+ (customize-set-variable 'scroll-bar-mode 'right))
+
+ ;; Apply a geometry resource to the initial frame. Put it at the end
+ ;; of the alist, so that anything specified on the command line takes
+ ;; precedence.
+ (let* ((res-geometry (x-get-resource "geometry" "Geometry"))
+ parsed)
+ (if res-geometry
+ (progn
+ (setq parsed (x-parse-geometry res-geometry))
+ ;; If the resource specifies a position,
+ ;; call the position and size "user-specified".
+ (if (or (assq 'top parsed) (assq 'left parsed))
+ (setq parsed (cons '(user-position . t)
+ (cons '(user-size . t) parsed))))
+ ;; All geometry parms apply to the initial frame.
+ (setq initial-frame-alist (append initial-frame-alist parsed))
+ ;; The size parms apply to all frames. Don't set it if there are
+ ;; sizes there already (from command line).
+ (if (and (assq 'height parsed)
+ (not (assq 'height default-frame-alist)))
+ (setq default-frame-alist
+ (cons (cons 'height (cdr (assq 'height parsed)))
+ default-frame-alist)))
+ (if (and (assq 'width parsed)
+ (not (assq 'width default-frame-alist)))
+ (setq default-frame-alist
+ (cons (cons 'width (cdr (assq 'width parsed)))
+ default-frame-alist))))))
+
+ ;; Check the reverseVideo resource.
+ (let ((case-fold-search t))
+ (let ((rv (x-get-resource "reverseVideo" "ReverseVideo")))
+ (if (and rv
+ (string-match "^\\(true\\|yes\\|on\\)$" rv))
+ (setq default-frame-alist
+ (cons '(reverse . t) default-frame-alist)))))
-;; Turn off window-splitting optimization; X is usually fast enough
-;; that this is only annoying.
-(setq split-window-keep-point t)
+ ;; Set x-selection-timeout, measured in milliseconds.
+ (let ((res-selection-timeout
+ (x-get-resource "selectionTimeout" "SelectionTimeout")))
+ (setq x-selection-timeout 20000)
+ (if res-selection-timeout
+ (setq x-selection-timeout (string-to-number res-selection-timeout))))
-;; Don't show the frame name; that's redundant with X.
-(setq-default mode-line-frame-identification " ")
+ ;; Don't let Emacs suspend under X.
+ (add-hook 'suspend-hook 'x-win-suspend-error)
-;; Motif direct handling of f10 wasn't working right,
-;; So temporarily we've turned it off in lwlib-Xm.c
-;; and turned the Emacs f10 back on.
-;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
-;; (if (featurep 'motif)
-;; (global-set-key [f10] 'ignore))
+ ;; Turn off window-splitting optimization; X is usually fast enough
+ ;; that this is only annoying.
+ (setq split-window-keep-point t)
-;; Turn on support for mouse wheels.
-(mouse-wheel-mode 1)
+ ;; Motif direct handling of f10 wasn't working right,
+ ;; So temporarily we've turned it off in lwlib-Xm.c
+ ;; and turned the Emacs f10 back on.
+ ;; ;; Motif normally handles f10 itself, so don't try to handle it a second time.
+ ;; (if (featurep 'motif)
+ ;; (global-set-key [f10] 'ignore))
+ ;; Turn on support for mouse wheels.
+ (mouse-wheel-mode 1)
-;; Enable CLIPBOARD copy/paste through menu bar commands.
-(menu-bar-enable-clipboard)
+ ;; Enable CLIPBOARD copy/paste through menu bar commands.
+ (menu-bar-enable-clipboard)
-;; Override Paste so it looks at CLIPBOARD first.
-(defun x-clipboard-yank ()
- "Insert the clipboard contents, or the last stretch of killed text."
- (interactive "*")
- (let ((clipboard-text (x-selection-value 'CLIPBOARD))
- (x-select-enable-clipboard t))
- (if (and clipboard-text (> (length clipboard-text) 0))
- (kill-new clipboard-text))
- (yank)))
+ ;; Override Paste so it looks at CLIPBOARD first.
+ (define-key menu-bar-edit-menu [paste]
+ (append '(menu-item "Paste" x-clipboard-yank
+ :enable (not buffer-read-only)
+ :help "Paste (yank) text most recently cut/copied")
+ nil))
+
+ (setq x-initialized t))
+
+(add-to-list 'handle-args-function-alist '(x . x-handle-args))
+(add-to-list 'frame-creation-function-alist '(x . x-create-frame-with-faces))
+(add-to-list 'window-system-initialization-alist '(x . x-initialize-window-system))
-(define-key menu-bar-edit-menu [paste]
- '(menu-item "Paste" x-clipboard-yank
- :enable (not buffer-read-only)
- :help "Paste (yank) text most recently cut/copied"))
+(provide 'x-win)
;; Initiate drag and drop
(add-hook 'after-make-frame-functions 'x-dnd-init-frame)
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index 5eb1d8b4c70..22f83f2f96d 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -27,16 +27,309 @@
;;; Code:
+(defvar xterm-function-map (make-sparse-keymap)
+ "Function key map overrides for xterm.")
+
+;; xterm from X.org 6.8.2 uses these key definitions.
+(define-key xterm-function-map "\eOP" [f1])
+(define-key xterm-function-map "\eOQ" [f2])
+(define-key xterm-function-map "\eOR" [f3])
+(define-key xterm-function-map "\eOS" [f4])
+(define-key xterm-function-map "\e[15~" [f5])
+(define-key xterm-function-map "\e[17~" [f6])
+(define-key xterm-function-map "\e[18~" [f7])
+(define-key xterm-function-map "\e[19~" [f8])
+(define-key xterm-function-map "\e[20~" [f9])
+(define-key xterm-function-map "\e[21~" [f10])
+(define-key xterm-function-map "\e[23~" [f11])
+(define-key xterm-function-map "\e[24~" [f12])
+
+(define-key xterm-function-map "\eO2P" [S-f1])
+(define-key xterm-function-map "\eO2Q" [S-f2])
+(define-key xterm-function-map "\eO2R" [S-f3])
+(define-key xterm-function-map "\eO2S" [S-f4])
+(define-key xterm-function-map "\e[1;2P" [S-f1])
+(define-key xterm-function-map "\e[1;2Q" [S-f2])
+(define-key xterm-function-map "\e[1;2R" [S-f3])
+(define-key xterm-function-map "\e[1;2S" [S-f4])
+(define-key xterm-function-map "\e[15;2~" [S-f5])
+(define-key xterm-function-map "\e[17;2~" [S-f6])
+(define-key xterm-function-map "\e[18;2~" [S-f7])
+(define-key xterm-function-map "\e[19;2~" [S-f8])
+(define-key xterm-function-map "\e[20;2~" [S-f9])
+(define-key xterm-function-map "\e[21;2~" [S-f10])
+(define-key xterm-function-map "\e[23;2~" [S-f11])
+(define-key xterm-function-map "\e[24;2~" [S-f12])
+
+(define-key xterm-function-map "\eO5P" [C-f1])
+(define-key xterm-function-map "\eO5Q" [C-f2])
+(define-key xterm-function-map "\eO5R" [C-f3])
+(define-key xterm-function-map "\eO5S" [C-f4])
+(define-key xterm-function-map "\e[15;5~" [C-f5])
+(define-key xterm-function-map "\e[17;5~" [C-f6])
+(define-key xterm-function-map "\e[18;5~" [C-f7])
+(define-key xterm-function-map "\e[19;5~" [C-f8])
+(define-key xterm-function-map "\e[20;5~" [C-f9])
+(define-key xterm-function-map "\e[21;5~" [C-f10])
+(define-key xterm-function-map "\e[23;5~" [C-f11])
+(define-key xterm-function-map "\e[24;5~" [C-f12])
+
+(define-key xterm-function-map "\eO6P" [C-S-f1])
+(define-key xterm-function-map "\eO6Q" [C-S-f2])
+(define-key xterm-function-map "\eO6R" [C-S-f3])
+(define-key xterm-function-map "\eO6S" [C-S-f4])
+(define-key xterm-function-map "\e[15;6~" [C-S-f5])
+(define-key xterm-function-map "\e[17;6~" [C-S-f6])
+(define-key xterm-function-map "\e[18;6~" [C-S-f7])
+(define-key xterm-function-map "\e[19;6~" [C-S-f8])
+(define-key xterm-function-map "\e[20;6~" [C-S-f9])
+(define-key xterm-function-map "\e[21;6~" [C-S-f10])
+(define-key xterm-function-map "\e[23;6~" [C-S-f11])
+(define-key xterm-function-map "\e[24;6~" [C-S-f12])
+
+(define-key xterm-function-map "\eO3P" [A-f1])
+(define-key xterm-function-map "\eO3Q" [A-f2])
+(define-key xterm-function-map "\eO3R" [A-f3])
+(define-key xterm-function-map "\eO3S" [A-f4])
+(define-key xterm-function-map "\e[15;3~" [A-f5])
+(define-key xterm-function-map "\e[17;3~" [A-f6])
+(define-key xterm-function-map "\e[18;3~" [A-f7])
+(define-key xterm-function-map "\e[19;3~" [A-f8])
+(define-key xterm-function-map "\e[20;3~" [A-f9])
+(define-key xterm-function-map "\e[21;3~" [A-f10])
+(define-key xterm-function-map "\e[23;3~" [A-f11])
+(define-key xterm-function-map "\e[24;3~" [A-f12])
+
+(define-key xterm-function-map "\eOA" [up])
+(define-key xterm-function-map "\eOB" [down])
+(define-key xterm-function-map "\eOC" [right])
+(define-key xterm-function-map "\eOD" [left])
+(define-key xterm-function-map "\eOF" [end])
+(define-key xterm-function-map "\eOH" [home])
+
+(define-key xterm-function-map "\e[1;2A" [S-up])
+(define-key xterm-function-map "\e[1;2B" [S-down])
+(define-key xterm-function-map "\e[1;2C" [S-right])
+(define-key xterm-function-map "\e[1;2D" [S-left])
+(define-key xterm-function-map "\e[1;2F" [S-end])
+(define-key xterm-function-map "\e[1;2H" [S-home])
+
+(define-key xterm-function-map "\e[1;5A" [C-up])
+(define-key xterm-function-map "\e[1;5B" [C-down])
+(define-key xterm-function-map "\e[1;5C" [C-right])
+(define-key xterm-function-map "\e[1;5D" [C-left])
+(define-key xterm-function-map "\e[1;5F" [C-end])
+(define-key xterm-function-map "\e[1;5H" [C-home])
+
+(define-key xterm-function-map "\e[1;6A" [C-S-up])
+(define-key xterm-function-map "\e[1;6B" [C-S-down])
+(define-key xterm-function-map "\e[1;6C" [C-S-right])
+(define-key xterm-function-map "\e[1;6D" [C-S-left])
+(define-key xterm-function-map "\e[1;6F" [C-S-end])
+(define-key xterm-function-map "\e[1;6H" [C-S-home])
+
+(define-key xterm-function-map "\e[1;3A" [A-up])
+(define-key xterm-function-map "\e[1;3B" [A-down])
+(define-key xterm-function-map "\e[1;3C" [A-right])
+(define-key xterm-function-map "\e[1;3D" [A-left])
+(define-key xterm-function-map "\e[1;3F" [A-end])
+(define-key xterm-function-map "\e[1;3H" [A-home])
+
+(define-key xterm-function-map "\e[2~" [insert])
+(define-key xterm-function-map "\e[3~" [delete])
+(define-key xterm-function-map "\e[5~" [prior])
+(define-key xterm-function-map "\e[6~" [next])
+
+(define-key xterm-function-map "\e[2;2~" [S-insert])
+(define-key xterm-function-map "\e[3;2~" [S-delete])
+(define-key xterm-function-map "\e[5;2~" [S-prior])
+(define-key xterm-function-map "\e[6;2~" [S-next])
+
+(define-key xterm-function-map "\e[2;5~" [C-insert])
+(define-key xterm-function-map "\e[3;5~" [C-delete])
+(define-key xterm-function-map "\e[5;5~" [C-prior])
+(define-key xterm-function-map "\e[6;5~" [C-next])
+
+(define-key xterm-function-map "\e[2;6~" [C-S-insert])
+(define-key xterm-function-map "\e[3;6~" [C-S-delete])
+(define-key xterm-function-map "\e[5;6~" [C-S-prior])
+(define-key xterm-function-map "\e[6;6~" [C-S-next])
+
+(define-key xterm-function-map "\e[2;3~" [A-insert])
+(define-key xterm-function-map "\e[3;3~" [A-delete])
+(define-key xterm-function-map "\e[5;3~" [A-prior])
+(define-key xterm-function-map "\e[6;3~" [A-next])
+
+(define-key xterm-function-map "\e[4~" [select])
+(define-key xterm-function-map "\e[29~" [print])
+
+(define-key xterm-function-map "\eOj" [kp-multiply])
+(define-key xterm-function-map "\eOk" [kp-add])
+(define-key xterm-function-map "\eOl" [kp-separator])
+(define-key xterm-function-map "\eOm" [kp-subtract])
+(define-key xterm-function-map "\eOo" [kp-divide])
+(define-key xterm-function-map "\eOp" [kp-0])
+(define-key xterm-function-map "\eOq" [kp-1])
+(define-key xterm-function-map "\eOr" [kp-2])
+(define-key xterm-function-map "\eOs" [kp-3])
+(define-key xterm-function-map "\eOt" [kp-4])
+(define-key xterm-function-map "\eOu" [kp-5])
+(define-key xterm-function-map "\eOv" [kp-6])
+(define-key xterm-function-map "\eOw" [kp-7])
+(define-key xterm-function-map "\eOx" [kp-8])
+(define-key xterm-function-map "\eOy" [kp-9])
+
+;; These keys are available in xterm starting from version 216
+;; if the modifyOtherKeys resource is set to 1.
+
+(define-key xterm-function-map "\e[27;5;9~" [C-tab])
+(define-key xterm-function-map "\e[27;5;13~" [C-return])
+(define-key xterm-function-map "\e[27;5;39~" [?\C-\'])
+(define-key xterm-function-map "\e[27;5;44~" [?\C-,])
+(define-key xterm-function-map "\e[27;5;45~" [?\C--])
+(define-key xterm-function-map "\e[27;5;46~" [?\C-.])
+(define-key xterm-function-map "\e[27;5;47~" [?\C-/])
+(define-key xterm-function-map "\e[27;5;48~" [?\C-0])
+(define-key xterm-function-map "\e[27;5;49~" [?\C-1])
+;; Not all C-DIGIT keys have a distinct binding.
+(define-key xterm-function-map "\e[27;5;57~" [?\C-9])
+(define-key xterm-function-map "\e[27;5;59~" [?\C-\;])
+(define-key xterm-function-map "\e[27;5;61~" [?\C-=])
+(define-key xterm-function-map "\e[27;5;92~" [?\C-\\])
+
+(define-key xterm-function-map "\e[27;6;33~" [?\C-!])
+(define-key xterm-function-map "\e[27;6;34~" [?\C-\"])
+(define-key xterm-function-map "\e[27;6;35~" [?\C-#])
+(define-key xterm-function-map "\e[27;6;36~" [?\C-$])
+(define-key xterm-function-map "\e[27;6;37~" [?\C-%])
+(define-key xterm-function-map "\e[27;6;38~" [?\C-&])
+(define-key xterm-function-map "\e[27;6;40~" [?\C-(])
+(define-key xterm-function-map "\e[27;6;41~" [?\C-)])
+(define-key xterm-function-map "\e[27;6;42~" [?\C-*])
+(define-key xterm-function-map "\e[27;6;43~" [?\C-+])
+(define-key xterm-function-map "\e[27;6;58~" [?\C-:])
+(define-key xterm-function-map "\e[27;6;60~" [?\C-<])
+(define-key xterm-function-map "\e[27;6;62~" [?\C->])
+(define-key xterm-function-map "\e[27;6;63~" [(control ??)])
+
+;; These are the strings emitted for various C-M- combinations
+;; for keyboards that the Meta and Alt modifiers are on the same
+;; key (usually labeled "Alt").
+(define-key xterm-function-map "\e[27;13;9~" [C-M-tab])
+(define-key xterm-function-map "\e[27;13;13~" [C-M-return])
+
+(define-key xterm-function-map "\e[27;13;39~" [?\C-\M-\'])
+(define-key xterm-function-map "\e[27;13;44~" [?\C-\M-,])
+(define-key xterm-function-map "\e[27;13;45~" [?\C-\M--])
+(define-key xterm-function-map "\e[27;13;46~" [?\C-\M-.])
+(define-key xterm-function-map "\e[27;13;47~" [?\C-\M-/])
+(define-key xterm-function-map "\e[27;13;48~" [?\C-\M-0])
+(define-key xterm-function-map "\e[27;13;49~" [?\C-\M-1])
+(define-key xterm-function-map "\e[27;13;50~" [?\C-\M-2])
+(define-key xterm-function-map "\e[27;13;51~" [?\C-\M-3])
+(define-key xterm-function-map "\e[27;13;52~" [?\C-\M-4])
+(define-key xterm-function-map "\e[27;13;53~" [?\C-\M-5])
+(define-key xterm-function-map "\e[27;13;54~" [?\C-\M-6])
+(define-key xterm-function-map "\e[27;13;55~" [?\C-\M-7])
+(define-key xterm-function-map "\e[27;13;56~" [?\C-\M-8])
+(define-key xterm-function-map "\e[27;13;57~" [?\C-\M-9])
+(define-key xterm-function-map "\e[27;13;59~" [?\C-\M-\;])
+(define-key xterm-function-map "\e[27;13;61~" [?\C-\M-=])
+(define-key xterm-function-map "\e[27;13;92~" [?\C-\M-\\])
+
+(define-key xterm-function-map "\e[27;14;33~" [?\C-\M-!])
+(define-key xterm-function-map "\e[27;14;34~" [?\C-\M-\"])
+(define-key xterm-function-map "\e[27;14;35~" [?\C-\M-#])
+(define-key xterm-function-map "\e[27;14;36~" [?\C-\M-$])
+(define-key xterm-function-map "\e[27;14;37~" [?\C-\M-%])
+(define-key xterm-function-map "\e[27;14;38~" [?\C-\M-&])
+(define-key xterm-function-map "\e[27;14;40~" [?\C-\M-\(])
+(define-key xterm-function-map "\e[27;14;41~" [?\C-\M-\)])
+(define-key xterm-function-map "\e[27;14;42~" [?\C-\M-*])
+(define-key xterm-function-map "\e[27;14;43~" [?\C-\M-+])
+(define-key xterm-function-map "\e[27;14;58~" [?\C-\M-:])
+(define-key xterm-function-map "\e[27;14;60~" [?\C-\M-<])
+(define-key xterm-function-map "\e[27;14;62~" [?\C-\M->])
+(define-key xterm-function-map "\e[27;14;63~" [(control meta ??)])
+
+(define-key xterm-function-map "\e[27;7;9~" [C-M-tab])
+(define-key xterm-function-map "\e[27;7;13~" [C-M-return])
+
+(define-key xterm-function-map "\e[27;7;32~" [?\C-\M-\s])
+(define-key xterm-function-map "\e[27;7;39~" [?\C-\M-\'])
+(define-key xterm-function-map "\e[27;7;44~" [?\C-\M-,])
+(define-key xterm-function-map "\e[27;7;45~" [?\C-\M--])
+(define-key xterm-function-map "\e[27;7;46~" [?\C-\M-.])
+(define-key xterm-function-map "\e[27;7;47~" [?\C-\M-/])
+(define-key xterm-function-map "\e[27;7;48~" [?\C-\M-0])
+(define-key xterm-function-map "\e[27;7;49~" [?\C-\M-1])
+(define-key xterm-function-map "\e[27;7;50~" [?\C-\M-2])
+(define-key xterm-function-map "\e[27;7;51~" [?\C-\M-3])
+(define-key xterm-function-map "\e[27;7;52~" [?\C-\M-4])
+(define-key xterm-function-map "\e[27;7;53~" [?\C-\M-5])
+(define-key xterm-function-map "\e[27;7;54~" [?\C-\M-6])
+(define-key xterm-function-map "\e[27;7;55~" [?\C-\M-7])
+(define-key xterm-function-map "\e[27;7;56~" [?\C-\M-8])
+(define-key xterm-function-map "\e[27;7;57~" [?\C-\M-9])
+(define-key xterm-function-map "\e[27;7;59~" [?\C-\M-\;])
+(define-key xterm-function-map "\e[27;7;61~" [?\C-\M-=])
+(define-key xterm-function-map "\e[27;7;92~" [?\C-\M-\\])
+
+(define-key xterm-function-map "\e[27;8;33~" [?\C-\M-!])
+(define-key xterm-function-map "\e[27;8;34~" [?\C-\M-\"])
+(define-key xterm-function-map "\e[27;8;35~" [?\C-\M-#])
+(define-key xterm-function-map "\e[27;8;36~" [?\C-\M-$])
+(define-key xterm-function-map "\e[27;8;37~" [?\C-\M-%])
+(define-key xterm-function-map "\e[27;8;38~" [?\C-\M-&])
+(define-key xterm-function-map "\e[27;8;40~" [?\C-\M-\(])
+(define-key xterm-function-map "\e[27;8;41~" [?\C-\M-\)])
+(define-key xterm-function-map "\e[27;8;42~" [?\C-\M-*])
+(define-key xterm-function-map "\e[27;8;43~" [?\C-\M-+])
+(define-key xterm-function-map "\e[27;8;58~" [?\C-\M-:])
+(define-key xterm-function-map "\e[27;8;60~" [?\C-\M-<])
+(define-key xterm-function-map "\e[27;8;62~" [?\C-\M->])
+(define-key xterm-function-map "\e[27;8;63~" [(control meta ??)])
+
+(define-key xterm-function-map "\e[27;2;9~" [S-tab])
+(define-key xterm-function-map "\e[27;2;13~" [S-return])
+
+(define-key xterm-function-map "\e[27;6;9~" [C-S-tab])
+(define-key xterm-function-map "\e[27;6;13~" [C-S-return])
+
+;; Other versions of xterm might emit these.
+(define-key xterm-function-map "\e[A" [up])
+(define-key xterm-function-map "\e[B" [down])
+(define-key xterm-function-map "\e[C" [right])
+(define-key xterm-function-map "\e[D" [left])
+(define-key xterm-function-map "\e[1~" [home])
+
+(define-key xterm-function-map "\e[1;2A" [S-up])
+(define-key xterm-function-map "\e[1;2B" [S-down])
+(define-key xterm-function-map "\e[1;2C" [S-right])
+(define-key xterm-function-map "\e[1;2D" [S-left])
+(define-key xterm-function-map "\e[1;2F" [S-end])
+(define-key xterm-function-map "\e[1;2H" [S-home])
+
+(define-key xterm-function-map "\e[1;5A" [C-up])
+(define-key xterm-function-map "\e[1;5B" [C-down])
+(define-key xterm-function-map "\e[1;5C" [C-right])
+(define-key xterm-function-map "\e[1;5D" [C-left])
+(define-key xterm-function-map "\e[1;5F" [C-end])
+(define-key xterm-function-map "\e[1;5H" [C-home])
+
+(define-key xterm-function-map "\e[11~" [f1])
+(define-key xterm-function-map "\e[12~" [f2])
+(define-key xterm-function-map "\e[13~" [f3])
+(define-key xterm-function-map "\e[14~" [f4])
+
(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
+ ;; rxvt's keybindings 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
- (eval-and-compile (load "term/rxvt"))
- (terminal-init-rxvt))
+ (if (and (getenv "COLORTERM" (selected-frame))
+ (string-match "\\`rxvt" (getenv "COLORTERM" (selected-frame))))
+ (tty-run-terminal-initialization (selected-frame) "rxvt")
;; The terminal intialization C code file might have initialized
;; function keys F13->F60 from the termcap/terminfo information. On
@@ -46,358 +339,66 @@
;; function-key-map. This substitution is needed because if a key
;; definition is 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 [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)))
- ;; xterm from X.org 6.8.2 uses these key definitions.
- (define-key map "\eOP" [f1])
- (define-key map "\eOQ" [f2])
- (define-key map "\eOR" [f3])
- (define-key map "\eOS" [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 "\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[1;2P" [S-f1])
- (define-key map "\e[1;2Q" [S-f2])
- (define-key map "\e[1;2R" [S-f3])
- (define-key map "\e[1;2S" [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 "\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 "\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 "\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;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[2~" [insert])
- (define-key map "\e[3~" [delete])
- (define-key map "\e[5~" [prior])
- (define-key map "\e[6~" [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;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[4~" [select])
- (define-key map "\e[29~" [print])
-
- (define-key map "\eOj" [kp-multiply])
- (define-key map "\eOk" [kp-add])
- (define-key map "\eOl" [kp-separator])
- (define-key map "\eOm" [kp-subtract])
- (define-key map "\eOo" [kp-divide])
- (define-key map "\eOp" [kp-0])
- (define-key map "\eOq" [kp-1])
- (define-key map "\eOr" [kp-2])
- (define-key map "\eOs" [kp-3])
- (define-key map "\eOt" [kp-4])
- (define-key map "\eOu" [kp-5])
- (define-key map "\eOv" [kp-6])
- (define-key map "\eOw" [kp-7])
- (define-key map "\eOx" [kp-8])
- (define-key map "\eOy" [kp-9])
-
- ;; These keys are available in xterm starting from version 216
- ;; if the modifyOtherKeys resource is set to 1.
-
- (define-key map "\e[27;5;9~" [C-tab])
- (define-key map "\e[27;5;13~" [C-return])
- (define-key map "\e[27;5;39~" [?\C-\'])
- (define-key map "\e[27;5;44~" [?\C-,])
- (define-key map "\e[27;5;45~" [?\C--])
- (define-key map "\e[27;5;46~" [?\C-.])
- (define-key map "\e[27;5;47~" [?\C-/])
- (define-key map "\e[27;5;48~" [?\C-0])
- (define-key map "\e[27;5;49~" [?\C-1])
- ;; Not all C-DIGIT keys have a distinct binding.
- (define-key map "\e[27;5;57~" [?\C-9])
- (define-key map "\e[27;5;59~" [?\C-\;])
- (define-key map "\e[27;5;61~" [?\C-=])
- (define-key map "\e[27;5;92~" [?\C-\\])
-
- (define-key map "\e[27;6;33~" [?\C-!])
- (define-key map "\e[27;6;34~" [?\C-\"])
- (define-key map "\e[27;6;35~" [?\C-#])
- (define-key map "\e[27;6;36~" [?\C-$])
- (define-key map "\e[27;6;37~" [?\C-%])
- (define-key map "\e[27;6;38~" [?\C-&])
- (define-key map "\e[27;6;40~" [?\C-\(])
- (define-key map "\e[27;6;41~" [?\C-\)])
- (define-key map "\e[27;6;42~" [?\C-*])
- (define-key map "\e[27;6;43~" [?\C-+])
- (define-key map "\e[27;6;58~" [?\C-:])
- (define-key map "\e[27;6;60~" [?\C-<])
- (define-key map "\e[27;6;62~" [?\C->])
- (define-key map "\e[27;6;63~" [(control ??)])
-
- ;; These are the strings emitted for various C-M- combinations
- ;; for keyboards that the Meta and Alt modifiers are on the same
- ;; key (usually labeled "Alt").
- (define-key map "\e[27;13;9~" [C-M-tab])
- (define-key map "\e[27;13;13~" [C-M-return])
-
- (define-key map "\e[27;13;39~" [?\C-\M-\'])
- (define-key map "\e[27;13;44~" [?\C-\M-,])
- (define-key map "\e[27;13;45~" [?\C-\M--])
- (define-key map "\e[27;13;46~" [?\C-\M-.])
- (define-key map "\e[27;13;47~" [?\C-\M-/])
- (define-key map "\e[27;13;48~" [?\C-\M-0])
- (define-key map "\e[27;13;49~" [?\C-\M-1])
- (define-key map "\e[27;13;50~" [?\C-\M-2])
- (define-key map "\e[27;13;51~" [?\C-\M-3])
- (define-key map "\e[27;13;52~" [?\C-\M-4])
- (define-key map "\e[27;13;53~" [?\C-\M-5])
- (define-key map "\e[27;13;54~" [?\C-\M-6])
- (define-key map "\e[27;13;55~" [?\C-\M-7])
- (define-key map "\e[27;13;56~" [?\C-\M-8])
- (define-key map "\e[27;13;57~" [?\C-\M-9])
- (define-key map "\e[27;13;59~" [?\C-\M-\;])
- (define-key map "\e[27;13;61~" [?\C-\M-=])
- (define-key map "\e[27;13;92~" [?\C-\M-\\])
-
- (define-key map "\e[27;14;33~" [?\C-\M-!])
- (define-key map "\e[27;14;34~" [?\C-\M-\"])
- (define-key map "\e[27;14;35~" [?\C-\M-#])
- (define-key map "\e[27;14;36~" [?\C-\M-$])
- (define-key map "\e[27;14;37~" [?\C-\M-%])
- (define-key map "\e[27;14;38~" [?\C-\M-&])
- (define-key map "\e[27;14;40~" [?\C-\M-\(])
- (define-key map "\e[27;14;41~" [?\C-\M-\)])
- (define-key map "\e[27;14;42~" [?\C-\M-*])
- (define-key map "\e[27;14;43~" [?\C-\M-+])
- (define-key map "\e[27;14;58~" [?\C-\M-:])
- (define-key map "\e[27;14;60~" [?\C-\M-<])
- (define-key map "\e[27;14;62~" [?\C-\M->])
- (define-key map "\e[27;14;63~" [(control meta ??)])
-
- (define-key map "\e[27;7;9~" [C-M-tab])
- (define-key map "\e[27;7;13~" [C-M-return])
-
- (define-key map "\e[27;7;32~" [?\C-\M-\s])
- (define-key map "\e[27;7;39~" [?\C-\M-\'])
- (define-key map "\e[27;7;44~" [?\C-\M-,])
- (define-key map "\e[27;7;45~" [?\C-\M--])
- (define-key map "\e[27;7;46~" [?\C-\M-.])
- (define-key map "\e[27;7;47~" [?\C-\M-/])
- (define-key map "\e[27;7;48~" [?\C-\M-0])
- (define-key map "\e[27;7;49~" [?\C-\M-1])
- (define-key map "\e[27;7;50~" [?\C-\M-2])
- (define-key map "\e[27;7;51~" [?\C-\M-3])
- (define-key map "\e[27;7;52~" [?\C-\M-4])
- (define-key map "\e[27;7;53~" [?\C-\M-5])
- (define-key map "\e[27;7;54~" [?\C-\M-6])
- (define-key map "\e[27;7;55~" [?\C-\M-7])
- (define-key map "\e[27;7;56~" [?\C-\M-8])
- (define-key map "\e[27;7;57~" [?\C-\M-9])
- (define-key map "\e[27;7;59~" [?\C-\M-\;])
- (define-key map "\e[27;7;61~" [?\C-\M-=])
- (define-key map "\e[27;7;92~" [?\C-\M-\\])
-
- (define-key map "\e[27;8;33~" [?\C-\M-!])
- (define-key map "\e[27;8;34~" [?\C-\M-\"])
- (define-key map "\e[27;8;35~" [?\C-\M-#])
- (define-key map "\e[27;8;36~" [?\C-\M-$])
- (define-key map "\e[27;8;37~" [?\C-\M-%])
- (define-key map "\e[27;8;38~" [?\C-\M-&])
- (define-key map "\e[27;8;40~" [?\C-\M-\(])
- (define-key map "\e[27;8;41~" [?\C-\M-\)])
- (define-key map "\e[27;8;42~" [?\C-\M-*])
- (define-key map "\e[27;8;43~" [?\C-\M-+])
- (define-key map "\e[27;8;58~" [?\C-\M-:])
- (define-key map "\e[27;8;60~" [?\C-\M-<])
- (define-key map "\e[27;8;62~" [?\C-\M->])
- (define-key map "\e[27;8;63~" [(control meta ??)])
-
- (define-key map "\e[27;2;9~" [S-tab])
- (define-key map "\e[27;2;13~" [S-return])
-
- (define-key map "\e[27;6;9~" [C-S-tab])
- (define-key map "\e[27;6;13~" [C-S-return])
-
- ;; Other versions of xterm might emit these.
- (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 "\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 "\e[11~" [f1])
- (define-key map "\e[12~" [f2])
- (define-key map "\e[13~" [f3])
- (define-key map "\e[14~" [f4])
+ (substitute-key-definition [f13] [S-f1] local-function-key-map)
+ (substitute-key-definition [f14] [S-f2] local-function-key-map)
+ (substitute-key-definition [f15] [S-f3] local-function-key-map)
+ (substitute-key-definition [f16] [S-f4] local-function-key-map)
+ (substitute-key-definition [f17] [S-f5] local-function-key-map)
+ (substitute-key-definition [f18] [S-f6] local-function-key-map)
+ (substitute-key-definition [f19] [S-f7] local-function-key-map)
+ (substitute-key-definition [f20] [S-f8] local-function-key-map)
+ (substitute-key-definition [f21] [S-f9] local-function-key-map)
+ (substitute-key-definition [f22] [S-f10] local-function-key-map)
+ (substitute-key-definition [f23] [S-f11] local-function-key-map)
+ (substitute-key-definition [f24] [S-f12] local-function-key-map)
+
+ (substitute-key-definition [f25] [C-f1] local-function-key-map)
+ (substitute-key-definition [f26] [C-f2] local-function-key-map)
+ (substitute-key-definition [f27] [C-f3] local-function-key-map)
+ (substitute-key-definition [f28] [C-f4] local-function-key-map)
+ (substitute-key-definition [f29] [C-f5] local-function-key-map)
+ (substitute-key-definition [f30] [C-f6] local-function-key-map)
+ (substitute-key-definition [f31] [C-f7] local-function-key-map)
+ (substitute-key-definition [f32] [C-f8] local-function-key-map)
+ (substitute-key-definition [f33] [C-f9] local-function-key-map)
+ (substitute-key-definition [f34] [C-f10] local-function-key-map)
+ (substitute-key-definition [f35] [C-f11] local-function-key-map)
+ (substitute-key-definition [f36] [C-f12] local-function-key-map)
+
+ (substitute-key-definition [f37] [C-S-f1] local-function-key-map)
+ (substitute-key-definition [f38] [C-S-f2] local-function-key-map)
+ (substitute-key-definition [f39] [C-S-f3] local-function-key-map)
+ (substitute-key-definition [f40] [C-S-f4] local-function-key-map)
+ (substitute-key-definition [f41] [C-S-f5] local-function-key-map)
+ (substitute-key-definition [f42] [C-S-f6] local-function-key-map)
+ (substitute-key-definition [f43] [C-S-f7] local-function-key-map)
+ (substitute-key-definition [f44] [C-S-f8] local-function-key-map)
+ (substitute-key-definition [f45] [C-S-f9] local-function-key-map)
+ (substitute-key-definition [f46] [C-S-f10] local-function-key-map)
+ (substitute-key-definition [f47] [C-S-f11] local-function-key-map)
+ (substitute-key-definition [f48] [C-S-f12] local-function-key-map)
+
+ (substitute-key-definition [f49] [A-f1] local-function-key-map)
+ (substitute-key-definition [f50] [A-f2] local-function-key-map)
+ (substitute-key-definition [f51] [A-f3] local-function-key-map)
+ (substitute-key-definition [f52] [A-f4] local-function-key-map)
+ (substitute-key-definition [f53] [A-f5] local-function-key-map)
+ (substitute-key-definition [f54] [A-f6] local-function-key-map)
+ (substitute-key-definition [f55] [A-f7] local-function-key-map)
+ (substitute-key-definition [f56] [A-f8] local-function-key-map)
+ (substitute-key-definition [f57] [A-f9] local-function-key-map)
+ (substitute-key-definition [f58] [A-f10] local-function-key-map)
+ (substitute-key-definition [f59] [A-f11] local-function-key-map)
+ (substitute-key-definition [f60] [A-f12] local-function-key-map)
+
+ (let ((map (copy-keymap xterm-function-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))
+ (set-keymap-parent map (keymap-parent local-function-key-map))
+ (set-keymap-parent local-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)
@@ -430,7 +431,7 @@
(add-hook 'suspend-hook 'xterm-turn-off-modify-other-keys)
(add-hook 'suspend-resume-hook 'xterm-turn-on-modify-other-keys)
(add-hook 'kill-emacs-hook 'xterm-turn-off-modify-other-keys)
- (xterm-turn-on-modify-other-keys))))))))
+ (xterm-turn-on-modify-other-keys)))))))
;; Set up colors, for those versions of xterm that support it.
(defvar xterm-standard-colors
@@ -467,7 +468,7 @@ for the currently selected frame. The first 16 colors are taken from
`xterm-standard-colors', which see, while the rest are computed assuming
either the 88- or 256-color standard color scheme supported by latest
versions of xterm."
- (let* ((ncolors (display-color-cells))
+ (let* ((ncolors (display-color-cells (selected-frame)))
(colors xterm-standard-colors)
(color (car colors)))
(if (> ncolors 0)