[gnu.emacs] How are arrow keys set up?

cowan@soleil.sps.mot.com (10/24/89)

I'm using a Visual Technology X-terminal most of the time and would
like to have emacs functions mapped to the terminal function
keys, and have the terminal arrow keys mapped to emacs pointer
movement functions.

But, how?

As an example, I've tried the mapping the up arrow key (^[[A) to be
previous-line in my .emacs file:
 (define-key global-map "^[[A" 'previous-line)
 (define-key global-map "\C-[A" 'previous-line)
 (define-key global-map "\e[A" 'previous-line)
 (define-key global-map "\e[-A" 'previous-line)

I keep getting an "error in init file" message.
Anyone know how I'm supposed to set this up?

 Andy Cowan
 cowan@soleil.sps.mot.com
 (602)821-4942
 Andy Cowan
 cowan@soleil.sps.mot.com
 (602)821-4942

wiles@hercules.uucp (Dale Wiles) (10/26/89)

In article <1918@dover.sps.mot.com> cowan@soleil.sps.mot.com () writes:
>
> [Stuff about mapping arrow keys.]
>
>As an example, I've tried the mapping the up arrow key (^[[A) to be
>previous-line in my .emacs file:

> (define-key global-map "\e[A" 'previous-line)
This is the proper syntax.

However, you're doing your mapping wrong. One way to map function keys is
to map the prefix key (in your case \e[) to a function map (CSI-map
probably), and then may the "A" to previous-line in CSI-map.

The best way to figure this out is to look at the file
"lisp/term/vt100.el" in your emacs directory. This is the program that
maps all the vt100 keys. It should get you going in the right direction.

You also might want to try M-x enable-arrow-keys, just to see what
happens. (It *probably* wont kill you :-)

*Emacs came, Dale, lad, Emacs came.               *(c) Marty Storer, Goog Inc.
*Disclaimer: I disclaim nothing! I am THE official*Looks more (bonk)
*opinion of my college, state, country and of all *like a sick-e-more (bonk)
*carbon based life forms in the universe.         *to me. Yogi the Space Bear.

wine@maui.cs.ucla.edu (David Wine) (10/27/89)

What is your environment variable TERM set to?  If it is vt100
then lisp/term/vt100.el should be loaded when you enter emacs and
then the cursor keys would be appropriately set.

fong@sybil.cs.Buffalo.EDU (steven w fong) (11/10/89)

In article <1918@dover.sps.mot.com> cowan@soleil.sps.mot.com () writes:

Part of your problem could be your terminal type.  If your terminal type is
VT100 (like ours), load in the vt100.elc file from emacs/lisp/term.

(load "/util/emacs/lisp/term/vt100.elc" nil nil t)

Then enable your arrow keys.

(enable-arrow-keys)

Then you can set up your arrow keys to some thing other than the default key
bindings.  These are my bindings:

(global-set-key "\e[B" 'scroll-up)
(global-set-key "\e[A" 'scroll-down)
(global-set-key "\e[C" 'scroll-left)
(global-set-key "\e[D" 'scroll-right)

Good luck with it.
	Steven W. Fong

internet: fong@cs.buffalo.edu	bitnet:	fong@sunybcs.BITNET
uucp:	  ..!{ames,boulder,decvax,rutgers}!sunybcs!fong