[comp.emacs] key bindings for Micro-EMACS

glf@mundoe.mu.oz (Giuseppe Fiusco) (08/19/87)

Every so often there is some discusion about how to make MicroEMACS
recognise a certein key sequence eg. the directional keys on a VT100.
Given that people will want to bind a wide number of different keys
to varioius functions (different terminals and function keys) I
have rewritten the key binding method for MicroEMACS so that a function
can be bound to any particular key sequence (Except for those the use
^@ (NULL) in the sequence (this may be fixed later)).

When MicroEMACS is started up the first thing it does is read a startup
file that contains information regarding how particular functions are
bound to a particular series of key-strokes. It uses something like the
following sequence :

[ Command		Function		Key Strokes ]

  bind-to-key		forward-character	\e[C

The above example will bind the forward-character function to the
keys strokes that are emiited when pressing the right arrow on a VT100
terminal. There is also a way of defining special charater values.

Obviously reading in the binding file every time is not the best way
of starting up MicroEMACS so it is possible to create a preloaded 
version. This is achieved by causing A core dump from the loadup file
by the command 'core' and then recreating a runable executable from this
preloaded core file (BSD4.3 only at the moment as far as I know). This
means that only a small number of keys need to be defined in the loadup
file.

I have retained all of the normal functions provided it MicroEMACS to
do with key bindings etc but the syntax is changed slightly. The changes
seem to work O-K but I will not gaurantee them to be bug free.

If enough people are interested I will tidy it up and post it out (this
will probably take a couple of weeks).

Giuseppe Fiusco
Department of Mathematics ,
University of Melbourne, Parkville, Victoria 3052, Australia

VOICE:  (03) 344 7278 (International: +61 3 344 7278)
ACSnet: glf@mundoe.mu
UUCP:	{seismo,mcvax,ukc,ubc-vision}!munnari!mundoe.mu.oz!glf
ARPA:	munnari!mundoe.mu.oz!glf@seismo.css.gov
CSNET:	glf%mundoe.mu.oz@csnet-relay

davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (08/20/87)

In article <292@mundoe.mu.oz> glf@mundoe.mu.oz (Giuseppe Fiusco) writes:
... stuff deleted about why you want to change keybindings ...

|Obviously reading in the binding file every time is not the best way
|of starting up MicroEMACS so it is possible to create a preloaded 
|version. This is achieved by causing A core dump from the loadup file
|by the command 'core' and then recreating a runable executable from this
|preloaded core file (BSD4.3 only at the moment as far as I know). This
|means that only a small number of keys need to be defined in the loadup
|file.

I think it would be easier to recompile with the preferred bindings than
to reload from dumps. Having a special version for each set of
keybindings seems like a lot of work. Does each user have his own
version, or are some arbitrary bindings made the systems default?
Interesting idea for a single user system, though.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {chinet | philabs | seismo}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

brett@wjvax.UUCP (Brett Galloway) (08/21/87)

In article <292@mundoe.mu.oz> glf@mundoe.mu.oz (Giuseppe Fiusco) writes:
>Every so often there is some discusion about how to make MicroEMACS
>recognise a certein key sequence eg. the directional keys on a VT100.
>
>When MicroEMACS is started up the first thing it does is read a startup
>file that contains information regarding how particular functions are
>bound to a particular series of key-strokes. It uses something like the
>following sequence :
>
>[ Command		Function		Key Strokes ]

I was faced with the same problem, but I addressed it in a slightly-different
manner, which I believe is more consistent with original usage.  I
defined a new function 'define-key`, which let one name a character
sequence.  After that, that name became a function-key, which could be bound
to a function.  With this method, the desired define-key commands can be put
in the MicroEMACS startup script, and then the resulting function keys can
be bound to the desired functions.  No additional function key table is
necessary.

In addition, I modified the termcap driver automatically to generate arrow
key function keys (I used FN-LEFT,FN-RIGHT,FN-UP,FN-DOWN) and bind the
respective functions to them.  That is very handy.

Unfortunately, I cannot post diffs, because I made lots of other modifications
as part of the same effort, and I was working on an old version anyhow
(3.7i).  The changes outlined above aren't very hard, however.

-- 
-------------
Brett Galloway
{pesnta,twg,ios,qubix,turtlevax,tymix,vecpyr,certes,isi}!wjvax!brett

mike@cimcor.UUCP (Michael Grenier) (08/22/87)

In article <7049@steinmetz.steinmetz.UUCP>, davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) writes:
> I think it would be easier to recompile with the preferred bindings than
> to reload from dumps. Having a special version for each set of
> keybindings seems like a lot of work. Does each user have his own
> version, or are some arbitrary bindings made the systems default?
> Interesting idea for a single user system, though.


Not being familiar with BSD or various other flavors of UNIX except
V.2 perhaps I'm missing something. The terminfo library knows the
key sequences for each terminal, why not use curses which returns a
unique code for each arrow key, next page key, etc; like vi uses.
 
     -Mike
      ihnp4!meccts!cimcor!mike

glf@mundoe.mu.oz (Giuseppe Fiusco) (08/24/87)

in article <449@cimcor.UUCP>, mike@cimcor.UUCP (Michael Grenier) says:
> .................................. The terminfo library knows the
> key sequences for each terminal, why not use curses which returns a
> unique code for each arrow key, next page key, etc; like vi uses.

There was a very simple reason for not using the terminal description
library routines to do the key-bindings. If you look carefully at the
source for MicroEMACS you will see that it is used on a large 
number of different systems (not just UNIX) so using the terminal
description package would not allow for a consistant, usable implementation
across the different systems.

Giuseppe Fiusco

UUCP:	{seismo,mcvax,ukc,ubc-vision}!munnari!mundoe.oz!glf
ARPA:	munnari!mundoe.oz!glf@seismo.css.gov
CSNET:	glf%mundoe.oz@csnet-relay

michael@pbinfo.UUCP (Michael Schmidt) (08/25/87)

Recently glf@mundoe.mu.oz (Giuseppe Fiusco) wrote:
  in article <449@cimcor.UUCP>, mike@cimcor.UUCP (Michael Grenier) says:
  > .................................. The terminfo library knows the
  > key sequences for each terminal, why not use curses which returns a
  > unique code for each arrow key, next page key, etc; like vi uses.
  
  There was a very simple reason for not using the terminal description
  library routines to do the key-bindings. If you look carefully at the
  source for MicroEMACS you will see that it is used on a large 
  number of different systems (not just UNIX) so using the terminal
  description package would not allow for a consistant, usable implementation
  across the different systems.
  
I really don't understand, what you're trying to say.

I think, the real reason is, that for example the ansi cursor
keys are starting with '\E[' and that is bound to a function in
most emacses. GNU has the possibility to set it in the terminal
dependent startup file and MicroGnuEmacs has a compile time
option to include code to read the keys from terminfo/cap and it
both works fine.

     Michael Schmidt
-- 
UUCP:  ...!seismo!unido!pbinfo!michael    |  Michael Schmidt
       or michael@pbinfo.UUCP             |  Universitaet-GH Paderborn, FB 17
CSNET: michael%pbinfo.uucp@Germany.CSNET  |  Warburger Str. 100
ARPA:  michael%pbinfo.uucp@seismo.css.gov |  D-4790 Paderborn, West Germany

mark@cogent.UUCP (Captain Neptune) (08/25/87)

In article <295@mundoe.mu.oz> glf@mundoe.mu.oz (Giuseppe Fiusco) writes:
>in article <449@cimcor.UUCP>, mike@cimcor.UUCP (Michael Grenier) says:
>> .................................. The terminfo library knows the
>> key sequences for each terminal, why not use curses which returns a
>> unique code for each arrow key, next page key, etc; like vi uses.
>
>There was a very simple reason for not using the terminal description
>library routines to do the key-bindings. If you look carefully at the
>source for MicroEMACS you will see that it is used on a large 
>number of different systems (not just UNIX) so using the terminal
>description package would not allow for a consistant, usable implementation
>across the different systems.

Sorry, I see this in a different light:

There is a simple reason why one *could* use the terminal description
library routines to do the key-bindings.  If you look carefully at the
source for MicroEMACS you will see that it is used on a large number of
different systems, thus employing LOTS of #ifdef structures so that it
can run on lots of systems (not just UNIX).  By putting the terminal
definition stuff in the appropriate #ifdef's, the terminal description
package *would* allow for a consistant, usable implementation across the
different systems. 
-- 
##############################################################################
# Mark ###################### Ernie: Gee, Bert!  Where'd all your files go ? #
# Steven #################### Bert:  My files!  Er-r-r-r-r-r-rnie-e-e-e-e !! #
# Jeghers ########## {ihnp4,cbosgd,lll-lcc,lll-crg}|{dual,ptsfa}!cogent!mark #
##############################################################################
# Standard Disclaimer: Don't sue me.  Sue my company.  They have more money. #
##############################################################################

mike@cimcor.UUCP (Michael Grenier) (08/25/87)

In article <295@mundoe.mu.oz>, glf@mundoe.mu.oz (Giuseppe Fiusco) writes:
> There was a very simple reason for not using the terminal description
> library routines to do the key-bindings. If you look carefully at the
> source for MicroEMACS you will see that it is used on a large 
> number of different systems (not just UNIX) so using the terminal
> description package would not allow for a consistant, usable implementation
> across the different systems.

Yes, that's true. However, you will note that MicroEMACS *does* use
the termcap definitions for output - so why not also on input. The other
operating systems and machines supported by MicroEMACS are usually 
consistant within themselves as a result of their lack of support for
remote terminals ( MSDOS, etc). VMS is an exception. The uEMACS code
selectively compiles the appropiate code for a given operating system.
See estruct.h 

I'm new to UNIX so pardon my ignorance. I see that termcap is used almost
exclusively and not curses for most public domain programs. It
seems that curses is the approach taken by current and future AT&T 
versions of UNIX (does POSIX address the curses issues ? if not, it should)
and the calls provided by curses sure seem cleaner and easier than termcap.
Does one choose termcap over curses because curses isn't provided as 
universally? 

How about a public domain implementation of curses on top of termcap
so one wouldn't always have to write to the lowest common denominator. 
Steve Jobs is probably right in saying that some common windowing and graphics
interface is desperately needed for UNIX if it is going to maintain itself 
against the OS/2s and Macs in this world ( at least in that range of hardware).
Curses isn't that answer, of course.

Sorry for drifting off the subject....  :-)
It just seemed that using the informational database we already had
is probably easier then having to rebind the various keystrokes for
each type of terminal one is supporting.

    -Mike
    ihnp4!meccts!cimcor!mike

larry@jc3b21.UUCP (08/30/87)

In article <262@cogent.UUCP>, mark@cogent.UUCP (Captain Neptune) writes:
> In article <295@mundoe.mu.oz> glf@mundoe.mu.oz (Giuseppe Fiusco) writes:
> >in article <449@cimcor.UUCP>, mike@cimcor.UUCP (Michael Grenier) says:
> >> .................................. The terminfo library knows the
> >> key sequences for each terminal, why not use curses which returns a
> >> unique code for each arrow key, next page key, etc; like vi uses.
> >

Just thought I'd put in a quick nudge for the mods I've finished to the
uemacs 3.9 code.  These change 4 or 5 files (and include 2 new header files
as well), and as a result support both cursor control and function keys on
generic UNIX machines (including ansi terminals and vt100-style things).
Support is for cursor for,back,up,down; home; page up/down; end (for AT like
XENIX stuff) and function keys f1-f10 (f10 == f0).  That was all that was
supported by termcap (for terminfo, I could add up to 64 function keys if any-
one is REALLY interested :-).

The code works properly on 3b2 (Sys V), PC/AT XENIX, and SUN (BSD 4.2).  That
is all I have access to, but it should run other places.  The diffs are about
18k long, so I have not posted (will if there is enough interest) and I'm
trying to get the patches back to the original poster as well.

There are still a few problems, including the fact that ansi terminals will
still muck up transfer of cursor keys from time-to-time.  At least one brand of
terminal (Wyse 85) ABSOLUTELY REFUSES to send a ^S to the computer, so those
keys have to be rebound.  Color doesn't work (yet) for XENIX systems (emacs is
too smart sometimes :-), and I had to remove the typeahead code to implement
the cursor/function keys (I'm working on it).

There hasn't been ANY mail in by mailbox about this (well, one letter), so
let me know how y'all feel about posting the stuff or whatever...

-l
(BTW, return mail may have to go through ...gatech!codas!usfvax2... instead
of the akgua route.  It depends on the phase of the moon or something!)

-- 
+-----------------------------------+-- St. Petersburg Junior College --+
|       Lawrence F. Strickland          P.O. Box 13489                  |
|   ...akgua!usfvax2!jc3b21!larry   |   St. Petersburg, FL 33733        |
+-----------------------------------+-- Phone: +1 813 341 4705 ---------+

len@array.UUCP (Leonard Vanek) (09/04/87)

In article <146@jc3b21.UUCP> larry@jc3b21.UUCP writes:
>
>Just thought I'd put in a quick nudge for the mods I've finished to the
>uemacs 3.9 code.

I had not realized that version 3.9 is already available. Can anybody
tell me when it is going to be posted to one of the sources newsgroups?

Len

nwd@j.cc.purdue.edu (Daniel Lawrence) (09/06/87)

In article <537@array.UUCP> len@array.UUCP (Leonard Vanek) writes:
>In article <146@jc3b21.UUCP> larry@jc3b21.UUCP writes:
>>
>>Just thought I'd put in a quick nudge for the mods I've finished to the
>>uemacs 3.9 code.
>I had not realized that version 3.9 is already available. Can anybody
>tell me when it is going to be posted to one of the sources newsgroups?

I sent and got a confirmation of reception from Rich $alz (moderator of
comp.unix.sources) about 4 weeks ago. I assume it will appear soon. In
the meantime, it is availible on the BBS listed in my signiture.

			Daniel Lawrence		(317) 742-5153
			UUCP:	ihnp4!pur-ee!j.cc.purdue.edu!nwd
			ARPA:	nwd@j.cc.purdue.edu
			FIDO:	201/2 The Programmer's Room (317) 742-5533