From: Stefan Monnier Date: Tue, 22 Oct 2024 00:21:10 +0000 (-0400) Subject: * lisp/files.el (require-with-check): Provide more info in the error message X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=22a2cceb8730f76c66c248866e389102ea60b030;p=emacs.git * 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) --- 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