diff --git a/lisp/files.el b/lisp/files.el index 898f9d23cf8..63a08ce5b22 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1275,7 +1275,7 @@ NOERROR is equal to `reload'), or otherwise emit a warning." (res (require feature filename (if (eq noerror 'reload) nil noerror)))) ;; If the `feature' was not yet provided, `require' just loaded the right ;; file, so we're done. - (when (eq lh load-history) + (when (and res (eq lh load-history)) ;; If `require' did nothing, we need to make sure that was warranted. (let* ((fn (locate-file (or filename (symbol-name feature)) load-path (get-load-suffixes) nil @@ -1288,11 +1288,10 @@ 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 (when fn - (if (string-match - (concat (regexp-opt (get-load-suffixes)) "\\'") fn) - (concat (substring fn 0 (match-beginning 0)) ".") - fn))) + (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)))))