GNU bug report logs - #17467
24.3; locate-library returning spurious path

Previous Next

Package: emacs;

Reported by: Alex Kosorukoff <alex <at> 3form.com>

Date: Sun, 11 May 2014 16:51:02 UTC

Severity: minor

Tags: patch

Found in version 24.3

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #88 received at 17467 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: Alex Kosorukoff <alex <at> 3form.com>, 17467 <17467 <at> debbugs.gnu.org>
Subject: Re: bug#17467: 24.3; locate-library returning spurious path
Date: Tue, 25 Aug 2020 12:39:06 +0200
Stefan Monnier <monnier <at> 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




This bug report was last modified 4 years and 226 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.