all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alex Kosorukoff <alex@3form.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 17467 <17467@debbugs.gnu.org>
Subject: bug#17467: 24.3; locate-library returning spurious path
Date: Sun, 11 May 2014 21:36:22 -0700	[thread overview]
Message-ID: <CAHD9_tRCCswTqNUGr8F2OB1w3OUkSJanDfDiN=1xTee4exhP7w@mail.gmail.com> (raw)
In-Reply-To: <jwv4n0v4ut9.fsf-monnier+emacsbugs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 6157 bytes --]

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: alex@3form.com-20140512042218-zjdg3v68bbja2rj2
# target_branch: :parent
# testament_sha1: 330ab5b4527e49ea46d8d16a6d47e5822247ce77
# timestamp: 2014-05-11 21:23:50 -0700
# base_revision_id: monnier@iro.umontreal.ca-20140511034953-\
#   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+FAA0AAAAAAAA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NM4idCy3aXl1p7JqW
FIUFpxKF1SsajXSlFKUpkaAoXz20lKSlJTEtMCXxOkeo/sULzRN0oUv1Ixp2FZciwsPuK7CiKmsx
HmeVwz6mkZRNAUilSypNp1nqJeThSSfRFp9DE7C72IvT7kzJ2BtjGUjVPX5E1k0WmBRKCKQoTCSL
kfojNHrRqRn90b6uz0mmNfbO9Nh/+LuSKcKEhodNzog=



On Sun, May 11, 2014 at 7:18 PM, Stefan Monnier <monnier@iro.umontreal.ca>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))
>
>

[-- Attachment #2: Type: text/html, Size: 7997 bytes --]

  reply	other threads:[~2014-05-12  4:36 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-11 16:06 bug#17467: 24.3; locate-library returning spurious path Alex Kosorukoff
2014-05-11 17:03 ` Eli Zaretskii
2014-05-11 17:38   ` Alex Kosorukoff
2014-05-11 17:46     ` Eli Zaretskii
2014-05-11 17:53       ` Alex Kosorukoff
2014-05-11 18:10         ` Eli Zaretskii
2014-05-11 18:55           ` Alex Kosorukoff
2014-05-11 22:55             ` Stefan Monnier
2014-05-12  0:41               ` Alex Kosorukoff
2014-05-11 17:37 ` Glenn Morris
2014-05-11 17:43   ` Alex Kosorukoff
2014-05-11 19:50 ` Stefan Monnier
2014-05-11 20:45   ` Alex Kosorukoff
2014-05-11 21:00     ` Alex Kosorukoff
2014-05-11 21:19     ` Glenn Morris
2014-05-11 22:31       ` Alex Kosorukoff
2014-05-11 21:56     ` Stefan Monnier
2014-05-12  0:20       ` Alex Kosorukoff
2014-05-12  0:32         ` Glenn Morris
2014-05-12  1:35           ` Alex Kosorukoff
2014-05-12  2:02             ` Alex Kosorukoff
2014-05-12  2:18         ` Stefan Monnier
2014-05-12  4:36           ` Alex Kosorukoff [this message]
2014-05-12  6:39             ` Stefan Monnier
2014-05-12 17:46               ` Alex Kosorukoff
2020-08-25 10:39           ` Lars Ingebrigtsen
2020-08-25 14:22             ` Stefan Monnier
2020-08-25 14:25               ` Lars Ingebrigtsen
2020-10-13  1:41             ` Lars Ingebrigtsen
2014-05-15 19:39 ` Stefan Monnier
2014-05-15 23:57   ` Alex Kosorukoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHD9_tRCCswTqNUGr8F2OB1w3OUkSJanDfDiN=1xTee4exhP7w@mail.gmail.com' \
    --to=alex@3form.com \
    --cc=17467@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.