From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#17467: 24.3; locate-library returning spurious path Date: Sun, 11 May 2014 22:18:03 -0400 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1399861169 31566 80.91.229.3 (12 May 2014 02:19:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 May 2014 02:19:29 +0000 (UTC) Cc: 17467 <17467@debbugs.gnu.org> To: Alex Kosorukoff Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon May 12 04:19:22 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Wjfpp-0000qd-ND for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 May 2014 04:19:21 +0200 Original-Received: from localhost ([::1]:35071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjfpo-0006ex-PJ for geb-bug-gnu-emacs@m.gmane.org; Sun, 11 May 2014 22:19:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wjfpe-0006eS-K6 for bug-gnu-emacs@gnu.org; Sun, 11 May 2014 22:19:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WjfpX-0006sX-4c for bug-gnu-emacs@gnu.org; Sun, 11 May 2014 22:19:10 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjfpX-0006sR-1w for bug-gnu-emacs@gnu.org; Sun, 11 May 2014 22:19:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WjfpW-0002hG-Fb for bug-gnu-emacs@gnu.org; Sun, 11 May 2014 22:19:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 May 2014 02:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17467 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17467-submit@debbugs.gnu.org id=B17467.139986109310270 (code B ref 17467); Mon, 12 May 2014 02:19:02 +0000 Original-Received: (at 17467) by debbugs.gnu.org; 12 May 2014 02:18:13 +0000 Original-Received: from localhost ([127.0.0.1]:59915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjfoi-0002fa-Kj for submit@debbugs.gnu.org; Sun, 11 May 2014 22:18:13 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:54551) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wjfof-0002fO-A5 for 17467@debbugs.gnu.org; Sun, 11 May 2014 22:18:10 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id s4C2I4mp022938; Sun, 11 May 2014 22:18:05 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 2DFE9601D9; Sun, 11 May 2014 22:18:03 -0400 (EDT) In-Reply-To: (Alex Kosorukoff's message of "Sun, 11 May 2014 17:20:23 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4939=0 X-NAI-Spam-Version: 2.3.0.9378 : core <4939> : inlines <853> : streams <1180070> : uri <1754400> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:88950 Archived-At: > 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))