[comp.emacs] when using emacs, get the keymap right!

drw@cullvax.UUCP (Dale Worley) (06/16/87)

jdia@osiris.UUCP (Josh Diamond) writes:
> Or, there has to be a version of emacs that makes more use of individual
> terminals' program function keys, and less use of control chars.
> esc-codes are ok, but the control codes can really mess things up.
> 
>     The "IDEAL" solution to this problem would be to make emacs
> understand pf-keys better.  Microemacs is easily kludged to do this.
> Isn't it about time this happened?
> 
>     I won't even mention that most emacs'es don't understand the cursor
> keys which exist on all but the most archaic terminals (and
> Macintoshes). :-)

Maybe I'm missing something, but you can set up damn near any sequence
of characters to invoke damn near any function in Emacs, so you just
have to find out what all those PF and cursor keys transmit, and bind
those strings to the functions you'd like to have.  Put this in your
startup file:

(setq term (getenv "TERM"))
(if (string-equal term "vt100")
	(progn
		(global-set-key "xxxx" 'blender-on-buffer)
		...))

Gnu Emacs already loads the appropriate file out of
/usr/local/emacs/lisp/term for your terminal type (see variable
term-file-prefix) to try to bind your cursor keys, etc.

Dale
-- 
Dale Worley	Cullinet Software		ARPA: cullvax!drw@eddie.mit.edu
UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw
"President Nixon has just lowered the speed of light to 55 mph.  At what
speed can 2 colliding VW's of mass m = (number) produce a 3rd VW?"

jdia@osiris.UUCP (06/17/87)

In article <1283@cullvax.UUCP>, drw@cullvax.UUCP (Dale Worley) writes:
> jdia@osiris.UUCP (Josh Diamond) writes:
> >     I won't even mention that most emacs'es don't understand the cursor
> > keys which exist on all but the most archaic terminals (and
> > Macintoshes). :-)
> 
> Maybe I'm missing something, but you can set up damn near any sequence
> of characters to invoke damn near any function in Emacs, so you just
> have to find out what all those PF and cursor keys transmit, and bind
> those strings to the functions you'd like to have.  Put this in your
> startup file:
> 
> (setq term (getenv "TERM"))
> (if (string-equal term "vt100")
> 	(progn
> 		(global-set-key "xxxx" 'blender-on-buffer)
> 		...))
...
> Dale

Shall we write code like this for every pfkey on every type of terminal?
Too expensive time-wise right?

Why not make emacs understand a database about terminal function keys.
It would have to be better than termcap/curses, as that only supports up
to 10 function keys in addition to cursor control keys (I think).  Why
wasn't emacs designed to at least understand cursor keys? They are already
in curses.

Also, many terminals, like the vt200, have in the area of 24 pfkeys, plus
a numeric keypad that can be put in "application" mode, plus dedicated keys
for Help, "Do", find, select, insert, remove, prev-screen, and next-screen.
In fact, the majority of newly designed terminals have similar keyboards.

BTW, Ingres uses its own version of termcap/curses so that it can figger
out how to use all of the function keys.  Hurray for RTI!

That's nuff...

					Josh / Spidey!

-- 
DON'T PANIC!!!                                              \_\ /_/  Yes, it is
                                                             _[*]_   supposed to
A message from Spidey, and the Spidey Team.  ------>>>>     / / \ \  look like a
Reachable via UUCP: ...[seismo,mimsy]!jhu!osiris!jdia                spider!

bmiller@burdvax.UUCP (06/19/87)

In article <1183@osiris.UUCP> jdia@osiris.UUCP (Josh Diamond) writes:
>In article <1283@cullvax.UUCP>, drw@cullvax.UUCP (Dale Worley) writes:
>
>Why not make emacs understand a database about terminal function keys.
>It would have to be better than termcap/curses, as that only supports up
>to 10 function keys in addition to cursor control keys (I think).  Why
>wasn't emacs designed to at least understand cursor keys? They are already
>in curses.
>
>Also, many terminals, like the vt200, have in the area of 24 pfkeys, plus
>a numeric keypad that can be put in "application" mode, plus dedicated keys
>for Help, "Do", find, select, insert, remove, prev-screen, and next-screen.
>In fact, the majority of newly designed terminals have similar keyboards.

Well, GNU does support vt200 and vt100 cursor keys, function keys and
keypads. The variable term-file-prefix determines the load path for the
special files that set up the appropriate keybindings (This is usually the
term subdirectory in your local elisp source directory).  Emacs then looks at
you terminal type and automatically load the appropriate file (vt100.el,
vt220.el, etc..)  then all you need do is M-x enable-arrow-keys (in version
18 [because this loses the binding for backward-paragraph, some loss :-)])
I think version 17 does this automatically, and you're in business...


--Herb Miller
ARPA: hmiller@eddie.mit.edu
CHAOS: ham@deep-thought.mit.edu
UUCP: ...mit-eddie!hmiller

I 
wish
inews
wasn't
so picky
about
file
lengths
!

drw@cullvax.UUCP (Dale Worley) (06/19/87)

jdia@osiris.UUCP (Josh Diamond) writes:
> Why not make emacs understand a database about terminal function keys.
> It would have to be better than termcap/curses, as that only supports up
> to 10 function keys in addition to cursor control keys (I think).  Why
> wasn't emacs designed to at least understand cursor keys? They are already
> in curses.
> 
> Also, many terminals, like the vt200, have in the area of 24 pfkeys, plus
> a numeric keypad that can be put in "application" mode, plus dedicated keys
> for Help, "Do", find, select, insert, remove, prev-screen, and next-screen.
> In fact, the majority of newly designed terminals have similar keyboards.

Well, as an interesting project, you could do just that.  Design
yourself some new termcap entries so you can say the things you want
to say (say, all entries starting with "_", which gives you 96 or so
entries to play with), and add to the Emacs init code some stuff to
suck it all in and analyze it and bind keys accordingly.  You only
need to be able to read files and environment variables, and the
coding can be easily done in Lisp.

When they say "extensible", they aren't kidding, you know!

Dale
-- 
Dale Worley	Cullinet Software		ARPA: cullvax!drw@eddie.mit.edu
UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw
If you light a match, how much mass does it convert into energy?

greg@xios.XIOS.UUCP (Greg Franks) (06/22/87)

In article <1183@osiris.UUCP> jdia@osiris.UUCP writes:
|Why not make emacs understand a database about terminal function keys.
|It would have to be better than termcap/curses, as that only supports up
|to 10 function keys in addition to cursor control keys (I think).  Why
|wasn't emacs designed to at least understand cursor keys? They are already
|in curses.
|
|Also, many terminals, like the vt200, have in the area of 24 pfkeys, plus
|a numeric keypad that can be put in "application" mode, plus dedicated keys
|for Help, "Do", find, select, insert, remove, prev-screen, and next-screen.
|In fact, the majority of newly designed terminals have similar keyboards.

SysV, Rel3 curses supports up to 64 PF keys, up from 10 in SysV, Rel2. 
In addition the newer version of curses supports quite a bit more
dedicated function keys.  

I understand that jove can be made to understand function keys quite
easily. 
-- 
Greg Franks     (613) 725-5411          "Vermont ain't flat"
{net-land}!utzoo!dciem!nrcaer!xios!greg
(Other paths will undoubtably work too - your mileage will vary)

barmar@think.uucp (Barry Margolin) (06/24/87)

There's a big problem with having Emacs understand function/arrow keys
automatically.  Most such keys send ESC followed by one or two
characters.  Emacs already has default bindings for most escape
sequences.  If you're lucky, all the function keys send a
three-character escape sequence, with all of them having the same
first two characters, so only one Emacs key binding is used up.
However, I'm familiar with a family of terminals (Honeywell VIPs)
which sent a different escape sequence for the arrow keys and 24
function keys.  Some of the function keys even send ESC <digit>!  How
are users supposed to deal with such incompatibilities between
terminals?  They would have to know which commands they can't use on
each terminal.

One person I used to work with actually did set up key bindings for
many VIP function keys.  It made it impossible for anyone else to sit
at his terminal, because he usurped half the standard ESC bindings.

jimo@phred.UUCP (Jim Osborn) (06/24/87)

One of the beauties of emacs is that you CAN set up your own keybindings,
allowing those of us who touch type to keep our hands on the home
keyboard, and move the cursor (or whatever) with combinations of
the plain old regular keys.  Makes for a VERY portable editor,
and allows me to keep my eyes on the screen.  Can you REALLY reach
all those function keys without looking?

guy%gorodish@Sun.COM (Guy Harris) (06/26/87)

> One of the beauties of emacs is that you CAN set up your own keybindings,
> allowing those of us who touch type to keep our hands on the home
> keyboard, and move the cursor (or whatever) with combinations of
> the plain old regular keys.  Makes for a VERY portable editor,
> and allows me to keep my eyes on the screen.  Can you REALLY reach
> all those function keys without looking?

Yes, I can, and I touch type.  A single counterexample is sufficient
to demolish the premise that function keys and touch-typing are
totally incompatible, and that counterexample is currently typing
this message.

I don't use function keys now, but that's just because I've never
bothered rebinding the keys.  At my previous job I became quite
facile with a function-key editor; I almost always used a VT100, but
that did not make me a special case - many other people also use one
particular keyboard most of the time.

It may be that *some* people find it inconvenient to touch-type when
they use an editor that uses function keys, but "some" doesn't mean
"all".  It doesn't even mean "most".
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy@sun.com