From xemacs-m  Wed Feb 26 18:41:42 1997
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id SAA18839
	for <xemacs-beta@xemacs.org>; Wed, 26 Feb 1997 18:41:34 -0600 (CST)
Received: (from steve@localhost)
	by altair.xemacs.org (8.8.5/8.8.5) id QAA03934;
	Wed, 26 Feb 1997 16:52:54 -0800
Mail-Copies-To: never
To: xemacs-beta@xemacs.org
Subject: Automating site-loads [v20 proof of concept patch]
X-Url: http://www.miranova.com/%7Esteve/
X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5"
 f8*@r4ipO6Jl!:Ccq<xoV[Qz2u8<8-+Vwf2gzJ44lf_/y9OaQ`@#Q65{U4/TC)i2`~/M&QI$X>p:9I
 OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+
X-Attribution: sb
From: Steven L Baur <steve@miranova.com>
Mime-Version: 1.0 (generated by tm-edit 7.105)
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Feb_26_16:52:51_1997-1"
Content-Transfer-Encoding: 7bit
Date: 26 Feb 1997 16:52:51 -0800
Message-ID: <m220a3rrx8.fsf@altair.xemacs.org>
Lines: 248
X-Mailer: Gnus v5.4.15/XEmacs 20.1

--Multipart_Wed_Feb_26_16:52:51_1997-1
Content-Type: text/plain; charset=US-ASCII

O.K.  I think I've a got a working automated way of integrating
site-load.el with DOC string generation.  The following patch is
against 20.1-b2.

Caveats, observations:
* When adding new packages it is probably a good idea to (manually)
  adjust src/PURESIZE.h upwards first.  I got strange messages with a
  tight PURESIZE fit that went away when I reset the first pass to a
  comfortable margin first.

* You will get `strange doc (duplicate)' messages for *each* symbol
  autoloaded in a dumped package:
Loading site-load...
Loading site-wide packages for dumping...
Loading ../lisp/modes/cc-mode...
Loading site-wide packages for dumping...done
Finding pointers to doc strings...
Note: Strange doc (duplicate) for bytecode c-mode @ 1299950
Note: Strange doc (duplicate) for bytecode c++-mode @ 1300454
Note: Strange doc (duplicate) for bytecode objc-mode @ 1300588
Note: Strange doc (duplicate) for bytecode java-mode @ 1301167
Note: Strange doc (duplicate) for bytecode c-set-style @ 1307559
Finding pointers to doc strings...done
Dumping under the name xemacs
Purespace usage: 771756 of 772540 (100%).

  There appears to be no lossage involved, so ignore the warnings for
  now.

* I haven't tested this under --srcdir configurations or 19.15 but it
  should be O.K. under both and I will post a tested 19.15 patch
  in a few hours.

* Don't worry about an offset warning when patching Makefile.in.in, I
  stripped the hunks related to the PURESIZE.h patch manually.

* If this is successful, it will appear in the next betas for further
  testing and refinement as it can obviously stand both.


You need the following two new files: lisp/site-packages and
lisp/site-load.el.  site-packages is obviously a template, replace the
contents with whatever packages you wish.

--Multipart_Wed_Feb_26_16:52:51_1997-1
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="site-packages"
Content-Transfer-Encoding: 7bit

(setq site-load-packages '(
"../lisp/modes/cc-mode"
)
)

--Multipart_Wed_Feb_26_16:52:51_1997-1
Content-Type: text/plain; charset=US-ASCII


--Multipart_Wed_Feb_26_16:52:51_1997-1
Content-Type: application/octet-stream; type=emacs-lisp
Content-Disposition: attachment; filename="site-load.el"
Content-Transfer-Encoding: 7bit

;;; site-load.el --- Template file for site-wide XEmacs customization

;; Author: Steven L. Baur <steve@altair.xemacs.org>
;; Keywords: internal

;; This file is part of XEmacs.

;;; Commentary:

;; This is a prototype site-load.el file.
;; The site-load.el mechanism is provided so XEmacs installers can easily
;; dump lisp packages with XEmacs that do not get dumped standardly.

;; The file `site-packages' if it exists should look something like:
;; (setq site-load-packages '(
;; "../lisp/modes/cc-mode"
;; "../lisp/utils/redo"
;; "../lisp/packages/scroll-in-place"
;; )
;; )

;; The first line and the last line must be exact.  Each of the packages
;; listed must be double quoted, have either an absolute path, or a relative
;; to the build src directory path *and* be bytecompiled prior to the attempt
;; to dump.

;; Because this is a trial implementation and the file is shared with
;; make-docfiles, syntax is strict and unforgiving.  So sue me.  It
;; is still better than the way it used to be.

;;; Code:
(defvar site-load-package-file "../lisp/site-packages"
  "File name containing the list of extra packages to dump with XEmacs.")
(defvar site-load-packages nil
  "A list of .elc files that should be dumped with XEmacs.
This variable should be set by `site-load-package-file'.")

;; Load site specific packages for dumping with the XEmacs binary.
(when (file-exists-p site-load-package-file) 
  (let ((file))
    (load site-load-package-file t t t)
    ;; The `load-gc' macro is provided as a clue that a package is being loaded
    ;; in preparation of being dumped into XEmacs.
    (defmacro load-gc (file)
      (list 'prog1 (list 'load file) '(garbage-collect)))
    (message "Loading site-wide packages for dumping...")
    (while site-load-packages
      (setq file (car site-load-packages))
      (load-gc file)
      (setq site-load-packages (cdr site-load-packages)))
    (message "Loading site-wide packages for dumping...done")
    (fmakunbound 'load-gc)))

;; This file is intended for end user additions.
;; Put other initialization here, like setting of language-environment, etc.
;; Perhaps this should really be in the site-init.el.

;;; site-load.el ends here

--Multipart_Wed_Feb_26_16:52:51_1997-1
Content-Type: text/plain; charset=US-ASCII

Index: src/Makefile.in.in
===================================================================
RCS file: /usr/local/xemacs/xemacs-20.0/src/Makefile.in.in,v
retrieving revision 1.7
diff -u -r1.7 Makefile.in.in
--- Makefile.in.in	1997/02/24 01:14:44	1.7
+++ Makefile.in.in	1997/02/27 00:13:54
@@ -1360,7 +1361,8 @@
 ${libsrc}DOC: ${libsrc}make-docfile ${obj_src} ${mule_obj_src} ${lisp}
 #endif
 	rm -f ${libsrc}DOC
-	${libsrc}make-docfile -d ${srcdir} ${obj_src} ${mule_obj_src} \
+	${libsrc}make-docfile -d ${srcdir} -i ${lispdir}site-packages \
+		${obj_src} ${mule_obj_src} \
 	        ${mallocdocsrc} ${rallocdocsrc} ${lispdir}version.el \
 		${lisp} > ${libsrc}DOC
 


Index: lib-src/make-docfile.c
===================================================================
RCS file: /usr/local/xemacs/xemacs-20.0/lib-src/make-docfile.c,v
retrieving revision 1.2
diff -u -r1.2 make-docfile.c
--- make-docfile.c	1997/01/23 05:29:21	1.2
+++ make-docfile.c	1997/02/27 00:12:50
@@ -33,6 +33,9 @@
  Then comes F for a function or V for a variable.
  Then comes the function or variable name, terminated with a newline.
  Then comes the documentation for that function or variable.
+
+ Added 19.15/20.1:  `-i site-packages' allow installer to dump extra packages
+ without modifying Makefiles, etc.
  */
 
 #define NO_SHORTNAMES   /* Tell config not to load remap.h */
@@ -74,6 +77,7 @@
 
 /* Stdio stream for output to the DOC file.  */
 static FILE *outfile;
+static char *extra_elcs = NULL;
 
 enum
 {
@@ -130,6 +134,41 @@
   return result;
 }
 
+static char *
+next_extra_elc(char *extra_elcs)
+{
+  static FILE *fp = NULL;
+  static char line_buf[BUFSIZ];
+  char *p = line_buf+1;
+
+  if (!fp) {
+    if (!extra_elcs) {
+      return NULL;
+    } else if (!(fp = fopen(extra_elcs, "r"))) {
+      /* It is not an error if this file doesn't exist. */
+      /*fatal("error opening site package file list", 0);*/
+      return NULL;
+    }
+    fgets(line_buf, BUFSIZ, fp);
+  }
+
+again:
+  if (!fgets(line_buf, BUFSIZ, fp)) {
+    fclose(fp);
+    fp = NULL;
+    return NULL;
+  }
+  line_buf[0] = '\0';
+  if (strlen(p) <= 2 || strlen(p) >= (BUFSIZ - 5)) {
+    /* reject too short or too long lines */
+    goto again;
+  }
+  p[strlen(p) - 2] = '\0';
+  strcat(p, ".elc");
+
+  return p;
+}
+
 
 int
 main (int argc, char **argv)
@@ -175,6 +214,11 @@
       i += 2;
     }
 
+  if (argc > (i + 1) && !strcmp(argv[i], "-i")) {
+    extra_elcs = argv[i + 1];
+    i += 2;
+  }
+
   if (outfile == 0)
     fatal ("No output file specified", "");
 
@@ -190,6 +234,15 @@
 	/* err_count seems to be {mis,un}used */
 	err_count += scan_file (argv[i]);
     }
+
+  if (extra_elcs) {
+    char *p;
+
+    while ((p = next_extra_elc(extra_elcs)) != NULL) {
+      err_count += scan_file(p);
+    }
+  }
+
   putc ('\n', outfile);
 #ifndef VMS
   exit (err_count > 0);

-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.

--Multipart_Wed_Feb_26_16:52:51_1997-1--

