GNU bug report logs -
#17467
24.3; locate-library returning spurious path
Previous Next
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 #68 received at 17467 <at> debbugs.gnu.org (full text, mbox):
> I think these file names are more appropriate for data files, not
> executable ones. It is undesirable that a name "tramp.gz" will shadow a
> valid library file "tramp.elc" that won't be found as a result.
I think I'm beginning to see what you mean. So far we have simply
considered "if it hurts, don't do it". And it worked well enough.
> When you say those names aren't spurious, do you have a particular
> example of an emacs elisp library in mind which file name ends with
> a suffix other than .el .elc .el.gz .elc.gz?
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.
Stefan
=== modified file 'lisp/subr.el'
--- lisp/subr.el 2014-04-15 17:03:15 +0000
+++ lisp/subr.el 2014-05-12 02:15:04 +0000
@@ -1878,10 +1878,15 @@
load-path (get-load-suffixes)))
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))
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.