1

My .emacs file includes a line I presumably added ages ago

(require 'some-random-package)

I haven't actually been able to learn anything about the package.

My load-path is quite complicated (it takes up about a screenful) so a manual solution digging through the load path isn't ideal.

I'm aware emacs' rules for loading a package are to look through the directories in the load path for foo.elc and foo. How can I find where the package came from?

3

There are two built-in interactive functions to help a user track down a library that is within the load-path -- i.e., locate-library [to see the path] and find-library [to open the library in a buffer].


M-x locate-library

locate-library is an interactive compiled Lisp function in 'subr.el'.

(locate-library LIBRARY &optional NOSUFFIX PATH INTERACTIVE-CALL)

Show the precise file name of Emacs library LIBRARY.
LIBRARY should be a relative file name of the library, a string.
It can omit the suffix (a.k.a. file-name extension) if NOSUFFIX is
nil (which is the default, see below).
This command searches the directories in 'load-path' like 'M-x load-library'
to find the file that 'M-x load-library RET LIBRARY RET' would load.
Optional second arg NOSUFFIX non-nil means don't add suffixes 'load-suffixes'
to the specified name LIBRARY.

If the optional third arg PATH is specified, that list of directories
is used instead of 'load-path'.

When called from a program, the file name is normally returned as a
string.  When run interactively, the argument INTERACTIVE-CALL is t,
and the file name is displayed in the echo area.

M-x find-library

find-library is an interactive autoloaded compiled Lisp function in
'find-func.el'.

(find-library LIBRARY)

Find the Emacs Lisp source of LIBRARY.
LIBRARY should be a string (the name of the library).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.