From 79f5c7bbbfba90c9f1b170922f6c0af414b4a74b Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 10 Nov 2024 16:50:36 -0500 Subject: [PATCH] lisp/files.el (require-with-check): Fix bug#74091. (cherry picked from commit 3496234c8ed10a14f740199722ec727bd43c82d3) --- lisp/files.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index af2716077f0..f55227f3e16 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1323,7 +1323,7 @@ NOERROR is equal to `reload'), or otherwise emit a warning." (let* ((fn (locate-file (or filename (symbol-name feature)) load-path (get-load-suffixes) nil )) ;; load-prefer-newer - ;; We used to look for `fn' in `load-history' with `assoc' + ;; 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, @@ -1331,10 +1331,11 @@ NOERROR is equal to `reload'), or otherwise emit a warning." ;; 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)) + (prefix (when fn + (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))))) -- 2.39.5