changeset 1048:edc95b5fe4cb

[xemacs-hg @ 2002-10-11 14:09:46 by james] Make modules autoload only if the module exists. Fix a paths bug that caused module-directory, site-module-directory, and module-load-path to be wrong.
author james
date Fri, 11 Oct 2002 14:10:03 +0000
parents c46be6682f03
children c90a99292154
files lisp/ChangeLog lisp/autoload.el lisp/dump-paths.el
diffstat 3 files changed, 64 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Oct 10 21:54:15 2002 +0000
+++ b/lisp/ChangeLog	Fri Oct 11 14:10:03 2002 +0000
@@ -1,3 +1,16 @@
+2002-10-10  Jerry James  <james@xemacs.org>
+
+	* autoload.el (generate-file-autoloads-1): Use new print-autoload
+	margin parameter.
+	* autoload.el (generate-c-file-autoloads-1): Ditto.  Fix typo in
+	docstring.  Conditionalize module autoloads on the presence of the
+	module in module-directory.
+	* autoload.el (print-autoload): New margin parameter to prettify
+	module auto-autoloads without affecting Lisp auto-autoloads.
+	* dump-paths.el (startup-setup-paths): Always set
+	module-directory, site-module-directory, and module-load-path,
+	even when not called-early.
+
 2002-09-22  Ville Skyttä  <ville.skytta@xemacs.org>
 
 	* package-get.el (package-get-download-sites): Bring sites list
--- a/lisp/autoload.el	Thu Oct 10 21:54:15 2002 +0000
+++ b/lisp/autoload.el	Fri Oct 11 14:10:03 2002 +0000
@@ -272,7 +272,7 @@
 			      (setq autoloads-done (cons (nth 1 form)
 							 autoloads-done))
 			    (setq autoload form))
-			  (print-autoload autoload doc-string-elt outbuf))
+			  (print-autoload autoload doc-string-elt outbuf ""))
 		      ;; Copy the rest of the line to the output.
 		      (let ((begin (point)))
 			;; (terpri outbuf)
@@ -334,7 +334,7 @@
 
 (defun* generate-c-file-autoloads-1 (file funlist)
   "Insert at point a loaddefs autoload section for the C file FILE.
-autoloads are generated for Defuns and defmacros in FILE
+autoloads are generated for defuns and defmacros in FILE
 marked by `generate-c-autoload-cookie' (which see).
 If FILE is being visited in a buffer, the contents of the buffer
 are used."
@@ -382,6 +382,16 @@
 		(if funlist
 		    (progn
 		      (message "Generating autoloads for %s..." trim-name)
+		      (princ "(when (or\n" outbuf)
+		      (princ (format
+			      "       (file-exists-p (expand-file-name \"%s.ell\" module-directory))\n"
+			      load-name) outbuf)
+		      (princ (format
+			      "       (file-exists-p (expand-file-name \"%s.dll\" module-directory))\n"
+			      load-name) outbuf)
+		      (princ (format
+			      "       (file-exists-p (expand-file-name \"%s.so\" module-directory)))\n"
+			      load-name) outbuf)
 		      (dolist (arg funlist)
 			(goto-char (point-min))
 			(re-search-forward
@@ -392,7 +402,8 @@
 			(let ((autoload (make-c-autoload load-name)))
 			  (when autoload
 			    (push (nth 1 (nth 1 autoload)) autoloads-done)
-			    (print-autoload autoload 3 outbuf)))))
+			    (print-autoload autoload 3 outbuf "  "))))
+		      (princ ")" outbuf))
 		  (goto-char (point-min))
 		  (let ((match
 			 (search-forward generate-c-autoload-cookie nil t)))
@@ -401,15 +412,25 @@
 		      (return-from generate-c-file-autoloads-1))
 
 		    (message "Generating autoloads for %s..." trim-name)
+		    (princ "(when (or\n" outbuf)
+		    (princ (format
+			    "       (file-exists-p (expand-file-name \"%s.ell\" module-directory))\n"
+			    load-name) outbuf)
+		    (princ (format
+			    "       (file-exists-p (expand-file-name \"%s.dll\" module-directory))\n"
+			    load-name) outbuf)
+		    (princ (format
+			    "       (file-exists-p (expand-file-name \"%s.so\" module-directory)))\n"
+			    load-name) outbuf)
 		    (while match
 		      (forward-line 1)
 		      (let ((autoload (make-c-autoload load-name)))
 			(when autoload
 			  (push (nth 1 (nth 1 autoload)) autoloads-done)
-			  (print-autoload autoload 3 outbuf)))
+			  (print-autoload autoload 3 outbuf "  ")))
 		      (setq match
-			    (search-forward generate-c-autoload-cookie nil t))
-		      ))))))
+			    (search-forward generate-c-autoload-cookie nil t)))
+		    (princ ")" outbuf))))))
 	(unless visited
 	  ;; We created this buffer, so we should kill it.
 	  (kill-buffer (current-buffer)))
@@ -425,7 +446,7 @@
     (or noninteractive ; XEmacs: only need one line in -batch mode.
 	(message "Generating autoloads for %s...done" trim-name))))
 
-(defun print-autoload (autoload doc-string-elt outbuf)
+(defun print-autoload (autoload doc-string-elt outbuf margin)
   "Print an autoload form, handling special characters.
 In particular, print docstrings with escapes inserted before left parentheses
 at the beginning of lines and ^L characters."
@@ -433,9 +454,10 @@
       ;; We need to hack the printing because the doc-string must be
       ;; printed specially for make-docfile (sigh).
       (let* ((p (nthcdr (1- doc-string-elt) autoload))
-	     (elt (cdr p)))
+	     (elt (cdr p))
+	     (start-string (format "\n%s(" margin)))
 	(setcdr p nil)
-	(princ "\n(" outbuf)
+	(princ start-string outbuf)
 	;; XEmacs change: don't let ^^L's get into
 	;; the file or sorting is hard.
 	(let ((print-escape-newlines t)
@@ -466,14 +488,15 @@
 	  (save-excursion
 	    (set-buffer outbuf)
 	    (save-excursion
-	      (while (search-backward "\n(" begin t)
+	      (while (search-backward start-string begin t)
 		(forward-char 1)
 		(insert "\\"))))
 	  (if (null (cdr elt))
 	      (princ ")" outbuf)
 	    (princ " " outbuf)
 	    (princ (substring (prin1-to-string (cdr elt)) 1) outbuf))
-	  (terpri outbuf)))
+	  (terpri outbuf)
+	  (princ margin outbuf)))
     ;; XEmacs change: another ^L hack
     (let ((p (save-excursion
 	       (set-buffer outbuf)
--- a/lisp/dump-paths.el	Thu Oct 10 21:54:15 2002 +0000
+++ b/lisp/dump-paths.el	Fri Oct 11 14:10:03 2002 +0000
@@ -119,24 +119,24 @@
 					     site-directory
 					     mule-lisp-directory))
 
-  (if called-early
-      (progn
-	(setq module-directory (paths-find-module-directory roots))
-	(if debug-paths
-	    (princ (format "module-directory:\n%S\n" module-directory)
-		   'external-debugging-output))
-	(setq site-module-directory (and (null inhibit-site-modules)
-					 (paths-find-site-module-directory
-					  roots)))
-	(if (and debug-paths (null inhibit-site-modules))
-	    (princ (format "site-module-directory:\n%S\n"
-			   site-module-directory)
-		   'external-debugging-output))
+  (setq module-directory (paths-find-module-directory roots))
+  (if debug-paths
+      (princ (format "module-directory:\n%S\n" module-directory)
+	     'external-debugging-output))
+  (setq site-module-directory (and (null inhibit-site-modules)
+				   (paths-find-site-module-directory
+				    roots)))
+  (if (and debug-paths (null inhibit-site-modules))
+      (princ (format "site-module-directory:\n%S\n"
+		     site-module-directory)
+	     'external-debugging-output))
 
-	(setq module-load-path (paths-construct-module-load-path
-				roots
-				module-directory
-				site-module-directory)))
+  (setq module-load-path (paths-construct-module-load-path
+			  roots
+			  module-directory
+			  site-module-directory))
+
+  (unless called-early
     (setq Info-directory-list
 	  (paths-construct-info-path
 	   roots early-packages late-packages last-packages))