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: Alex Kosorukoff
Subject: bug#17467: 24.3; locate-library returning spurious path
Date: Sun, 11 May 2014 21:36:22 -0700

I like the idea of optimizing out the second string-match, though that variant matched tramp.el.old which is not a valid library name. Here is a modifed version using the same idea except it skips files like tramp.el.old.

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: address@hidden
# target_branch: :parent
# testament_sha1: 330ab5b4527e49ea46d8d16a6d47e5822247ce77
# timestamp: 2014-05-11 21:23:50 -0700
# base_revision_id: address@hidden
#   1mzcrftziwhrw9hl
# Begin patch
=== modified file 'lisp/subr.el'
--- lisp/subr.el        2014-04-09 01:48:07 +0000
+++ lisp/subr.el        2014-05-12 04:22:18 +0000
@@ -1857,10 +1857,14 @@
                                        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 ((file
+         (locate-file
+          library
+          (or path load-path)
+          (unless nosuffix
+            (if (string-match "\\.elc?\\(\\.gz\\)?\\'" library)
+                (if (= 2 (length (match-data))) load-file-rep-suffixes)
+              (get-load-suffixes))))))
     (if interactive-call
        (if file
            (message "Library is file %s" (abbreviate-file-name file))

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWdDpudEABgd/gDN0FUFQ4//3
8wgABL////BgCI+FAA0AAAAAAAAMkk2p6mmgBoDQaADTQAABoGlQZPSMmynpqDJo0AaZADTIyABz
CYBMAJhMJpgAAEyaaBjmEwCYATCYTTAAAJk00DHMJgEwAmEwmmAAATJpoGCpRAJoATEDRDQCYJT1
NNqY1NkylAzQWMD1e2laABxxxTQHTYJXxEfUiG4Q6b22N1Uag1frP3pbf2aB7XuzlcK84k5F8VNn
K7C8uNBohJUOdK//P1n8bZ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un, May 11, 2014 at 7:18 PM, Stefan Monnier <address@hidden> wrote:
> 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))



reply via email to

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