[comp.emacs] Function Keys in MG2a

davidm@cimshop.UUCP (David Masterson) (09/20/89)

I am using MG2a on a VMS system and am trying to figure out how to activate
the function keys on my terminal.  I am more used to the manner that
MicroEmacs 3.9e used for function keys, so the mechanism in MG2a is rather
daunting.  Can anyone help me understand what switches need to be compiled in,
how to attach a command to a function key (something of the form '^[[nn~' or
'^[Oa'), what 'define-key', 'global-set-key', and 'local-set-key' are for, and
how to set things up in a startup file ('.mg'?)?  In MicroEmacs 3.9e, I
basically taught (read hacked) it to treat '^[[' and '^[O' as function key
starters and then had it interpret the rest, but the MG2a implementation looks
significantly different (I get the feeling I'm missing something important).
Any help??

David Masterson
uunet!cimshop!davidm

mic@ut-emx.UUCP (Mic Kaczmarczik) (09/20/89)

In article <467@cimshop.UUCP> davidm@cimshop.UUCP (David Masterson) writes:
>
>I am using MG2a on a VMS system and am trying to figure out how to activate
>the function keys on my terminal.  I am more used to the manner that
>MicroEmacs 3.9e used for function keys, so the mechanism in MG2a is rather
>daunting.  Can anyone help me understand what switches need to be compiled in,
>how to attach a command to a function key (something of the form '^[[nn~' or
>'^[Oa'), what 'define-key', 'global-set-key', and 'local-set-key' are for, and
>how to set things up in a startup file ('.mg'?)?

>David Masterson
>uunet!cimshop!davidm

You need to compile MG 2a with XKEYS defined.  After that, MG will
look for a file called .mg-TERM, where TERM is the value of the
logical name TERM (e.g. .mg-vt100 for a vt100 terminal type). If
found, it will read and evaluate that file just like .mg.  This allows
you to have different function key setups for different terminals,
albeit in a slightly different manner than GNU Emacs does.

I've included an example .mg-vt100 below, which defines the arrow keys
in VT100 application mode.  For more information, look in
[.SYS.DEFAULT]README, which also explains the termcap terminal driver. 

Mic Kaczmarczik

---------------------------------------------------------------------
;
; Example key definition file for VT100 terminals using the termcap
; driver. This only works if XKEYS is defined during compilation.
;
(global-set-key "\eOA" 'previous-line)	; up arrow
(global-set-key "\eOB" 'next-line)	; down arrow
(global-set-key "\eOC" 'forward-char)	; right arrow
(global-set-key "\eOD" 'backward-char)	; left arrow
------------------------------------------------------------------------ 
Mic Kaczmarczik					   Internet: mic@emx.utexas.edu
Unix/VMS Services 				   BITNET: MIC@UTAIVC
UT Austin Computation Center			   THEnet: UTAIVC::MIC

     Don't worry about life, son. It ain't nohow permanent.  -- Walt Kelly

davidm@cimshop.UUCP (David Masterson) (09/22/89)

In article <18622@ut-emx.UUCP> mic@ut-emx.UUCP (Mic Kaczmarczik) writes:
>In article <467@cimshop.UUCP> davidm@cimshop.UUCP (David Masterson) writes:
>> [ questions about MG2a startup ]
>
>You need to compile MG 2a with XKEYS defined.  After that, MG will
>look for a file called .mg-TERM, where TERM is the value of the
>logical name TERM (e.g. .mg-vt100 for a vt100 terminal type). If
>found, it will read and evaluate that file just like .mg.  This allows
>you to have different function key setups for different terminals,
>albeit in a slightly different manner than GNU Emacs does.
>
>---------------------------------------------------------------------
>;
>; Example key definition file for VT100 terminals using the termcap
>; driver. This only works if XKEYS is defined during compilation.
>;
>(global-set-key "\eOA" 'previous-line)	; up arrow
>(global-set-key "\eOB" 'next-line)	; down arrow
>(global-set-key "\eOC" 'forward-char)	; right arrow
>(global-set-key "\eOD" 'backward-char)	; left arrow
>------------------------------------------------------------------------ 

According to make.com in [.sys.vms], my MG is compiled with XKEYS on.  I tried
your .mg-vt100 file above and got mixed results.  Without the .mg-vt100 file,
none of the arrow keys worked with MG beeping at the ESC-O and inserting the
following character.  With the above .mg-vt100 file, the up and down arrows
seemed to work as specified, but the left and right arrows just beeped at me
(no inserted characters!) and a QUIT signal in the minibuffer.  I also added
(after the above):

(global-set-key "\e[6~" 'scroll-up) ; next screen
(global-set-key "\e[5~" 'scroll-down) ; previous screen

as a separate test (just to see how far things went) and they didn't take
either.  It seemed the "\e[" was recognized as backward paragraph and the "6~"
or "5~" were self-inserted (no QUIT signal).  Suggestions where to try
next? (help).

David Masterson
uunet!cimshop!davidm

p.s.  This is a VMS system running DECWindows and I am in a DECterm in VT300
mode.  The function keys do map to the above key sequences (checked with a ^Q
in MG), but I don't know if this is a timing thing.

larryh@tekcae.CAX.TEK.COM (Larry Hedges) (09/22/89)

In article <472@cimshop.UUCP> davidm@cimshop.UUCP (David Masterson) writes:
>In article <18622@ut-emx.UUCP> mic@ut-emx.UUCP (Mic Kaczmarczik) writes:
>>In article <467@cimshop.UUCP> davidm@cimshop.UUCP (David Masterson) writes:
>>> [ questions about MG2a startup ]
>>
>>
>>---------------------------------------------------------------------
>>;
>>; Example key definition file for VT100 terminals using the termcap
>>; driver. This only works if XKEYS is defined during compilation.
>>;
>>(global-set-key "\eOA" 'previous-line)	; up arrow
>>(global-set-key "\eOB" 'next-line)	; down arrow
>>(global-set-key "\eOC" 'forward-char)	; right arrow
>>(global-set-key "\eOD" 'backward-char)	; left arrow
>>------------------------------------------------------------------------ 
>




	I use the following in my .emacs file on VMS - it works! (gnuemacs):


(global-unset-key "\e[")
"For vt100/ANSI displays"
"<F1> backward line"
(global-set-key "\e[A" 'previous-line)
"<F2> forward line"
(global-set-key "\e[B" 'next-line)
"<F3> back a character"
(global-set-key "\e[D" 'backward-char)
"<F4> forward a character"
(global-set-key "\e[C" 'forward-char)



-- 
     Larry Hedges                                     Tektronix, Inc.
     larryh@bianchi.CAX.TEK.COM                       P.O. Box 500
     CAX Data Management   19-075                     Beaverton, Oregon
     (503) 627-2642                                   97077