* bug#23638: "load" should use directory from load-file-name as a final fallback
@ 2016-05-28 14:33 Robert Weiner
2016-05-28 14:49 ` bug#23638: Someone thought relative file loading was enough of a problem, he wrote a whole package for it Robert Weiner
2021-02-07 13:14 ` bug#23638: "load" should use directory from load-file-name as a final fallback Lars Ingebrigtsen
0 siblings, 2 replies; 4+ messages in thread
From: Robert Weiner @ 2016-05-28 14:33 UTC (permalink / raw
To: 23638
[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]
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.
[-- Attachment #2: Type: text/html, Size: 1436 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#23638: Someone thought relative file loading was enough of a problem, he wrote a whole package for it.
2016-05-28 14:33 bug#23638: "load" should use directory from load-file-name as a final fallback Robert Weiner
@ 2016-05-28 14:49 ` Robert Weiner
2021-02-07 13:14 ` bug#23638: "load" should use directory from load-file-name as a final fallback Lars Ingebrigtsen
1 sibling, 0 replies; 4+ messages in thread
From: Robert Weiner @ 2016-05-28 14:49 UTC (permalink / raw
To: 23638
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
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
[-- Attachment #2: Type: text/html, Size: 338 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#23638: "load" should use directory from load-file-name as a final fallback
2016-05-28 14:33 bug#23638: "load" should use directory from load-file-name as a final fallback Robert Weiner
2016-05-28 14:49 ` bug#23638: Someone thought relative file loading was enough of a problem, he wrote a whole package for it Robert Weiner
@ 2021-02-07 13:14 ` Lars Ingebrigtsen
2022-05-08 12:22 ` Lars Ingebrigtsen
1 sibling, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2021-02-07 13:14 UTC (permalink / raw
To: Robert Weiner; +Cc: 23638
Robert Weiner <rswgnu@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
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#23638: "load" should use directory from load-file-name as a final fallback
2021-02-07 13:14 ` bug#23638: "load" should use directory from load-file-name as a final fallback Lars Ingebrigtsen
@ 2022-05-08 12:22 ` Lars Ingebrigtsen
0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-05-08 12:22 UTC (permalink / raw
To: Robert Weiner; +Cc: 23638
Lars Ingebrigtsen <larsi@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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-08 12:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-28 14:33 bug#23638: "load" should use directory from load-file-name as a final fallback Robert Weiner
2016-05-28 14:49 ` bug#23638: Someone thought relative file loading was enough of a problem, he wrote a whole package for it Robert Weiner
2021-02-07 13:14 ` bug#23638: "load" should use directory from load-file-name as a final fallback Lars Ingebrigtsen
2022-05-08 12:22 ` Lars Ingebrigtsen
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.