Emacs key bindings for Interactive at386 console

daniel mocsny dmocsny at uceng.UC.EDU
Sat Dec 2 06:47:01 AEST 1989

Hello net.

I received several responses to my request for GNU emacs key-bindings
suitable for an at386 terminal type (such as the Interactive 386/ix
system console). (Thank you, thank you all!) I also received many
requests for whatever answers I received, so I am posting a summary.

I also received several pleas for help in installing GNU emacs under
386/ix. I know it can be done, but I don't know how (a friend installed
it for me, and I haven't diff'ed my way through his directory tree
to see what he did). So eventually I will figure out to install
GNU emacs, and if I'm feeling extremely generous I might even post.
(What? Contribute something instead of just sponge off others'
generosity? Hah!)

But I have to believe that dozens, perhaps hundreds, of you must
already know how to install GNU emacs. So if someone would be so kind
as to give a few hints, that would be great.

Furthermore, I have to wonder why installing GNU emacs should be a
problem at all. Surely 386/ix users represent a sizable fraction of
FSF/GNU's virtual customer base. So why doesn't the emacs distribution
have the files already prepared that you need to compile under 386/ix?
Huh? If anybody has made these files, howzabout sending them to FSF?

'Nuff outta me. Here's what I got from everyone else:

From: izen386!steve at skybridge.SCL.CWRU.Edu


Here are the bindings that I wrote.  The page up and page down keys work
under the xterm environment, not the at386.  It shouldn't be too difficult
to add the code to make them work under the at386 environment.  Just add
another keymap for esc-N-~.  If I ever get around to doing it I'll send
you the elisp.


;;Kludges by Steve Izen (skybridge.scl.cwru.edu!izen386!steve)
;;makes the xterm cursor keys work independently of application cursor state
(defvar esc-O-map (make-keymap)
  "Keymap for subcommands of ESC O")
(fset 'esc-O-prefix esc-O-map)
(define-key esc-map "O" 'esc-O-prefix)
(define-key esc-O-map "B" 'next-line)
(define-key esc-O-map "A" 'previous-line)
(define-key esc-O-map "C" 'forward-char)
(define-key esc-O-map "D" 'backward-char)
(defvar esc-lb-map (make-keymap)
  "Keymap for subcommands of ESC [")
(fset 'esc-lb-prefix esc-lb-map)
(define-key esc-map "[" 'esc-lb-prefix)
(define-key esc-lb-map "B" 'next-line)
(define-key esc-lb-map "A" 'previous-line)
(define-key esc-lb-map "C" 'forward-char)
(define-key esc-lb-map "D" 'backward-char)
(define-key esc-lb-map "U" 'scroll-up)
(define-key esc-lb-map "V" 'scroll-down)
(define-key esc-lb-map "H" 'beginning-of-line)
(define-key esc-lb-map "Y" 'end-of-line)

;; kludge to remap AT386 alt keys as meta keys- redirect esc-N as esc.
(fset 'myesc-prefix esc-map)
(define-key esc-map "N" 'myesc-prefix)

(put 'eval-expression 'disabled nil)

From: keragee!dcb at apple.com (Dan Brotherton)
Subject: Emacs key bindings for Interactive at386 console

Here is the at386.el I use. Note it also needs to be linked to AT386
due to an oddity in 386/ix. The original code was from somebody else.
I've tweaked it a fair amount, especially as to the function key

---------------------- cut ---------------------------------------
;;; at386.el
;;; Texas Microsystems at386 keyboard definitions
;;; Dan Rich (drich at dialogic.UUCP)
;;; 21 August 1989
;;; Tested on: GNU Emacs 18.54.1 of Mon Jul 24 1989 on dialogic (usg-unix-v)
;;; --> I'm using it on 18.55 dcb
;;; Note: The shift key will affect the value of a function key, but
;;; the control and alt keys do not.
;;; Most of the information needed to create this file was taken from
;;; documentation found in lisp/keypad.el

(require 'keypad)

(defvar AT386-map-1 nil
  "The map for the function keys on the at386")
(defvar AT386-map-2 nil
  "The keypad map for the at386")

(defun enable-at386-keys ()
  "Enable the use of the at386 function keys."
  (global-set-key "\eO" AT386-map-1)
  (global-set-key "\e[" AT386-map-2)
  (global-unset-key "")                       ; help
  (global-set-key "" 'backward-delete-char)
  (global-unset-key "\C-xm"))                   ; mail

(defun at386-home ()
  "Move cursor to beginning of line"
  (beginning-of-line 1))

(defun at386-end ()
  "Move cursor to end of line"
  (end-of-line 1))

(defun line-to-top ()
  (recenter 0))

(defun line-to-bottom ()
  (recenter (- (window-height) 2)))

;;; Create a few new keypad defaults.  Here's what I think I'm doing here:
;;; I look through "keypad.el" to find any unused entries in function-keymap
;;; and then create my own bindings for them here.  Then I use the newly
;;; created ?x string in the setup-terminal-keymap.

(define-key function-keymap "1" 'at386-end)
(define-key function-keymap "3" 'scroll-down)
(define-key function-keymap "5" 'recenter)
(define-key function-keymap "7" 'at386-home)
(define-key function-keymap "9" 'scroll-up)
(define-key function-keymap "-" 'line-to-top)
(define-key function-keymap "+" 'line-to-bottom)
(define-key function-keymap "W" 'toggle-truncate-lines)
(define-key function-keymap "Y" 'gnus)
(define-key function-keymap "A" 'vm)
(define-key function-keymap "Z" 'mail)

(if AT386-map-1
  (setq AT386-map-1 (make-keymap))   ; <ESC>O commands
  (setup-terminal-keymap AT386-map-1
                         '(("P" . ??)   ; F1  (help-map)
			   ("W" . ?W)   ; F8  (toggle-truncate-lines)
			   ("Y" . ?Y)   ; F10 (gnus)
                           ("Z" . ?Z)   ; F11 (mail)
                           ("A" . ?A)   ; F12 (vm)

(if AT386-map-2
  (setq AT386-map-2 (make-keymap))   ; <ESC>[ commands
  (setup-terminal-keymap AT386-map-2
                         '(("A" . ?u)   ; Up Arrow (previous-line)
                           ("B" . ?d)   ; Down Arrow (next-line)
                           ("C" . ?r)   ; Right Arrow (forward-char)
                           ("D" . ?l)   ; Left Arrow (backward-char)
                           ("H" . ?7)   ; Home (move-to-window-line 0)
                           ("Y" . ?1)   ; End (move-to-window-line -1)
                           ("G" . ?5)   ; Clear (recenter)
                           ("U" . ?9)   ; Page up (scroll-down)
                           ("V" . ?3)   ; Page down (scroll-up)
                           ("S" . ?-)   ; - key (line-to-top)
                           ("T" . ?+)   ; + key (line-to-bottom)
                           ("@" . ?I)   ; Insert (insert-character)

---------------------- cut ---------------------------------------


Dan Brotherton   RJE Communications, Inc.  Sunnyvale, CA
dcb at keragee.UUCP || dcb at nimikos.UUCP || apple!mrspoc!keragee!dcb

From: jdyx!tpf (Tom Friedel)
Subject: Re: Emacs key bindings for Interactive at386 console

Here is my .emacs.  If you get a good file for binding Meta
to the Alt key I'd be interested  (but only after you get it
to work :-))


(put 'eval-expression 'disabled nil)
(auto-save-mode nil)

;;; Primitive but effective at386.el sets up convenient key bindings for
;;; using Gnu Emacs on the at386 keyboard brought to you by Larry A. Shurr.

;;; To use, place this file in the Gnu Emacs lisp/term directory (usually
;;; "/usr/local/emacs/lisp/term").

;;; How to get a key mapping if you want to bind a function to it:
;;; Enter help (normally ctl-h key), then 'k' (for keyboard binding),
;;; then the key you are interested in.  If the key is already bound, its
;;; mapping is displayed only briefly in the minibuffer at the bottom of
;;; the screen before it is erased and a description of the function is
;;; displayed in a help window.  In order to get a good look at the map-
;;; ping, you may have to both global-unset-key and local-unset-key that
;;; key first.  If the key is not bound, Gnu Emacs will display the
;;; message "<key mapping> is undefined" where <key mapping> is a descrip-
;;; tion of what Emacs saw when you struck the key you are interested in.
;;; For instance, the "Home" key would be displayed as: "ESC [ H" which
;;; you encode for elisp as "\M-[H".

(global-unset-key "\M-[")                      ; Lose default meta-[ binding
                                               ; (normally backward-paragraph)

                                               ; Key
(global-set-key "\M-[@"  'overwrite-mode)      ; Insert (toggles insert mode)
(global-set-key "\M-[A"  'previous-line)       ; Up-arrow
(global-set-key "\M-[B"  'next-line)           ; Down-arrow
(global-set-key "\M-[C"  'forward-char)        ; Right-arrow
(global-set-key "\M-[D"  'backward-char)       ; Left-arrow
(global-set-key "\M-[H"  'beginning-of-line)   ; Home
(global-set-key "\M-[P"  'delete-char)         ; Delete (not the Del key)
(global-set-key "\M-[U"  'scroll-up)           ; Page down
(global-set-key "\M-[V"  'scroll-down)         ; Page Up
(global-set-key "\M-[Y"  'end-of-line)         ; End
(global-set-key "\M-oP"  'scroll-up)           ; F1  (Page down)
(global-set-key "\M-oQ"  'scroll-down)         ; F2  (Page up)
(global-set-key "\M-oR"  'set-mark-command)    ; F3  (Set mark)
(global-set-key "\M-oS"  'kill-region)         ; F4  (Kill region)
(global-set-key "\M-oT"  'yank)                ; F5  (Yank back)
;(global-set-key "\M-oU"  '<foo>)              ; F6
;(global-set-key "\M-oV"  '<foo>)              ; F7
;(global-set-key "\M-oW"  '<foo>)              ; F8
;(global-set-key "\M-oX"  '<foo>)              ; F9
(global-set-key "\M-oY"  'other-window)        ; F10 (next window)
(global-set-key "\M-oZ"  'beginning-of-buffer) ; F11 (Go to beginning of file)
(global-set-key "\M-oA"  'end-of-buffer)       ; F12 (Go to end of file)

(put 'narrow-to-page 'disabled nil)
(setq truncate-lines 1)

More information about the Comp.unix.i386 mailing list