john@axis-design.fr (John Hughes) (03/11/91)
I keep seeing lisp/term files that do function keys the wrong way. Why does everyone seem to have an unreasoning horror of ``function-keymap'' ? Have a look at keypad.el for instructions on how to set up your terminal function keys so people can use them in a terminal-independant way. Have a look at term/vt100.el for an example. Once you have mapped the terminal function keys to `function-keymap' entries the user can pick his own bindings for the function keys which will work on any terminal. (Except suns and AT&T Unixpc's 'cos the people who wrote the term files didn't do it right). By the way, here is my `at386.el' that I use on my Interactive unix system console. ;; Map AT386 function key escape sequences ;; into the standard slots in function-keymap. (require 'keypad) (defvar CSI-map nil "The CSI-map maps the CSI function keys on the AT386 keyboard. The CSI keys are the arrow keys. (This breaks ESC-[).") (if (not CSI-map) (progn (setq CSI-map (lookup-key global-map "\e[")) (if (not (keymapp CSI-map)) (setq CSI-map (make-sparse-keymap))) ;; <ESC>[ commands (setup-terminal-keymap CSI-map '(("@" . ?I) ; Insert ("A" . ?u) ; up arrow ("B" . ?d) ; down-arrow ("C" . ?r) ; right-arrow ("D" . ?l) ; left-arrow ("G" . ?5) ; keypad 5 ("H" . ?h) ; Home ("S" . ?-) ; keypad - ("T" . ?+) ; keypad + ("U" . ?N) ; Page up ("V" . ?P) ; Page down ("Y" . ?H))) ; End (define-key global-map "\e[" CSI-map))) (defvar SS3-map nil "SS3-map maps the SS3 function keys on the AT386 keyboard. The SS3 keys are the function keys.") (if (not SS3-map) (progn (setq SS3-map (lookup-key global-map "\eO")) (if (not (keymapp SS3-map)) (setq SS3-map (make-keymap))) ;; <ESC>O commands (setup-terminal-keymap SS3-map '(("P" . ?\C-a) ; F1 ("Q" . ?\C-b) ; F2 ("R" . ?\C-c) ; F3 ("S" . ?\C-d) ; F4 ("T" . ?\C-e) ; F5 ("U" . ?\C-f) ; F6 ("V" . ?\C-g) ; F7 ("W" . ?\C-h) ; F8 ("X" . ?\C-i) ; F9 ("Y" . ?\C-j) ; F10 ("Z" . ?\C-k) ; F11 ("A" . ?\C-l) ; F12 ("p" . ?\C-m) ; SF1 ("q" . ?\C-n) ; SF2 ("r" . ?\C-o) ; SF3 ("s" . ?\C-p) ; SF4 ("t" . ?\C-q) ; SF5 ("u" . ?\C-r) ; SF6 ("v" . ?\C-s) ; SF7 ("w" . ?\C-t) ; SF8 ("x" . ?\C-u) ; SF9 ("y" . ?\C-v) ; SF10 ("z" . ?\C-w) ; SF11 ("a" . ?\C-x))) ; SF12 (define-key global-map "\eO" SS3-map))) ;; Now we should make the ALT key be a META key, ALT + x => ESC N x ;; But how can we do that??