GNU bug report logs - #23638
"load" should use directory from load-file-name as a final fallback

Previous Next

Package: emacs;

Reported by: Robert Weiner <rswgnu <at> gmail.com>

Date: Sat, 28 May 2016 14:35:02 UTC

Severity: wishlist

Tags: wontfix

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23638 in the body.
You can then email your comments to 23638 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23638; Package emacs. (Sat, 28 May 2016 14:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Robert Weiner <rswgnu <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 28 May 2016 14:35:02 GMT) Full text and rfc822 format available.

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

From: Robert Weiner <rswgnu <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: "load" should use directory from load-file-name as a final fallback
Date: Sat, 28 May 2016 10:33:20 -0400
[Message part 1 (text/plain, inline)]
The "load" function could do more of the right thing in the case where an
absolute path is given in a load call and then within the file loaded,
require or load references are made to relative files whose directories are
not in load path but the files do exist within the directory specified by
the original load.

So for example, we have a testing directory, "/tmp/" not in load-path with
files a.el and b.el.
In a.el, there is the line: (require 'b) and then we do a (load
"/tmp/a.el").  The require of b will fail but since load-file-name is set
to /tmp/a.el, if no matches are found in load-path, it would be a simple
matter to try to resolve b in the directory specified in load-file-name as
a fallback.

This would help in many cases when experimenting with new directories of
code that have not yet been added to the load path.  It also would help the
Emacs package system since it adds only the top-level directory of a
package to load-path when trying to byte-compile the package.  If the
package contains subdirectories, which require or load local files within
these subdirectories, these will fail right now but would succeed with the
above change.

Any comments, suggestions or issues with this?  Please consider
implementing this and help make multi-directory packages a reality.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23638; Package emacs. (Sat, 28 May 2016 14:50:01 GMT) Full text and rfc822 format available.

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

From: Robert Weiner <rswgnu <at> gmail.com>
To: 23638 <at> debbugs.gnu.org
Subject: Someone thought relative file loading was enough of a problem, he
 wrote a whole package for it.
Date: Sat, 28 May 2016 10:49:05 -0400
[Message part 1 (text/plain, inline)]
That package is here:

https://github.com/rocky/emacs-load-relative

But integrating the key points into "load" would be much more useful and
cleaner.

Bob
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23638; Package emacs. (Sun, 07 Feb 2021 13:15:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Robert Weiner <rswgnu <at> gmail.com>
Cc: 23638 <at> debbugs.gnu.org
Subject: Re: bug#23638: "load" should use directory from load-file-name as a
 final fallback
Date: Sun, 07 Feb 2021 14:14:32 +0100
Robert Weiner <rswgnu <at> gmail.com> writes:

> The "load" function could do more of the right thing in the case where
> an absolute path is given in a load call and then within the file
> loaded, require or load references are made to relative files whose
> directories are not in load path but the files do exist within the
> directory specified by the original load.

It's an interesting idea, and I guess it's pretty trivial to implement?
That is, if `load' is called with an absolute path, then bind
`load-path' and add the directory to the value locally.

It sounds convenient, but also kinda chaotic -- if I load "/tmp/foo.el",
then I may not want to load anything else from "/tmp/" just because
"/tmp/foo.el" says "(require 'bar)".  That is, it sounds kinda insecure.

There's also the issue of being consistent -- today,
'(load "/tmp/foo.el")' and `C-x C-f /tmp/foo.el RET' and then
`eval-buffer' gives the same result...  but this wouldn't be the case if
we changed `load' this way.

Now, we could add a new command `load-file-with-directory' or something
that would do this -- that would be more clear, at least, that we're
playing games with `load-path', and would be almost as convenient as if
`load' did this itself.

Any opinions here?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23638; Package emacs. (Sun, 08 May 2022 12:24:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Robert Weiner <rswgnu <at> gmail.com>
Cc: 23638 <at> debbugs.gnu.org
Subject: Re: bug#23638: "load" should use directory from load-file-name as a
 final fallback
Date: Sun, 08 May 2022 14:22:47 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> It sounds convenient, but also kinda chaotic -- if I load "/tmp/foo.el",
> then I may not want to load anything else from "/tmp/" just because
> "/tmp/foo.el" says "(require 'bar)".  That is, it sounds kinda insecure.
>
> There's also the issue of being consistent -- today,
> '(load "/tmp/foo.el")' and `C-x C-f /tmp/foo.el RET' and then
> `eval-buffer' gives the same result...  but this wouldn't be the case if
> we changed `load' this way.
>
> Now, we could add a new command `load-file-with-directory' or something
> that would do this -- that would be more clear, at least, that we're
> playing games with `load-path', and would be almost as convenient as if
> `load' did this itself.
>
> Any opinions here?

Nobody had any opinions here in a year, so I think the conclusion is
that we don't want to do this, and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 08 May 2022 12:24:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 23638 <at> debbugs.gnu.org and Robert Weiner <rswgnu <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 08 May 2022 12:24:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 06 Jun 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 323 days ago.

Previous Next


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