[net.emacs] Cursor keys

mly@prep.AI.MIT.EDU (02/15/86)

From: mly@prep.AI.MIT.EDU (Richard Mlynarik)
You didn't say what emacs you are running, though from circumstantial
evidence I assume it is GNU Emacs of some unknown modernity.
(Use m-x emacs-version ito find out)

This is covered in the `Init Files' section of the GNU Emacs manual
(either printed or by way of `m-x info' in Emacs version 17)

The example given in that section is:

   * Make `C-x p' undefined.
     
          (global-unset-key "\C-xp")
     
     One reason to undefine a key is so that you can make it a prefix.
     Simply defining `C-x p ANYTHING' would make `C-x p'
     a prefix, provided it is not otherwise defined.
     
So to solve your problem:
    I'm fairly new to emacs and was wondering if anyone can tell me if there is a
    way to define the cursor keys on a DEC VT240 terminal to be next-line,
    previous-line, forward-char, & backward-char. The cursor keys send the
    characters ESC [ B,ESC [ A,ESC [ C,ESC [ D respectively. The only problem is
    that the first two characters are taken to be backward-paragraph (ESC [) and
    the rest is inserted into the text.

place the following forms in your ~/.emacs file:

(global-unset-key "\e[")
(global-set-key "\e[A" 'previous-line)
(global-set-key "\e[B" 'next-line)
(global-set-key "\e[C" forward-char)
(global-set-key "\e[D" 'backward-char)

I don't know how similar a vt240 is to a vt200 or a vt220 -- if they
are close, you might consider making a file emacs/lisp/term/vt240.el
which is linked to emacs/lisp/term/vt200.el -- that file contains a
number of key definitions which some people have found to their
liking.  Have a look around in that file to see what things are
defined and how they can be changed.

jbs@mit-eddie.UUCP (Jeff Siegal) (02/15/86)

In article <11475@watnot.UUCP> cagordon@watnot.UUCP (Chris Gordon) writes:
>
>I'm fairly new to emacs and was wondering if anyone can tell me if there is a
>way to define the cursor keys on a DEC VT240 terminal to be next-line,
>previous-line, forward-char, & backward-char. The cursor keys send the
>characters ESC [ B,ESC [ A,ESC [ C,ESC [ D respectively. The only problem is
>that the first two characters are taken to be backward-paragraph (ESC [) and
>the rest is inserted into the text.

One perfectly apporpriate way to do this is to put the VT240 in
"applications mode," which gives the arrow keys codes of the form
ESC-O <char>.  You then have to define these key-sequences to
"next-line," etc. with whatever incantation your particular version
of Emacs likes.

Jeff Siegal - MIT EECS