[comp.emacs] Binding VT100 keypad keys with GNU Emacs .emacs

moconnor@vela.acs.oakland.edu (Mike O'Connor) (08/10/90)

I am having problems binding VT100 keypad keys with .emacs files.

The VT100 keypad keys (M-O*, according to describe-key) will bind 
properly *after* loading up emacs, but will not bind with the 
global-set-key statements used in the .emacs initialization file.  
No other keys have problems binding with the global-set-key statements
in the .emacs used.  Terminal incompatibility has been ruled out -- 
the terminals we have tried out come straight from DEC.

Could someone on the net please assist?  System configuration is GNU 
Emacs 18.55 on Ultrix 3.1, if that is of any assistance.
-- 
--              moconnor@argo.acs.oakland.edu           Internet     
--              moconnor@oakland                        Bitnet
--

pierson@encore.com (Dan L. Pierson) (08/10/90)

This has been gone over recently but I'll try to make this worthwhile
by giving a bit more detail on Emacs startup.

You're running into the rather obscure initialization sequence in GNU
Emacs startup.  Roughly it's as follows:

    1. Internal initialization.
    2. Load the user's .emacs file (or the system default if the
       user doesn't have one).
       -q or -no-init-file  	Don't do this
       -u or -user  	    	Use another user's file
    4. Create the *scratch* buffer and put it in initial-major-mode.
    3. Load "term/$TERM" from the load path.
       If in a window system, (assume X), load "term/$TERMx-win" instead
	(i.e. append (concat (symbol-name window-system) "-win") to
    	      term-file-prefix before use)
       While haven't found a file to load, strip off last "-.*" and
       try again.  This lets TERM values like "vt100-wide" work.
       This is where the VT100 stuff is set up
       Set term-file-prefix to nil to prevent this
    4. Funcall term-setup-hook.
    5. Funcall window-setup-hook.

Read the lisp source "startup.el" for more details, including how to
define your own command line switches.

Now what's happening to you is that "term/vt100.el" is redefining M-O
after your .emacs has run.  To fix this, take all of your commands
that redefine M-O and wrap them in something like:

(let ((term (getenv "TERM")))
  (cond ((string-equal term "vt100")
         (setq term-setup-hook
               '(lambda ()
                   YOUR COMMANDS HERE
                   )))))


Note: I used a cond instead of an if because I have more than two
terminal types to check, your mileage may vary.

If you're using M-O as a prefix key, vt100.el sets this up for you so
you should change anything of the form:j

    (global-set-key "\M-O..." '+++)

to

    (define-key SS3-map "..." '+++)
--

                                            dan

In real life: Dan Pierson, Encore Computer Corporation, Research
UUCP: {talcott,linus,necis,decvax}!encore!pierson
Internet: pierson@encore.com

bk7295@leah.Albany.Edu (Brian A. Kell) (08/11/90)

In article <2460@vela.acs.oakland.edu>, moconnor@vela.acs.oakland.edu (Mike O'Connor) writes:
> I am having problems binding VT100 keypad keys with .emacs files.
> 
> The VT100 keypad keys (M-O*, according to describe-key) will bind 
> properly *after* loading up emacs, but will not bind with the 
> global-set-key statements used in the .emacs initialization file.  
> No other keys have problems binding with the global-set-key statements
> in the .emacs used.  Terminal incompatibility has been ruled out -- 


In the GNUemacs 18.55 distribution there are libraries for various terminal
types, including the vt100 (see the file dist-18.55/lisp/term/vt100.el)
This library will automatically be loaded if your environment variable
TERM is set to vt100 (or vt100-*).  This is described in the manual
under `Terminal-Specific Initialization' in the section about 
`The Init File: .emacs'.  It works for me using a name-brand DEC vt320
operating in vt100 mode...

Brian Kell
SUNY/Albany Department of Computer Science
brian@isadora.albany.edu