[comp.emacs] Is there a hook for gnu emacs starting up?

charles@hpcvca.HP.COM (Charles Brown) (03/09/88)

Is there a hook for gnu emacs starting up?  I would like to have the
appropriate term/???.elc loaded depending upon $TERM.  It is easy to
do this in the .emacs file, but that requires N x M files (N users
and M computers).  Ideally I would like to do:
	if .emacs exists
		load .emacs
	else
		if $TERM == foo
			load "term/foo"
		...

dch@cci632.UUCP (David C. Howland) (03/11/88)

In article <640001@hpcvca.HP.COM> charles@hpcvca.HP.COM (Charles Brown) writes:
>Is there a hook for gnu emacs starting up?  I would like to have the
>appropriate term/???.elc loaded depending upon $TERM.  It is easy to
>do this in the .emacs file, but that requires N x M files (N users
>and M computers).  Ideally I would like to do:
>	if .emacs exists
>		load .emacs
>	else
>		if $TERM == foo
>			load "term/foo"
>		...


Put into your .emacs the following

;;;If non-nil, Emacs startup does
;;; (load (concat term-file-prefix (getenv "TERM")))
;;; You may set this variable to nil in your `.emacs' file if you do not wish
;;; the terminal-initialization file to be loaded.
(setq term-file-prefix "~/term.")

Options/settings that  go into a  .emacs file  should be  global for ALL
editing sessions  across    ALL  terminal types.    Terminal   dependent
options/settings belong in terminal dependent  files as in ~/term.xyz or
~/term.abc.  Where abc and xyz are terminal types.

bd@hpsemc.HP.COM (bob desinger) (03/13/88)

Charles Brown (charles@hpcvca.HP.COM) asks:
> Is there a hook for gnu emacs starting up?  I would like to have the
> appropriate term/???.elc loaded depending upon $TERM.

At startup, your Gnu Emacs should automatically load the terminal type
you're using.  If your $TERM is "hp", for instance, you'll get the
effect of `(load-library "term/hp")'.  [The load-library function loads
the .elc file if it exists, or the .el file if not.]

For this to work, you'll need an entry in term/ for whatever values of
$TERM that you use.  There are two ways to make this happen when the
number of term/ entries don't match the number of $TERM possibilities:
increase the term/ entries or map the $TERM values to what's in term/.

If you want to increase the term/ entries, I suggest links.  Suppose
you edit on either an hp2392 or a new HP 700/92 (called, say,
hp70092), and you want both to use the term/bobcat.elc file.  First,
M-x byte-compile-file term/bobcat.el.  Then, to make links:

	% cd /usr/local/lib/emacs/lisp/term	# or wherever
	% ln bobcat.elc hp2392.elc
	% ln bobcat.elc hp70092.elc

On the other hand, to map $TERM values to bobcat, tell your shell to
pretend that you're on a bobcat terminal if you're on a hp2392 or
hp70092 with a script or shell function like:

	case $TERM in
	hp2392|hp70092) TERM=bobcat gnumacs $*;;
	esac

(I take the easy way out and use in my .emacs file:

	(load "local/term/hp")		; DWIM with C-h and DEL

where /usr/local/lib/emacs/lisp/local/term/hp.elc is a file that maps
my arrow keys and terminal editing keys to emacs functions.  Jack
Repenning posted it many moons ago; I can forward you a copy or post
it if there's enough interest.)

bob desinger	bd@hpsemc%hplabs.HP.COM		ucbvax!hpda!hpsemc!bd

charles@hpcvca.HP.COM (Charles Brown) (03/15/88)

> >Is there a hook for gnu emacs starting up?  I would like to have the
> >appropriate term/???.elc loaded depending upon $TERM.  It is easy to
> >do this in the .emacs file, but that requires N x M files (N users
> >and M computers).  Ideally I would like to do:
> >	if .emacs exists
> >		load .emacs
> >	else
> >		if $TERM == foo
> >			load "term/foo"
> >		...
> Put into your .emacs the following
> ;;;If non-nil, Emacs startup does
> ;;; (load (concat term-file-prefix (getenv "TERM")))
> ;;; You may set this variable to nil in your `.emacs' file if you do not wish
> ;;; the terminal-initialization file to be loaded.
> (setq term-file-prefix "~/term.")

This is precisely what I was trying to avoid.  I maintain the emacs
sources on several machines.  I do not have access to all of the users
.emacs file (nor do I want it).

> Options/settings that  go into a  .emacs file  should be  global for ALL
> editing sessions  across    ALL  terminal types.    Terminal   dependent
> options/settings belong in terminal dependent  files as in ~/term.xyz or
> ~/term.abc.  Where abc and xyz are terminal types.

This does not mean anything to me.  The reason I have the conditional
in my psuedo code at the top is because HP terminals and
pseudo-terminals have a bewildering array of identifiers, yet they all
use the same term/hp.el file.

Fortunately a couple of people have sent me a solution which fits what
I need.  A file named default.el will be loaded at startup time.  This
is 'documented' in the source of startup.el.  :-(   Anyway, this works
well.  :-)
	charles@hp-pcd