[comp.emacs] Autoloading edt.el, update to previous message

dko@calmasd.GE.COM (Dan O'Neill) (01/21/88)

This is a followup to my previous posting where I made some incorrect
statements about the function of keypad.el when referenced by a
terminal initialization file.

The problem in question was with "edt.el".  It would not function
correctly when loaded in site-init.el, site-load.el or .emacs.  I
responded with a suggestion to execute the function "edt-emulation-on"
with a binding to term-setup-hook.  This suggestion will work.

However, there is a more specific problem which I did not address
correctly, that of why edt.el does not work when loaded via an init
file.  Specifically, why the PF1 key on a VT100/200 terminal seems not
to be bound correctly.  The following is an explaination and a cure. 

Explaination:

Defined inside the file edt.el is the function "define-keypad-key".
This function is specifically for the binding of function keys in a
keymap other than the pre-defined "function-keymap" variable.  This
function takes three arguments: 
    1) name of the keymap to make the binding in;
    2) the index into the keymap "function-keymap" which
       represents the function key in question, and
    3) the function to be bound.

The returned value from this function is the ascii key sequence
represented by the key in question.

e.g., The entry \C-a in function-keymap represents the character
sequence ESC O P on a vt100 terminal.

define-keypad-key will work fine when the file is executed
interactively, as the variable "function-keymap" has been defined by
the vt100.el file.

When edt.el is loaded via one of the init files, the define-keypad-key
function looks into "function-keymap" and finds nil for the definition
of the entry index by \C-a, for example.  Thus the definitions for all
keys in the GOLD-map, defined in edt.el, will be nil.

Solution:

The idea here is to enable speedy startup of EDT mode; i.e., avoid the
long process of loading edt.el each time an editing session is
started.  Thus the site manager creates or modifies the file
site-load.el and adds the line (load "edt") and removes the auto-load
"edt" line from loadup.el.

Now, the lisp code in edt.el will have to be modified slightly.
Search for the section where the function define-keypad-key is first
used. 

;Bind GOLD/Keypad keys
(define-keypad-key GOLD-map ?u 'line-to-top-of-window)	    ;"up-arrow"

Enclose all of the lines containing (define-keypad-key ... in a
function, lets call it bind-edt-gold-keys.

(defun bind-edt-gold-keys ()
  (define-keypad-key GOLD-map ?u 'line-to-top-of-window)      ;"up-arrow"
  (define-keypad-key GOLD-map ?d 'line-to-bottom-of-window)   ;"down-arrow"
     .
     .
  (define-keypad-key GOLD-map ?e 'shell-command)              ;"ENTER"
) ; end of bind-edt-gold-keys

Now, find the definition of the function edt-emulation-on, and add 
the line (bind-edt-gold-keys) to the function.

(defun edt-emulation-on ()
  (interactive)
  (advance-direction)
       .
       .
  (define-key esc-map "?" 'apropos)	;"<ESC>?"
  (bind-edt-gold-keys))			;bind the gold'd keys

Now, rebuild xemacs so that the new site-load.el file is used and the
edt.el file is pre-loaded.

Run xemacs and enter the command M-X edt-emulation-on.  You should
enter EDT mode very quickly.  If this works properly, you can place
the command (edt-emulation-on) in your .emacs file.

(defun setup-my-editor ()
  (edt-emulation-on))

(setq term-setup-hook 'setup-my-editor)

Sorry for all the confusion.  If you still have problems, write me and
I'll see what I can do.  And, yes, it's really 1:00am in the
morning.
-- 
Dan O'Neill			dko@calmasd.GE.COM
GE Calma R&D			...!sdcsvax!calmasd!dko