emacs keymap for AT386?

Marco S Hyman marc at dumbcat.sf.ca.us
Thu Sep 20 14:35:33 AEST 1990


In article <22073 at grebyn.com> ckp at grebyn.UUCP (Checkpoint Technologies) writes:
    Has anyone implemented an AT386 keymap for GNU emacs? I'd like to
    be able to use the arrows, to use Page Up and Page Down, and I'd like
    Alt to work for Meta.  I'm willing to sacrifice the Meta-[ current
    functionality.  I'm using Interactive Unix 2.2.  Thanks.
    

I keep this as at386 and AT386 in .../emacs/lisp/term.

(enjoy)

// marc

;; @(#) at386.el 22jul90 marc at dumbcat.sf.ca.us
;; Map AT386 cursor movement, function, and alt key sequences
;;
;; There were two ways to go in creating this file.  The first was to copy
;; the vt100 example using the keypad functions, the other was to copy the
;; sun example and map things direct.  I went with the sun example because I
;; use a sun at work and prefer the set-ups to be similar.

(defun unbound-key ()
  "Placeholder for undefined keys."
  (interactive)
  (error "unbound-key"))

(defun scroll-up-n (n)
  "Scroll up n (defualt 1) line."
  (interactive "p")
  (scroll-up n))

(defun scroll-down-n (n)
  "Scroll down n (defualt 1) line."
  (interactive "p")
  (scroll-down n))

;; define the pc cursor key keymap and bind it to the existing ESC-[ map or
;; a new keymap if no existing ESC-[ map.  Assign default values.

(defvar pc-cursor-map nil
  "keymap for the cursor movement keys on pc style keyboards.")

(if (not pc-cursor-map)
    (progn
     (setq pc-cursor-map (lookup-key global-map "\e["))
     (if (not (keymapp pc-cursor-map))
	 (setq pc-cursor-map (make-sparse-keymap)))))

(define-key pc-cursor-map "@" 'yank)			; insert
(define-key pc-cursor-map "A" 'previous-line)		; up-arrow
(define-key pc-cursor-map "B" 'next-line)		; down-arrow
(define-key pc-cursor-map "C" 'forward-char)		; right-arrow
(define-key pc-cursor-map "D" 'backward-char)		; left-arrow
(define-key pc-cursor-map "G" 'recenter)		; keypad 5
(define-key pc-cursor-map "H" 'beginning-of-buffer)	; home
(define-key pc-cursor-map "S" 'unbound-key)		; keypad minus
(define-key pc-cursor-map "T" 'unbound-key)		; keypad plus
(define-key pc-cursor-map "U" 'scroll-up)		; page down
(define-key pc-cursor-map "V" 'scroll-down)		; page up
(define-key pc-cursor-map "Y" 'end-of-buffer)		; end

;; define the pc function key keymap and bind it to the existing ESC-O map or
;; a new keymap if no existing ESC-O map.  Assign default values.

(defvar pc-function-map nil
  "keymap for the function keys on a pc style keyboard.")

(if (not pc-function-map)
    (progn
     (setq pc-function-map (lookup-key global-map "\eO"))
     (if (not (keymapp pc-function-map))
	 (setq pc-function-map (make-sparse-keymap)))))

(define-key pc-function-map "P" 'unbound-key)		; F1
(define-key pc-function-map "Q" 'unbound-key)		; F2
(define-key pc-function-map "R" 'scroll-down-n)		; F3
(define-key pc-function-map "S" 'scroll-up-n)		; F4
(define-key pc-function-map "T" 'shell)			; F5
(define-key pc-function-map "U" 'shrink-window)		; F6
(define-key pc-function-map "V" 'enlarge-window)	; F7
(define-key pc-function-map "W" 'unbound-key)		; F8
(define-key pc-function-map "X" 'unbound-key)		; F9
(define-key pc-function-map "Y" 'unbound-key)		; F10
(define-key pc-function-map "Z" 'unbound-key)		; F11
(define-key pc-function-map "A" 'unbound-key)		; F12
(define-key pc-function-map "p" 'unbound-key)		; shift-F1
(define-key pc-function-map "q" 'unbound-key)		; shift-F2
(define-key pc-function-map "r" 'unbound-key)		; shift-F3
(define-key pc-function-map "s" 'unbound-key)		; shift-F4
(define-key pc-function-map "t" 'unbound-key)		; shift-F5
(define-key pc-function-map "u" 'unbound-key)		; shift-F6
(define-key pc-function-map "v" 'unbound-key)		; shift-F7
(define-key pc-function-map "w" 'unbound-key)		; shift-F8
(define-key pc-function-map "x" 'unbound-key)		; shift-F9
(define-key pc-function-map "y" 'unbound-key)		; shift-F10
(define-key pc-function-map "z" 'unbound-key)		; shift-F11
(define-key pc-function-map "a" 'unbound-key)		; shift-F12

;; Enable the just defined pc cursor and function keys.  Note that the
;; existing ESC-[ is mapped to ESC-[[.  There is no existing ESC-O to get
;; remapped.

(define-key esc-map "[" pc-cursor-map)
(define-key esc-map "[[" 'backward-paragraph)
(define-key esc-map "O" pc-function-map)

;; since .emacs gets loaded BEFORE this file a hook is provided to add local
;; bindings to the cursor and function maps.  An example entry in your
;; .emacs might look like.
;; (setq at386-term-hook 
;;   '((define-key pc-function-map "P" 'goto-line)
;;     (define-key pc-function-map "Q" 'what-line)))

(defvar at386-term-hook nil
  "At386 startup hook to modify default key bindings.")

(run-hooks 'at386-term-hook)

;; should map \eN as an additional META key -- would allow alt-x to work where
;; esc-x works now.
-- 
// marc at dumbcat.sf.ca.us
// {ames,decwrl,sun}!pacbell!dumbcat!marc



More information about the Comp.unix.sysv386 mailing list