[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: relative load-file

From: Rocky Bernstein
Subject: Re: relative load-file
Date: Fri, 13 Nov 2009 00:59:37 -0500

On Fri, Nov 13, 2009 at 12:24 AM, grischka <address@hidden> wrote:
> [...]
> That is, one wants to load an Emacs Lisp file relative the file

> that issues the load which is often in the same directory or a
> nearby directory.
> This would be easy if there were a variable like __FILE__ that Ruby
> provides.

Why would you need __FILE__ if in emacs you can type much more easily
As in
  (load (concat (file-name-directory #$) "extra-stuff"))

Never ascribe to willful intent that which can be easily explained by ignorance :-)

I've just read up on this, and although it is appealing and another heuristic that can be tried, it looks as though it too is sometimes gives nil in cases where say (car current-load-list) works, just like load-file-name. In fact I'd be curious to learn the differences between it and load-file-name. Off hand, I'd guess that #$ persists after loading -- when it is set -- whereas load-file-name and the car don't, but otherwise they are the same. Anyone know or care to comment?

Here is the test I tried. I put this in a file /tmp/foo.el:

(message "++1 %s" #$)
(message "++2 %s" (car current-load-list))

When I eval-buffer I get:

++1 nil
++2 /tmp/foo.el

Of course if I load-file it, they both come out with the same file names.

Thanks for the idea and info!

--- grischka

reply via email to

[Prev in Thread] Current Thread [Next in Thread]