* lisp/files.el (require-with-check): Be a bit more lenient (bug74040)
This commit is contained in:
parent
cc6a11f483
commit
0aae02a374
1 changed files with 20 additions and 3 deletions
|
@ -1277,10 +1277,27 @@ NOERROR is equal to `reload'), or otherwise emit a warning."
|
||||||
;; file, so we're done.
|
;; file, so we're done.
|
||||||
(when (eq lh load-history)
|
(when (eq lh load-history)
|
||||||
;; If `require' did nothing, we need to make sure that was warranted.
|
;; If `require' did nothing, we need to make sure that was warranted.
|
||||||
(let ((fn (locate-file (or filename (symbol-name feature))
|
(let* ((fn (locate-file (or filename (symbol-name feature))
|
||||||
load-path (get-load-suffixes))))
|
load-path (get-load-suffixes) nil
|
||||||
|
)) ;; load-prefer-newer
|
||||||
|
;; We used to look for `fn' in `load-history' with `assoc'
|
||||||
|
;; which works in most cases, but in some cases (e.g. when
|
||||||
|
;; `load-prefer-newer' is set) `locate-file' can return a
|
||||||
|
;; different file than the file that `require' would load,
|
||||||
|
;; so the file won't be found in `load-history' even though
|
||||||
|
;; we did load "it". (bug#74040)
|
||||||
|
;; So use a "permissive" search which doesn't pay attention to
|
||||||
|
;; differences between file extensions.
|
||||||
|
(prefix (if (string-match
|
||||||
|
(concat (regexp-opt (get-load-suffixes)) "\\'") fn)
|
||||||
|
(concat (substring fn 0 (match-beginning 0)) ".")
|
||||||
|
fn))
|
||||||
|
(lh load-history))
|
||||||
|
(while (and lh (let ((file (car-safe (car lh))))
|
||||||
|
(not (and file (string-prefix-p prefix file)))))
|
||||||
|
(setq lh (cdr lh)))
|
||||||
(cond
|
(cond
|
||||||
((assoc fn load-history) nil) ;We loaded the right file.
|
(lh nil) ;We loaded the right file.
|
||||||
((eq noerror 'reload) (load fn nil 'nomessage))
|
((eq noerror 'reload) (load fn nil 'nomessage))
|
||||||
((and fn (memq feature features))
|
((and fn (memq feature features))
|
||||||
(funcall (if noerror #'warn #'error)
|
(funcall (if noerror #'warn #'error)
|
||||||
|
|
Loading…
Add table
Reference in a new issue