[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: require (was: Re: Hooks in minor modes)
From: |
Emanuel Berg |
Subject: |
Re: require (was: Re: Hooks in minor modes) |
Date: |
Tue, 04 May 2021 04:29:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Jean Louis wrote:
> If I put script A and script B in the directory ~/tmp and
> push "." into load-path, and then during the day move to
> directory ~/lib I will not be able to invoke in ~/lib any
> script neither in M-: eval that will make the function (load
> "A") nor (load "B") work. This is because I have changed
> current directory.
The objective is to make sure when you `require' B from A,
as long as they are in the same directory, A will find B,
because A will first look in its own directory.
That way you can place the directory containing A and
B anywhere you like. OTOH if you hard-code the load path, if
you move it somewhere else, then A won't find B anymore.
Now, I don't know if that is actually what happens in 100% of
the cases using the "." method, because I don't know the
internals of how and when and to what the working directory is
computed, but to me it makes sense that whenever you require
something from a source file, the working directory would be
that of that source file's position in the file system...
Anyway it seems to work fine so far, here is the Makefile:
https://dataswamp.org/~incal/terror-3/Makefile
> If I have some bunch of development scripts in
> ~/Programming/emacs-lisp, then I will put that directory and
> new scripts there, so I will be able to load them any time
> from there, regardless of the current directory.
Sure, if you have a single directory for everything! All path
problems solved :)
> Make a package, install it.
You don't have to make a package of every single source file
that is ever needed someplace else, see this simple file for
example which is still used in 11 of my other Elisp files:
https://dataswamp.org/~incal/emacs-init/close.el
> In packages I use `require' and not `load', I think every
> package directory is added to load-path automatically.
> So I do not need to think about load-path at all
Indeed, because you seem to think there are only two types of
source files, system wide libraries that are globally
available, and then all other files, that `require' these
libraries and only these libraries...
Fortunately, it isn't that simple :)
--
underground experts united
https://dataswamp.org/~incal