Annotation of 43BSDReno/contrib/emacs-18.55/lisp/term/s4.el, revision 1.1

1.1     ! root        1: ;; Map s4 function key escape sequences
        !             2: ;; into the standard slots in function-keymap where we can;
        !             3: ;; set up terminal-specific bindings where we must
        !             4: ;;
        !             5: ;; by: Eric S. Raymond == {ihnp4,rutgers,seismo}!cbmvax!snark!eric
        !             6: 
        !             7: (require 'keypad)
        !             8: 
        !             9: ;; First, map as many keys as possible to terminal-independent keycaps
        !            10: 
        !            11: (defvar META-RB-map nil
        !            12:   "The META-RB-map maps the ESC-[ function keys on the s4 keyboard.")
        !            13: 
        !            14: (if (not META-RB-map)
        !            15:     (progn
        !            16:      (setq META-RB-map (lookup-key global-map "\e["))
        !            17:      (if (not (keymapp META-RB-map))
        !            18:         (setq META-RB-map (make-sparse-keymap)))  ;; <ESC>[ commands
        !            19: 
        !            20:      (setup-terminal-keymap META-RB-map
        !            21:            '(("A" . ?u)           ; up arrow
        !            22:              ("B" . ?d)           ; down-arrow
        !            23:              ("C" . ?r)           ; right-arrow
        !            24:              ("D" . ?l)           ; left-arrow
        !            25:              ("U" . ?N)           ; 'Page' -> next page
        !            26:              ("V" . ?P)           ; 'Shift-Page' -> prev page
        !            27:              ("H" . ?h)           ; 'Home' -> home-key
        !            28:        ;;    ("J" . ??)           ; 'Clear' -> unmapped
        !            29:        ))))
        !            30: 
        !            31: (defun enable-arrow-keys ()
        !            32:   "Enable the use of the s4 arrow keys for cursor motion.
        !            33: Because of the nature of the s4, this unavoidably breaks
        !            34: the standard Emacs command ESC [; therefore, it is not done by default,
        !            35: but only if you give this command in your .emacs."
        !            36:   (global-set-key "\e[" META-RB-map))
        !            37: 
        !            38: (defvar META-N-map nil
        !            39:   "META-N-map maps the ESC-N function keys on the s4 keyboard.")
        !            40: 
        !            41: (if (not META-N-map)
        !            42:     (progn
        !            43: 
        !            44:      (setq META-N-map (lookup-key global-map "\eN"))
        !            45:      (if (not (keymapp META-N-map))
        !            46:         (setq META-N-map (make-sparse-keymap)))  ;; <ESC>N commands
        !            47:      (setup-terminal-keymap META-N-map '(
        !            48:                ("a" . ?C)      ; 'Rfrsh' -> redraw screen
        !            49:        ;;      ("A" . ??)      ; 'Clear' -> unmapped
        !            50:        ;;      ("c" . ??)      ; 'Move' -> unmapped
        !            51:        ;;      ("d" . ??)      ; 'Copy' -> unmapped
        !            52:        ;;      ("B" . ??)      ; 'Shift-Beg' -> unmapped
        !            53:        ;;      ("M" . ??)      ; 'Shift-Home' -> unmapped
        !            54:        ;;      ("N" . ??)      ; 'Shift-End' -> unmapped
        !            55:                ("e" . ?k)      ; 'Dlete' -> generic delete (kill-region)
        !            56:                ("f" . ?.)      ; 'Dlete Char' -> keypad .
        !            57:                ("g" . ?1)      ; 'Prev' -> keypad 1 (backward-word)
        !            58:                ("h" . ?3)      ; 'Next' -> keypad 3 (forward-word)
        !            59:                ("i" . ?s)      ; 'Mark' -> select
        !            60:        ;;      ("I" . ??)      ; 'Select' -> MAPPED BELOW
        !            61:        ;;      ("j" . ??)      ; 'Input Mode' -> unmapped
        !            62:        ))
        !            63: 
        !            64:      (define-key global-map "\eN" META-N-map)))
        !            65: 
        !            66: (defvar META-O-map nil
        !            67:   "META-O-map maps the META-O function keys on the s4 keyboard.")
        !            68: 
        !            69: (if (not META-O-map)
        !            70:     (progn
        !            71: 
        !            72:      (setq META-O-map (lookup-key global-map "\eO"))
        !            73:      (if (not (keymapp META-O-map))
        !            74:         (setq META-O-map (make-sparse-keymap)))  ;; <ESC>O commands
        !            75:      (setup-terminal-keymap META-O-map '(
        !            76:                ("a" . ?E)      ; 'Clear-Line' -> Clear to EOL
        !            77:                ("A" . ?S)      ; 'Shift-Clear-Line' -> Clear to EOS
        !            78:                ("b" . ?\C-@)   ; 'Ref' -> function key 0
        !            79:                ("c" . ?\C-a)   ; 'F1' -> function key 1
        !            80:                ("d" . ?\C-b)   ; 'F2' -> function key 2
        !            81:                ("e" . ?\C-c)   ; 'F3' -> function key 3
        !            82:                ("f" . ?\C-d)   ; 'F4' -> function key 4
        !            83:                ("g" . ?\C-e)   ; 'F5' -> function key 5
        !            84:                ("h" . ?\C-f)   ; 'F6' -> function key 6
        !            85:                ("i" . ?\C-g)   ; 'F7' -> function key 7
        !            86:                ("j" . ?\C-h)   ; 'F8' -> function key 8
        !            87:        ;;      ("k" . ??)      ; 'Exit' -> MAPPED BELOW
        !            88:                ("m" . ??)      ; 'Help' -> help-command
        !            89:        ;;      ("n" . ??)      ; 'Creat' -> unmapped
        !            90:        ;;      ("o" . ??)      ; 'Save' -> MAPPED BELOW
        !            91:        ;;      ("r" . ??)      ; 'Opts' -> unmapped
        !            92:        ;;      ("s" . ??)      ; 'Undo' -> MAPPED BELOW
        !            93:                ("t" . ?x)      ; 'Redo' -> 'do' key
        !            94:        ;;      ("u" . ??)      ; 'Cmd' -> MAPPED BELOW
        !            95:        ;;      ("v" . ??)      ; 'Open' -> MAPPED BELOW
        !            96:        ;;      ("V" . ??)      ; 'Close' -> unmapped
        !            97:        ;;      ("w" . ??)      ; 'Cancel' -> MAPPED BELOW
        !            98:                ("x" . ?f)      ; 'Find' -> find/replace
        !            99:        ;;      ("y" . ??)      ; 'Rplac' -> MAPPED BELOW
        !           100:        ;;      ("z" . ??)      ; 'Print' -> MAPPED BELOW
        !           101:        ))
        !           102: 
        !           103:      (define-key global-map "\eO" META-O-map)))
        !           104: 
        !           105: (defvar META-P-map nil
        !           106:   "META-P-map maps the META-P function keys on the s4 keyboard.")
        !           107: 
        !           108: (if (not META-P-map)
        !           109:     (progn
        !           110: 
        !           111:      (setq META-P-map (lookup-key global-map "\eP"))
        !           112:      (if (not (keymapp META-P-map))
        !           113:         (setq META-P-map (make-sparse-keymap)))  ;; <ESC>P commands
        !           114:      (setup-terminal-keymap META-P-map '(
        !           115:                ("a" . ?1)      ; Ctrl-1 -> keypad 1
        !           116:                ("b" . ?2)      ; Ctrl-2 -> keypad 2
        !           117:                ("c" . ?3)      ; Ctrl-3 -> keypad 3
        !           118:                ("d" . ?4)      ; Ctrl-4 -> keypad 4
        !           119:                ("e" . ?5)      ; Ctrl-5 -> keypad 5
        !           120:                ("f" . ?6)      ; Ctrl-6 -> keypad 6
        !           121:                ("g" . ?7)      ; Ctrl-7 -> keypad 7
        !           122:                ("h" . ?8)      ; Ctrl-8 -> keypad 8
        !           123:                ("i" . ?9)      ; Ctrl-9 -> keypad 9
        !           124:                ("j" . ?0)      ; Ctrl-0 -> keypad 0
        !           125:                ("k" . ?-)      ; Ctrl-- -> keypad -
        !           126:        ))
        !           127: 
        !           128:      (define-key global-map "\eP" META-P-map)))
        !           129: 
        !           130: ;; Now do terminal-specific mappings of keys with no standard-keycap equivalent
        !           131: 
        !           132: ;;;(define-key esc-map "9" 'beginning-of-buffer)               ;'Begin'
        !           133: ;;;(define-key esc-map "0" 'end-of-buffer)                     ;'End'
        !           134: (define-key META-N-map "I" 'narrow-to-region)          ;'Select'
        !           135: (define-key META-O-map "k" 'save-buffers-kill-emacs)   ;'Exit'
        !           136: (define-key META-O-map "o" 'save-buffer)               ;'Save'
        !           137: (define-key META-O-map "s" 'undo)                      ;'Undo'
        !           138: (define-key META-O-map "u" 'execute-extended-command)  ;'Cmd'
        !           139: (define-key META-O-map "v" 'find-file)                 ;'Open'
        !           140: (define-key META-O-map "w" 'keyboard-quit)             ;'Cancl'
        !           141: (define-key META-O-map "y" 'replace-regexp)            ;'Rplac'
        !           142: (define-key META-O-map "z" 'lpr-buffer)                        ;'Print'

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.