* lisp/net/ange-ftp.el (ange-ftp-load): Add MUST-SUFFIX argument.
* lisp/net/tramp.el (tramp-handle-load): Adapt MUST_SUFFIX test.
* src/lread.c (Fload): Call handler with must_suffix.
* test/lisp/net/tramp-tests.el (tramp-test27-load): Extend test.
((eq identification 'localname) localname)
(t (ange-ftp-replace-name-component file ""))))))
-(defun ange-ftp-load (file &optional noerror nomessage nosuffix)
+(defun ange-ftp-load (file &optional noerror nomessage nosuffix must-suffix)
(if (ange-ftp-ftp-name file)
(let ((tryfiles (if nosuffix
(list file)
(or noerror
(signal 'file-error (list "Cannot open load file" file)))
nil))
- (ange-ftp-real-load file noerror nomessage nosuffix)))
+ (ange-ftp-real-load file noerror nomessage nosuffix must-suffix)))
;; Calculate default-unhandled-directory for a given ange-ftp buffer.
(defun ange-ftp-unhandled-file-name-directory (_filename)
(setq file (concat file ".elc")))
((file-exists-p (concat file ".el"))
(setq file (concat file ".el")))))
- (when must-suffix
- ;; The first condition is always true for absolute file names.
- ;; Included for safety's sake.
- (unless (or (file-name-directory file)
- (string-match-p (rx ".el" (? "c") eos) file))
- (tramp-error
- v 'file-error
- "File `%s' does not include a `.el' or `.elc' suffix" file)))
+ (when (and must-suffix (not (string-match-p (rx ".el" (? "c") eos) file)))
+ (tramp-error
+ v 'file-error "File `%s' does not include a `.el' or `.elc' suffix" file))
(unless (or noerror (file-exists-p file))
(tramp-error v 'file-missing file))
(if (not (file-exists-p file))
/* If file name is magic, call the handler. */
handler = Ffind_file_name_handler (file, Qload);
if (!NILP (handler))
- return call5 (handler, Qload, file, noerror, nomessage, nosuffix);
+ return
+ call6 (handler, Qload, file, noerror, nomessage, nosuffix, must_suffix);
/* The presence of this call is the result of a historical accident:
it used to be in every file-operation and when it got removed
(load tmp-name 'noerror 'nomessage))
(should-not (featurep 'tramp-test-load))
(write-region "(provide 'tramp-test-load)" nil tmp-name)
- ;; `load' in lread.c does not pass `must-suffix'. Why?
- ;;(should-error
- ;; (load tmp-name nil 'nomessage 'nosuffix 'must-suffix)
- ;; :type 'file-error)
+ ;; `load' in lread.c passes `must-suffix' since Emacs 29.
+ ;; In Ange-FTP, `must-suffix' is ignored.
+ (when (and (tramp--test-emacs29-p)
+ (not (tramp--test-ange-ftp-p)))
+ (should-error
+ (load tmp-name nil 'nomessage 'nosuffix 'must-suffix)
+ :type 'file-error))
(load tmp-name nil 'nomessage 'nosuffix)
(should (featurep 'tramp-test-load)))