[comp.sys.ibm.pc] MicroEMACS Key Bindings for VT220 -- Here They Are

low@melair.UUCP (Rick Low) (03/28/89)

OK, OK, stop sending mail.  :-)  Here is my emacs.rc (or .emacsrc)
for a VT220 terminal.  It is hereby released into the public domain.

I wrote it for a VT320 but I use it in "VT300 mode, 7-bit
controls", which my VT320 manual says is compatible with a VT220.
This is for all you people like me that have ported MicroEMACS
to your VAXes and UNIX boxes so that you could have a consistent
editor interface across MS-DOS, VMS, and UNIX machines.

I didn't implement any of the top row of function keys on the LK201
keyboard (except Help and Do) or the numeric keypad keys;
I just never saw the need.  It's easy enough to do.

This probably belongs in comp.emacs, but the original question was
asked here, and besides, in comp.emacs this stuff would be lost
in the GNUoise.


QUICK EXPLANATION OF uEMACS 3.9e BINDINGS FOR VT220

Bindings That I Removed

^S	- conflict with XOFF (bound to nop)
^Q	- conflict with XON (bound to nop)
M-^S	- conflict with XOFF
^X^S	- conflict with XOFF


New Bindings for VT220 with LK201

^/	- incremental-search
^\	- reverse-incremental-search
M-/	- hunt-forward
M-\	- hunt-backward
^]	- clear replace string (allows search & replace to be used
	  as delete too)
M-.	- save-file and exit-emacs
^XQ	- quote-character (replaces ^Q)
M-S	- search-forward (replaces ^S)
M-J	- change-screen-size (replaces M-^S)
M-O	- save file (replaces ^X^S)


Arrow and Editing Key Bindings

arrows		- next-line, previous-line, forward-character, 
		  backward-character
Find		- hunt-forward
Insert Here	- yank (same as ^Y)
Help		- help
Do		- execute-command-line
Remove		- kill-region (same as ^W)
Select		- set-mark
Prev Screen	- previous-page
Next Screen	- next-page


Modes Added Automatically on Startup

- magic, asave
- cmode set if filename ends in .c or .h


------------------------- cut here -------------------------------
; .emacsrc -- MicroEMACS startup command file for VT320 terminal
; 25 Nov 88  Rick Low  MEL DSL Ottawa

set $discmd FALSE

; new key bindings

; - formerly unbound functions

bind-to-key	incremental-search	^_	; really ^/ on VT220
bind-to-key	reverse-incremental-search ^\
bind-to-key	hunt-forward		M-/
bind-to-key	hunt-backward		M-\
bind-to-key	execute-macro-8		^]	; clear replace string
bind-to-key	execute-macro-9		M-.	; save file & exit

; - work around overloading of ^S and ^Q

;unbind-key	^S			; rebind ^S and ^Q to nop
;unbind-key 	^Q			;   so XOFF and XON will
bind-to-key 	nop		^S	;   not cause
bind-to-key	nop		^Q	;   any grief

unbind-key 	M-^S			; unbind any other functions that
unbind-key 	^X^S			;   use ^S or ^Q

bind-to-key	quote-character		^XQ	; replaces ^Q
bind-to-key	search-forward		M-S	; replaces ^S
bind-to-key	change-screen-size	M-J	; replaces M-^S
bind-to-key	save-file		M-O	; replaces ^X^S

; - keypad arrows

bind-to-key	next-line		FNB
bind-to-key	previous-line		FNA
bind-to-key	forward-character	FNC
bind-to-key	backward-character	FND

; - some LK201 function keys in VT300 mode

bind-to-key execute-macro-1	FN1	; Find		- hunt-forward
bind-to-key execute-macro-2	FN2
;				FN2~	  Insert Here	- yank
;				FN28~	  Help		- help
;				FN29~	  Do		- execute-command-line
bind-to-key execute-macro-3	FN3	; Remove	- kill-region
bind-to-key execute-macro-4	FN4	; Select	- set-mark
bind-to-key execute-macro-5	FN5	; Prev Screen	- previous-page
bind-to-key execute-macro-6	FN6	; Next Screen	- next-page

; handle Find

1	store-macro
	set %rctemp &gtk
	!if &equ %rctemp "~"
		hunt-forward
	!else
		write-message "[Key not Bound]"
	!endif
!endm

; handle Insert Here, Help, or Do

2	store-macro
	set %rctemp &gtk
	!if &equ %rctemp "~"	; Insert Here
		yank
	!else
		!if &equ %rctemp "8"
			set %rctemp &gtk
			!if &equ %rctemp "~"	; Help
				help
			!else
				write-message "[Key not Bound]"
			!endif
		!else
			!if &equ %rctemp "9"
				set %rctemp &gtk
				!if &equ %rctemp "~"	; Do
					execute-command-line @"execute-command-line: "
				!else
					write-message "[Key not Bound]"
				!endif
			!else
				write-message "[Key not Bound]"
			!endif
		!endif
	!endif
!endm

; handle Remove

3	store-macro
	set %rctemp &gtk
	!if &equ %rctemp "~"
		kill-region
	!else
		write-message "[Key not Bound]"
	!endif
!endm

; handle Select

4	store-macro
	set %rctemp &gtk
	!if &equ %rctemp "~"
		set-mark
	!else
		write-message "[Key not Bound]"
	!endif
!endm

; handle Prev Screen

5	store-macro
	set %rctemp &gtk
	!if &equ %rctemp "~"
		previous-page
	!else
		write-message "[Key not Bound]"
	!endif
!endm

; handle Next Screen

6	store-macro
	set %rctemp &gtk
	!if &equ %rctemp "~"
		next-page
	!else
		write-message "[Not Bound]"
	!endif
!endm

; set CMODE automatically

7	store-macro
	; manual is wrong for &rig; actual usage is
	;	&rig <string> <start position>
	set %rctemp &rig $cfname &sub &len $cfname 1
	!if &or &seq %rctemp ".c" &seq %rctemp ".h"
		add-mode "CMODE"
	!endif
!endm

; clear replace string (to allow replace to be used as delete)

8	store-macro
	set $replace ""
	write-message "replace string cleared"
!endm

; save file and exit

9	store-macro
	save-file
	exit-emacs
!endm

bind-to-key execute-macro-7	M-FNR	; run automaticlly after startup

add-global-mode "magic"
add-global-mode "asave"
set $discmd TRUE
----------------------------- cut here --------------------------------

Rick Low
MEL Defence Systems Limited, Ottawa, Canada
+1 613 836 6860
UUCP: uunet!mitel!melair!low