Mercurial > hg > xemacs-beta
comparison lisp/code-files.el @ 4385:7a8c613ee283
Don't call substitute-in-file-name haphazardly.
2008-01-04 Michael Sperber <mike@xemacs.org>
* code-files.el (insert-file-contents):
(load): Don't call `substitute-in-file-name' on the file name.
author | Mike Sperber <sperber@deinprogramm.de> |
---|---|
date | Sat, 05 Jan 2008 16:19:37 +0100 |
parents | 41e88d0c934e |
children | a90b63846dc4 |
comparison
equal
deleted
inserted
replaced
4384:c7e65155cb35 | 4385:7a8c613ee283 |
---|---|
233 ;; understand MIME), but in concept -- such high-level decoding should | 233 ;; understand MIME), but in concept -- such high-level decoding should |
234 ;; be done by mail readers, not by IO code! Removed 2000-04-18. | 234 ;; be done by mail readers, not by IO code! Removed 2000-04-18. |
235 | 235 |
236 ;(defun convert-mbox-coding-system (filename visit start end) ...) | 236 ;(defun convert-mbox-coding-system (filename visit start end) ...) |
237 | 237 |
238 (defun load (file &optional noerror nomessage nosuffix) | 238 (defun load (filename &optional noerror nomessage nosuffix) |
239 "Execute a file of Lisp code named FILE, or load a binary module. | 239 "Execute a file of Lisp code named FILENAME, or load a binary module. |
240 First tries to find a Lisp FILE with .elc appended, then with .el, then with | 240 First tries to find a Lisp file FILENAME with .elc appended, then with .el, then with |
241 FILE unmodified. If unsuccessful, tries to find a binary module FILE with | 241 FILENAME unmodified. If unsuccessful, tries to find a binary module FILE with |
242 the elements of `module-extensions' appended, one at a time. | 242 the elements of `module-extensions' appended, one at a time. |
243 Searches directories in load-path for Lisp files, and in `module-load-path' | 243 Searches directories in load-path for Lisp files, and in `module-load-path' |
244 for binary modules. | 244 for binary modules. |
245 If optional second arg NOERROR is non-nil, | 245 If optional second arg NOERROR is non-nil, |
246 report no error if FILE doesn't exist. | 246 report no error if FILE doesn't exist. |
248 optional third arg NOMESSAGE is non-nil. | 248 optional third arg NOMESSAGE is non-nil. |
249 If optional fourth arg NOSUFFIX is non-nil, don't try adding suffixes | 249 If optional fourth arg NOSUFFIX is non-nil, don't try adding suffixes |
250 .elc, .el, or elements of `module-extensions' to the specified name FILE. | 250 .elc, .el, or elements of `module-extensions' to the specified name FILE. |
251 Return t if file exists." | 251 Return t if file exists." |
252 (declare (special load-modules-quietly)) | 252 (declare (special load-modules-quietly)) |
253 (let* ((filename (substitute-in-file-name file)) | 253 (let ((handler (find-file-name-handler filename 'load)) |
254 (handler (find-file-name-handler filename 'load)) | 254 (path nil)) |
255 (path nil)) | |
256 (if handler | 255 (if handler |
257 (funcall handler 'load filename noerror nomessage nosuffix) | 256 (funcall handler 'load filename noerror nomessage nosuffix) |
258 ;; First try to load a Lisp file | 257 ;; First try to load a Lisp file |
259 (if (and (> (length filename) 0) | 258 (if (and (> (length filename) 0) |
260 (setq path (locate-file filename load-path | 259 (setq path (locate-file filename load-path |
261 (and (not nosuffix) | 260 (and (not nosuffix) |
262 '(".elc" ".el" ""))))) | 261 '(".elc" ".el" ""))))) |
263 ;; now use the internal load to actually load the file. | 262 ;; now use the internal load to actually load the file. |
264 (load-internal | 263 (load-internal |
265 file noerror nomessage nosuffix | 264 filename noerror nomessage nosuffix |
266 (let ((elc ; use string= instead of string-match to keep match-data. | 265 (let ((elc ; use string= instead of string-match to keep match-data. |
267 (equalp ".elc" (substring path -4)))) | 266 (equalp ".elc" (substring path -4)))) |
268 (or (and (not elc) coding-system-for-read) ;prefer for source file | 267 (or (and (not elc) coding-system-for-read) ;prefer for source file |
269 ;; find magic-cookie | 268 ;; find magic-cookie |
270 (let ((codesys | 269 (let ((codesys |
271 (find-coding-system-magic-cookie-in-file path))) | 270 (find-coding-system-magic-cookie-in-file path))) |
272 (when codesys | 271 (when codesys |
273 (setq codesys (intern codesys)) | 272 (setq codesys (intern codesys)) |
399 coding-system determination procedure. | 398 coding-system determination procedure. |
400 | 399 |
401 See also `insert-file-contents-access-hook', | 400 See also `insert-file-contents-access-hook', |
402 `insert-file-contents-pre-hook', `insert-file-contents-error-hook', | 401 `insert-file-contents-pre-hook', `insert-file-contents-error-hook', |
403 and `insert-file-contents-post-hook'." | 402 and `insert-file-contents-post-hook'." |
404 (let* ((expanded (substitute-in-file-name filename)) | 403 (let ((handler (find-file-name-handler filename 'insert-file-contents))) |
405 (handler (find-file-name-handler expanded 'insert-file-contents))) | |
406 (if handler | 404 (if handler |
407 (funcall handler 'insert-file-contents filename visit start end replace) | 405 (funcall handler 'insert-file-contents filename visit start end replace) |
408 (let (return-val coding-system used-codesys) | 406 (let (return-val coding-system used-codesys) |
409 ;; OK, first load the file. | 407 ;; OK, first load the file. |
410 (condition-case err | 408 (condition-case err |