Subject: site-start.el and lout-mode.el

From: Ian Jackson <[email-masked]>
Date: Fri, 19 Jul 96 21:03 BST

There exists an Emacs mode for editing Lout source files, and I'd like
the Lout package to arrange for this to `work right'.

This means putting lout-mode.el in /usr/lib/emacs/site-lisp (which is
fine) and editing site-start.el so that it contains:
 (autoload 'lout-mode "lout-mode" "Mode for editing Lout source" t)
 (setq auto-mode-alist (append '(("\\.lout$" . lout-mode)) auto-mode-alist))
This would ideally be removed again when the package is removed.

Is there some recommended procedure for doing this ?

Mark, you're the Emacs maintainer, what do you say ?

Thanks,
Ian.

---

From: [email-masked] (Mark W. Eichin)
Date: 19 Jul 1996 19:51:28 -0400

I don't have a good mechanism for it, but look at what "gnats" does, I
think it adds it's own hooks...

---

From: [email-masked]
Date: Fri, 19 Jul 96 20:56 EDT

Ian Jackson writes:
  Ian>  There exists an Emacs mode for editing Lout source files, and I'd
  Ian> like the Lout package to arrange for this to `work right'.
  Ian> 
  Ian> This means putting lout-mode.el in /usr/lib/emacs/site-lisp (which is
  Ian> fine) and editing site-start.el so that it contains: (autoload
  Ian> 'lout-mode "lout-mode" "Mode for editing Lout source" t) (setq
  Ian> auto-mode-alist (append '(("\\.lout$" . lout-mode)) auto-mode-alist))
  Ian> This would ideally be removed again when the package is removed.
  Ian> 
  Ian> Is there some recommended procedure for doing this ?

We could do with a script similar to install-info to deal with this. The
postinst/prerm from the vm package are good starting points.

  Ian> Mark, you're the Emacs maintainer, what do you say ?

--
Dirk Eddelb"uttel                             http://qed.econ.queensu.ca/~edd

---

From: "Brian C. White" <[email-masked]>
Date: Fri, 19 Jul 1996 23:36:04 -0400

> think it adds it's own hooks...

It does at that.  I've attached the Gnats install code that handles adding
and removing itself from the site-start.el file.  I've since learned a lot
more about perl and can see several easier ways to do this.

                                        Brian
                               ( [email-masked] )

-------------------------------------------------------------------------------
    In theory, theory and practice are the same.  In practice, they're not.
#! /usr/bin/perl

###############################################################################
#
# Add the 'gnats' tools into emacs
#
$emacsfile = "/etc/site-start.el";	# provided by 'init'

sub addemacs_die {
	die "Cannot add 'gnats' tools to emacs site-start: $!\n";
}

#
# Append to the emacs site-start file
#
open(EMACS,">>$emacsfile") || addemacs_die;
print EMACS <<END;

; ----- Gnats-Load-Start -----
(autoload 'edit-pr "gnats"
   "Command to edit a problem report." t)
(autoload 'view-pr "gnats"
   "Command to view a problem report." t)
(autoload 'unlock-pr "gnats"
   "Unlock a problem report." t)
(autoload 'query-pr "gnats"
   "Command to query information about problem reports." t)
(autoload 'send-pr-mode "send-pr"
   "Major mode for sending problem reports." t)
(autoload 'send-pr "send-pr"
   "Command to create and send a problem report." t)
; -----  Gnats-Load-End  -----
END
close(EMACS);
#! /usr/bin/perl

###############################################################################
#
# Remove the 'gnats' tools from emacs
#
$emacsfile = "/etc/site-start.el";	# provided by 'init'

sub rmemacs_die {
	print "- Could not remove 'gnats' tools from emacs site-start: $!\n";
	return 0;
}

#
# Slurp the entire emacs site-start file
#
if (open(EMACS,"<$emacsfile") || rmemacs_die) {
	$delim = $/; undef $/;
	$emacs = <EMACS>;
	close(EMACS);
	$/ = $delim;
	@emacs = split(/\n/,$emacs);

#
# Remove any old entry for 'gnats'
#
	@newemacs = ();
	$found = 0;
	foreach $line (@emacs) {
		if ($line =~ m/----- Gnats-Load-Start -----/) {
			$found = 1;
		}
		if ($found == 0) {
			push(@newemacs,$line);
		}
		if ($line =~ m/-----  Gnats-Load-End  -----/) {
			$found = 0;
		}
	}

#
# Write out the changed site-start file
#
	$emacs = join("\n",@newemacs);
	$emacs.= "\n";
	if (rename("$emacsfile","$emacsfile.dpkg-old") || rmemacs_die) {
		if (open(EMACS,">$emacsfile") || rmemacs_die) {
			print EMACS $emacs;
			close(EMACS);
			chmod 0644, "$emacsfile";
		} else {
			rename("$emacsfile.dpkg-old","$emacsfile");
		}
	}
}

---

From: "Brian C. White" <[email-masked]>
Date: Sat, 20 Jul 1996 10:07:24 -0400

> postinst/prerm from the vm package are good starting points.

If anything, I would recommend a "site-start" directory that held the code
for all of the installed packages.  Emacs lisp should be sufficiently smart
enough to be able to run all scripts in a given directory, much like run-parts.
This would, of course, be in addition to the "site-start.el" file in /etc.

                                        Brian
                               ( [email-masked] )

---

From: Rob Browning <[email-masked]>
Date: 20 Jul 1996 11:35:53 -0500

> This would, of course, be in addition to the "site-start.el" file in /etc.

In fact, I imagine that it would be pretty easy to arrange for the
standard Debian /etc/site-start.el file to contain code to handle
this.  It would certainly trivialize adding and removing entries...

This seems like a good idea.
--
Rob

---

From: [email-masked] (Erick Branderhorst)
Date: Mon, 22 Jul 1996 11:10:05 +0100

> This would, of course, be in addition to the "site-start.el" file in /etc.

How bad is this for the performance of the starting of emacs? I started
writing some "generic write in delete from util" a while ago but didn't
finish it because of other more important things, I came up with the
following:

It should have an option to comment the text which needs to be inserted so
that the inserted text is active during the load. If the "put a file in a
subdir" approach is followed this should be an option as well.

If order is important, some kind of sorting mechanism should be inserted.

Erick

---

From: Ian Jackson <[email-masked]>
Date: Thu, 1 Aug 96 01:58 BST

Erick Branderhorst writes ("Re: site-start.el and lout-mode.el"):
> [ people ... ]
> How bad is this for the performance of the starting of emacs? [...]

If it's too slow we can have the script cat together all the entries
into a cached version if the directory is more recently modified than
the cache, and then run the cache.

Ian.

---

From: Rob Browning <[email-masked]>
Date: 31 Jul 1996 21:32:43 -0500

> the cache, and then run the cache.

That's true, but I have a feeling that it won't be a problem unless we
end up with hundreds of load files, which is a long way away.

--
Rob