From 22a2cceb8730f76c66c248866e389102ea60b030 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Mon, 21 Oct 2024 20:21:10 -0400 Subject: [PATCH] * lisp/files.el (require-with-check): Provide more info in the error message Rather than only show the "new" file to be loaded, show also the name of the currently loaded file, to clarify the conflict. (cherry picked from commit 8a2fbddf17b4beb31d19161769066a4c1bd8bab0) --- lisp/files.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lisp/files.el b/lisp/files.el index 10c8999b3ef..1186d1cc2c3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1326,15 +1326,17 @@ NOERROR is equal to `reload'), or otherwise emit a warning." ((assoc fn load-history) nil) ;We loaded the right file. ((eq noerror 'reload) (load fn nil 'nomessage)) ((and fn (memq feature features)) - (funcall (if noerror #'warn #'error) - "Feature `%S' is now provided by a different file %s" - feature fn)) + (let ((oldfile (symbol-file feature 'provide))) + (funcall (if noerror #'warn #'error) + "Feature `%S' loaded from %S is now provided by %S" + feature (if oldfile (abbreviate-file-name oldfile)) + (abbreviate-file-name fn)))) (fn (funcall (if noerror #'warn #'error) - "Could not load file %s" fn)) + "Could not load file: %s" fn)) (t (funcall (if noerror #'warn #'error) - "Could not locate file %s in load path" + "Could not locate file in load path: %s" (or filename (symbol-name feature))))))) res)) @@ -4463,7 +4465,7 @@ already the major mode." (pcase var ('mode (let ((mode (intern (concat (downcase (symbol-name val)) - "-mode")))) + "-mode")))) (set-auto-mode-0 mode t))) ('eval (pcase val -- 2.39.2