Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Relative loads for Emacs Lisp files. Adds functions __FILE__ and load-relative and require-relative.
Emacs Lisp Shell Ruby Makefile
tree: 7de0162234

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
AUTHORS
COPYING
ChangeLog
INSTALL
Makefile.am
NEWS
README
README.textile
autogen.sh
common.mk
configure.ac
elisp-comp
install-from-git.sh
load-relative.el
make-check-filter.rb

README.textile

Emacs relative-file load, require __FILE__ and a provide-me macro.

Here we add functions: load-relative, require-relative, require-relative-list, __FILE__, and macro provide-me.

The latest version is at http://github.com/rocky/emacs-load-relative/

__FILE__

__FILE__ returns the file name that that the calling program is running. If you are _eval_’ing a buffer then the file name of that buffer is used. The name was selected to be analogous to the name used in C, Perl, and Ruby.

load-relative

load-relative loads an Emacs Lisp file relative to another (presumably currently running) Emacs Lisp file. For example if you have files foo.el and bar.el in the same directory, then to load Emacs Lisp file bar.el from inside Emacs lisp file foo.el:

 (require 'load-relative)
 (load-relative "baz")

That load-relative line could above have also been written as:

 (load-relative "./baz")

or:

 (load-relative "baz.el")  # if you want to exclude any byte-compiled files

require-relative, require-relative-list

If instead of loading file baz, you want to require it:

 (require-relative "baz")

or

 (require-relative "./baz")

The above not only does a require on ’baz, but makes sure you get that from the same file as you would have if you had issued load_relative.

If you have a list of files you want to require, you can require them one shot using require-relative-list like this:

 (require-relative-list '("dbgr-init" "dbgr-fringe"))

provide-me

Finally, macro provide-me saves you the trouble of adding a symbol after provide, by using the file basename (without directory or file extension) as the name of the thing you want to provide. Using this forces the provide names to be the same as the filename, but I consider that a good thing.

Something went wrong with that request. Please try again.