bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17467: 24.3; locate-library returning spurious path


From: Lars Ingebrigtsen
Subject: bug#17467: 24.3; locate-library returning spurious path
Date: Tue, 25 Aug 2020 12:39:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

> There are a few (~/.emacs being the most obvious), but admittedly,
> I think they all share the property of not being searched for in
> load-path.  So we could probably strengthen the search along the lines
> you suggest without (hopefully) breaking existing code with a hack along
> the lines of the one below.

I've respun the patch for Emacs 28.  It sounds reasonable to me, but the
use case isn't really compelling.  It breaks the
so-long-tests-commentary test, which basically does:

(finder-commentary "so-long")

So I'm not sure whether it makes sense to proceed with this change...

diff --git a/lisp/subr.el b/lisp/subr.el
index a58a873a33..6eb2f61eb0 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2302,10 +2302,15 @@ locate-library
 string.  When run interactively, the argument INTERACTIVE-CALL is t,
 and the file name is displayed in the echo area."
   (interactive (list (read-library-name) nil nil t))
-  (let ((file (locate-file library
-                          (or path load-path)
-                          (append (unless nosuffix (get-load-suffixes))
-                                  load-file-rep-suffixes))))
+  (let* ((suffixes
+          (nconc (unless nosuffix (get-load-suffixes))
+                 (when (or (file-name-absolute-p library)
+                           ;; (load "foo.el") should find /bar/foo.el.gz,
+                           ;; but (load "foo") should not find /bar/foo.gz.
+                           (string-match "\\.el\\(\\.[[:alnum:]]+\\)?"
+                                         library))
+                   load-file-rep-suffixes)))
+         (file (locate-file library (or path load-path) suffixes)))
     (if interactive-call
        (if file
            (message "Library is file %s" (abbreviate-file-name file))


-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]