comparison 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
comparison
equal deleted inserted replaced
882:f503f1607e8b 883:1e9272790fe0
218 ;; be done by mail readers, not by IO code! Removed 2000-04-18. 218 ;; be done by mail readers, not by IO code! Removed 2000-04-18.
219 219
220 ;(defun convert-mbox-coding-system (filename visit start end) ...) 220 ;(defun convert-mbox-coding-system (filename visit start end) ...)
221 221
222 (defun load (file &optional noerror nomessage nosuffix) 222 (defun load (file &optional noerror nomessage nosuffix)
223 "Execute a file of Lisp code named FILE. 223 "Execute a file of Lisp code named FILE, or load a binary module.
224 First tries FILE with .elc appended, then tries with .el, 224 First tries to find a Lisp FILE with .elc appended, then with .el, then with
225 then tries FILE unmodified. Searches directories in load-path. 225 FILE unmodified. If unsuccessful, tries to find a binary module FILE with
226 .ell appended, then with .dll, then with .so, and finally unmodified.
227 Searches directories in load-path for Lisp files, and in module-load-path
228 for binary modules.
226 If optional second arg NOERROR is non-nil, 229 If optional second arg NOERROR is non-nil,
227 report no error if FILE doesn't exist. 230 report no error if FILE doesn't exist.
228 Print messages at start and end of loading unless 231 Print messages at start and end of loading unless
229 optional third arg NOMESSAGE is non-nil. 232 optional third arg NOMESSAGE is non-nil.
230 If optional fourth arg NOSUFFIX is non-nil, don't try adding 233 If optional fourth arg NOSUFFIX is non-nil, don't try adding
231 suffixes .elc or .el to the specified name FILE. 234 suffixes .elc, .el, or .ell to the specified name FILE.
232 Return t if file exists." 235 Return t if file exists."
233 (let* ((filename (substitute-in-file-name file)) 236 (let* ((filename (substitute-in-file-name file))
234 (handler (find-file-name-handler filename 'load)) 237 (handler (find-file-name-handler filename 'load))
235 (path nil)) 238 (path nil))
236 (if handler 239 (if handler
237 (funcall handler 'load filename noerror nomessage nosuffix) 240 (funcall handler 'load filename noerror nomessage nosuffix)
238 (if (or (<= (length filename) 0) 241 ;; First try to load a Lisp file
239 (null (setq path 242 (if (and (> (length filename) 0)
240 (locate-file filename load-path 243 (setq path (locate-file filename load-path
241 (and (not nosuffix) 244 (and (not nosuffix)
242 '(".elc" ".el" "")))))) 245 '(".elc" ".el" "")))))
246 ;; now use the internal load to actually load the file.
247 (load-internal
248 file noerror nomessage nosuffix
249 (let ((elc ; use string= instead of string-match to keep match-data.
250 (equalp ".elc" (substring path -4))))
251 (or (and (not elc) coding-system-for-read) ;prefer for source file
252 ;; find magic-cookie
253 (let ((codesys
254 (find-coding-system-magic-cookie-in-file path)))
255 (when codesys
256 (setq codesys (intern codesys))
257 (if (find-coding-system codesys) codesys)))
258 (if elc
259 ;; if reading a byte-compiled file and we didn't find
260 ;; a coding-system magic cookie, then use `binary'.
261 ;; We need to guarantee that we never do autodetection
262 ;; on byte-compiled files because confusion here would
263 ;; be a very bad thing. Pre-existing byte-compiled
264 ;; files are always in the `binary' coding system.
265 ;; Also, byte-compiled files always use `lf' to terminate
266 ;; a line; don't risk confusion here either.
267 'binary
268 (or (find-file-coding-system-for-read-from-filename path)
269 ;; looking up in `file-coding-system-alist'.
270 ;; otherwise use `buffer-file-coding-system-for-read',
271 ;; as normal
272 buffer-file-coding-system-for-read)
273 ))))
274 ;; The file name is invalid, or we want to load a binary module
275 (if (and (> (length filename) 0)
276 (setq path (locate-file filename module-load-path
277 (and (not nosuffix)
278 '(".ell" ".dll" ".so" "")))))
279 (if (featurep 'modules)
280 (let ((load-modules-quietly nomessage))
281 (load-module path))
282 (signal 'file-error '("This XEmacs does not support modules")))
243 (and (null noerror) 283 (and (null noerror)
244 (signal 'file-error (list "Cannot open load file" filename))) 284 (signal 'file-error (list "Cannot open load file" filename))))
245 ;; now use the internal load to actually load the file. 285 ))))
246 (load-internal
247 file noerror nomessage nosuffix
248 (let ((elc ; use string= instead of string-match to keep match-data.
249 (equalp ".elc" (substring path -4))))
250 (or (and (not elc) coding-system-for-read) ; prefer for source file
251 ;; find magic-cookie
252 (let ((codesys (find-coding-system-magic-cookie-in-file path)))
253 (when codesys
254 (setq codesys (intern codesys))
255 (if (find-coding-system codesys) codesys)))
256 (if elc
257 ;; if reading a byte-compiled file and we didn't find
258 ;; a coding-system magic cookie, then use `binary'.
259 ;; We need to guarantee that we never do autodetection
260 ;; on byte-compiled files because confusion here would
261 ;; be a very bad thing. Pre-existing byte-compiled
262 ;; files are always in the `binary' coding system.
263 ;; Also, byte-compiled files always use `lf' to terminate
264 ;; a line; don't risk confusion here either.
265 'binary
266 (or (find-file-coding-system-for-read-from-filename path)
267 ;; looking up in `file-coding-system-alist'.
268 ;; otherwise use `buffer-file-coding-system-for-read',
269 ;; as normal
270 buffer-file-coding-system-for-read)
271 )))
272 )))))
273 286
274 (defvar insert-file-contents-access-hook nil 287 (defvar insert-file-contents-access-hook nil
275 "A hook to make a file accessible before reading it. 288 "A hook to make a file accessible before reading it.
276 `insert-file-contents' calls this hook before doing anything else. 289 `insert-file-contents' calls this hook before doing anything else.
277 Called with two arguments: FILENAME and VISIT, the same as the 290 Called with two arguments: FILENAME and VISIT, the same as the