diff lisp/code-files.el @ 883:1e9272790fe0

[xemacs-hg @ 2002-06-26 00:11:15 by youngs] 2002-06-24 John Paul Wallington <jpw@shootybangbang.com> * obsolete.el (frame-parameter): New compatibility function. (makehash): Ditto. (buffer-local-value): Ditto. (line-beginning-position): New compatibility alias for `point-at-bol'. (line-end-position): New compatibility alias for `point-at-eol'. * subr.el (with-temp-message): New function; sync with GNU Emacs 21. (bound-and-true-p): Ditto. (propertize): New function. (delete-and-extract-region): Ditto. 2002-06-24 Jerry James <james@xemacs.org> * code-files.el (load): Look for a binary module if no Lisp file with the correct name is found.
author youngs
date Wed, 26 Jun 2002 00:11:16 +0000
parents 42375619fa45
children 25e260cb7994
line wrap: on
line diff
--- a/lisp/code-files.el	Tue Jun 25 21:20:47 2002 +0000
+++ b/lisp/code-files.el	Wed Jun 26 00:11:16 2002 +0000
@@ -220,56 +220,69 @@
 ;(defun convert-mbox-coding-system (filename visit start end) ...)
 
 (defun load (file &optional noerror nomessage nosuffix)
-  "Execute a file of Lisp code named FILE.
-First tries FILE with .elc appended, then tries with .el,
- then tries FILE unmodified.  Searches directories in load-path.
+  "Execute a file of Lisp code named FILE, or load a binary module.
+First tries to find a Lisp FILE with .elc appended, then with .el, then with
+ FILE unmodified.  If unsuccessful, tries to find a binary module FILE with
+ .ell appended, then with .dll, then with .so, and finally unmodified.
+Searches directories in load-path for Lisp files, and in module-load-path
+ for binary modules.
 If optional second arg NOERROR is non-nil,
  report no error if FILE doesn't exist.
 Print messages at start and end of loading unless
  optional third arg NOMESSAGE is non-nil.
 If optional fourth arg NOSUFFIX is non-nil, don't try adding
- suffixes .elc or .el to the specified name FILE.
+ suffixes .elc, .el, or .ell to the specified name FILE.
 Return t if file exists."
   (let* ((filename (substitute-in-file-name file))
 	 (handler (find-file-name-handler filename 'load))
 	 (path nil))
     (if handler
 	(funcall handler 'load filename noerror nomessage nosuffix)
-      (if (or (<= (length filename) 0)
-	      (null (setq path
-			  (locate-file filename load-path
+      ;; First try to load a Lisp file
+      (if (and (> (length filename) 0)
+	       (setq path (locate-file filename load-path
 				       (and (not nosuffix)
-					    '(".elc" ".el" ""))))))
-	  (and (null noerror)
-	       (signal 'file-error (list "Cannot open load file" filename)))
-	;; now use the internal load to actually load the file.
-	(load-internal
-	 file noerror nomessage nosuffix
-	 (let ((elc ; use string= instead of string-match to keep match-data.
+					    '(".elc" ".el" "")))))
+	  ;; now use the internal load to actually load the file.
+	  (load-internal
+	   file noerror nomessage nosuffix
+	   (let ((elc ; use string= instead of string-match to keep match-data.
 		(equalp ".elc" (substring path -4))))
-	   (or (and (not elc) coding-system-for-read) ; prefer for source file
-	       ;; find magic-cookie
-	       (let ((codesys (find-coding-system-magic-cookie-in-file path)))
-		 (when codesys
-		   (setq codesys (intern codesys))
-		   (if (find-coding-system codesys) codesys)))
-	       (if elc
-		   ;; if reading a byte-compiled file and we didn't find
-		   ;; a coding-system magic cookie, then use `binary'.
-		   ;; We need to guarantee that we never do autodetection
-		   ;; on byte-compiled files because confusion here would
-		   ;; be a very bad thing.  Pre-existing byte-compiled
-		   ;; files are always in the `binary' coding system.
-		   ;; Also, byte-compiled files always use `lf' to terminate
-		   ;; a line; don't risk confusion here either.
-		   'binary
-		 (or (find-file-coding-system-for-read-from-filename path)
-		     ;; looking up in `file-coding-system-alist'.
-		     ;; otherwise use `buffer-file-coding-system-for-read',
-		     ;; as normal
-		     buffer-file-coding-system-for-read)
-		 )))
-	 )))))
+	     (or (and (not elc) coding-system-for-read) ;prefer for source file
+		 ;; find magic-cookie
+		 (let ((codesys
+			(find-coding-system-magic-cookie-in-file path)))
+		   (when codesys
+		     (setq codesys (intern codesys))
+		     (if (find-coding-system codesys) codesys)))
+		 (if elc
+		     ;; if reading a byte-compiled file and we didn't find
+		     ;; a coding-system magic cookie, then use `binary'.
+		     ;; We need to guarantee that we never do autodetection
+		     ;; on byte-compiled files because confusion here would
+		     ;; be a very bad thing.  Pre-existing byte-compiled
+		     ;; files are always in the `binary' coding system.
+		     ;; Also, byte-compiled files always use `lf' to terminate
+		     ;; a line; don't risk confusion here either.
+		     'binary
+		   (or (find-file-coding-system-for-read-from-filename path)
+		       ;; looking up in `file-coding-system-alist'.
+		       ;; otherwise use `buffer-file-coding-system-for-read',
+		       ;; as normal
+		       buffer-file-coding-system-for-read)
+		   ))))
+	;; The file name is invalid, or we want to load a binary module
+	(if (and (> (length filename) 0)
+		 (setq path (locate-file filename module-load-path
+					 (and (not nosuffix)
+					      '(".ell" ".dll" ".so" "")))))
+	    (if (featurep 'modules)
+		(let ((load-modules-quietly nomessage))
+		  (load-module path))
+	      (signal 'file-error '("This XEmacs does not support modules")))
+	  (and (null noerror)
+	       (signal 'file-error (list "Cannot open load file" filename))))
+	))))
 
 (defvar insert-file-contents-access-hook nil
   "A hook to make a file accessible before reading it.