[comp.unix.i386] Emacs key bindings for Interactive at386 console

dmocsny@uceng.UC.EDU (daniel mocsny) (11/29/89)

I believe some time ago, while I was half asleep, I saw in this group
a file GNU-emacs elisp-style key bindings for the system console
terminal type at386 that one gets with Interactive's 386/ix. At
the time, I wasn't interested, but now I am (funny how things
change). I found out how to determine the sent key codes for
the at386 keypad and function keys, using ctrl-q to quote keystrokes
in emacs. And no doubt after a few days' work I could figure out
how to set up some semi-intelligent key bindings for emacs, perhaps
by studying the existing .el files and plowing further into
Texinfo.

But being inherently lazy, and also under some pressure to actually
get some real work done now and then (what is the problem with bosses,
anyway), I thought I would cast myself on the public dole again.
So whoever might be the person in the know on this vital topic,
please do tell.

Severely yours,

Dan Mocsny				Snail:
Internet: dmocsny@uceng.UC.EDU		Dept. of Chemical Engng. M.L. 171
513/751-6824 (home)			University of Cincinnati
513/556-2007 (lab)			Cincinnati, Ohio 45221-0171
"We can help our young people get their values and priorities straight---
to look less to rock groups, soap stars, and athletes as role models and
more to Nobel Prize winners and teachers as ideals of human achievement."
	--- John F. Akers, Chairman, IBM corp., presuamably serious

drich@dialogic.UUCP (Dan Rich) (11/30/89)

Below you will find a copy of my term/at386.el file.  This binds the
keypad on an at386 terminal to the obvious definitions, F1 to help,
and also C-? to help (due to a conflict with F1 and another mode I am
working on).  The only "feature" of this that might be surprising is
the working of the home/end keys.  I have written these to be
compatable with a version of BRIEF that we use, and they act as follows:
Pressing home/end once: beginning/end of line
		  twice: beginning/end of screen
		  three times: beginning/end of file
This file will also remove C-h from help (backspace conflict), and
remap this to C-? (formerly undo).  I chose this because undo also can
be found on C-x u, and C-? is almost intuitive...

Dan Rich                    | ARPA: drich%dialogic@uunet.uu.net 
UNIX Systems Administrator  | UUCP: uunet!dialogic!drich
Dialogic Corporation        | - Time is an illusion.  Lunchtime, doubly so. -
(201) 334-8450 x213         |                           Douglas Adams

8<------------------------------ Cut Here ------------------------------>8
;;; $Id: at386.el,v 1.2 89/09/14 11:44:32 drich Exp $
;;;
;;; at386 keyboard definitions
;;; Dan Rich (drich@dialogic.UUCP)
;;; 21 August 1989
;;; $Log:	at386.el,v $
; Revision 1.2  89/09/14  11:44:32  drich
; Modified to tread DEL/BS correctly, also modified to use C-? for help.
; 
;;; Revision 1.1  89/09/14  11:06:16  drich
;;; Initial revision
;;; 
;;;
;;; Tested on: GNU Emacs 18.54.1 of Mon Jul 24 1989 on dialogic (usg-unix-v)
;;;
;;; 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")
(defvar last2 nil
  "Last key home/end, used in at386-home and at386-end")

(defun enable-at386-keys ()
  "Enable the use of the at386 function keys."
  (interactive)
  (global-set-key "\eO" AT386-map-1)
  (global-set-key "\e[" AT386-map-2))

(defun at386-home ()
  "Move cursor to top of screen."
  (interactive)
  (setq last last-command)
  (if (equal last 'at386-home)
      (if (equal last2 t)
	  (beginning-of-buffer)
	(progn
	  (move-to-window-line 0)
	  (setq last2 t)))
    (progn
      (beginning-of-line)
      (setq last2 nil))))

(defun at386-end ()
  "Move cursor to bottom of screen."
  (interactive)
  (setq last last-command)
  (if (equal last 'at386-end)
      (if (equal last2 t)
	  (end-of-buffer)
	(progn
	  (move-to-window-line -1)
	  (end-of-line)
	  (setq last2 t)))
    (progn
      (end-of-line)
      (setq last2 nil))))

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

(defun line-to-bottom ()
  (interactive)
  (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)

(if AT386-map-1
    nil
  (setq AT386-map-1 (make-keymap))   ; <ESC>O commands
  (setup-terminal-keymap AT386-map-1
			 '(("P" . ??)   ; F1 (help-map)
			   )))

(if AT386-map-2
    nil
  (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)
			   )))

(enable-at386-keys)

;; Change the keyboard translation to interpret:
;; C-h as DEL
;; C-? as C-h (actually C-? generates C-_)
(setq keyboard-translate-table
      "\000\^a\^b\^c\^d\^e\^f\^g\^?\^i\^j\^k\^l\^m\^n\^o\^p\^q\^r\^s\^t\^u\^v\^w\^x\^y\^z\^[\034\^]\035\^h")
-- 
Dan Rich                    | ARPA: drich%dialogic@uunet.uu.net 
UNIX Systems Administrator  | UUCP: uunet!dialogic!drich
Dialogic Corporation        | - Time is an illusion.  Lunchtime, doubly so. -
(201) 334-8450 x213         |                           Douglas Adams

dmocsny@uceng.UC.EDU (daniel mocsny) (12/02/89)

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@skybridge.SCL.CWRU.Edu

Dan,

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.

		Steve

;;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@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
bindings.

---------------------- cut ---------------------------------------
;;; at386.el
;;; Texas Microsystems at386 keyboard definitions
;;; Dan Rich (drich@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."
  (interactive)
  (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"
  (interactive)
  (beginning-of-line 1))

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

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

(defun line-to-bottom ()
  (interactive)
  (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
    nil
  (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
    nil
  (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)
                           )))
(enable-at386-keys)

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

-Dan

Dan Brotherton   RJE Communications, Inc.  Sunnyvale, CA
dcb@keragee.UUCP || dcb@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 :-))

Tom



(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)
(display-time)
(setq truncate-lines 1)

allbery@NCoast.ORG (Brandon S. Allbery) (12/03/89)

As quoted from <3005@uceng.UC.EDU> by dmocsny@uceng.UC.EDU (daniel mocsny):
+---------------
| 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?
+---------------

RMS doesn't like System V, so he won't include System V diffs unless they're
ready-to-install into his source tree and don't break anything else.  (Hmph.
Followups to alt.religion.computers.)

++Brandon
-- 
Brandon S. Allbery    allbery@NCoast.ORG, BALLBERY (MCI Mail), ALLBERY (Delphi)
uunet!hal.cwru.edu!ncoast!allbery ncoast!allbery@hal.cwru.edu bsa@telotech.uucp
*(comp.sources.misc mail to comp-sources-misc[-request]@backbone.site, please)*
*Third party vote-collection service: send mail to allbery@uunet.uu.net (ONLY)*
expnet.all: Experiments in *net management and organization.  Mail me for info.