On Wed, Nov 11, 2009 at 8:20 PM, Stefan Monnier <address@hidden>
> When load-file-name is nil, this uses the name of default directory ofYou obviously know enough about the problem to "fix it" further
> current buffer. But that's not the same as the directory of the file
> containing the load-relative function.
> For example, I could have eval'd a buffer that did a load-relative of a file
> in a different directory. Even without this, I can change the default
> directory using the cd function. And changing the default directory never
> changes the file location of the file issuing load-relative.
> Any other thoughts?
Huh? If I knew a good solution to this short of changing the source code, I wouldn't be asking.
(e.g. using buffer-file-name if you prefer it to default-directory).
What strikes me wrong about going in the direction of using buffer-file-name or using buffers is that that we are introspecting about is the running code.
I just took a look at the src/lread.c and although it is a somewhat bit mysterious to me, from what I gather from readevalloop (and I could be very very wrong here) is that when a file is read in, perhaps there is no buffer created in the Emacs sense.
Avoiding buffer creation to read in a Lisp file make sense because one wants reading Lisp code to be fast; furthemore there is no reason to store the entire source contents as source contents after the file is read/eval'd. (The vast majority of compilers don't save the source text).
I don't see any point in fixing it further, since there will always be
corner cases where it doesn't do what the user intended.
A couple of things strike me as weird.
First, none of the examples I have given do I find really corner case. These and many more have come up. (Recall that I have been using this mode of working, and I gather from prior remarks you haven't.)
Second, a reason one might try to encapsulate this in a library is to be able to handle as many of the corner cases as possible so run-of-the-mill users need not have to be concerned - they can use the feature and have confidence that it does the right thing.
Thanks for the help.