6

What failed for me?

(add-to-list 'load-path "~/.emacs.d/others")

what worked for me?

(mapc 'load (file-expand-wildcards "~/.emacs.d/others/*.el"))

Functions defined in elisp files lying @~/.emacs.d/others were not loaded in the first case.

So, is it wrong to assume that adding folder paths to load-path will load the *.el files lying underneath?

6
  • 4
    Adding to the load path does not actually load any files. It only tells emacs where to look for files when you ask it to load them.
    – Dan
    Commented Mar 3, 2015 at 11:40
  • @Dan - That looks like answer to me Commented Mar 3, 2015 at 11:50
  • Using load is not a good approach. Better update the load-path as in the first snippet and then use require or autoload as necessary. Better yet check out the use-package package; it will help make loading the packages more efficient. Commented Mar 3, 2015 at 12:13
  • @kaushalmodi, use-package grants convenience while adding (small) overhead. I don't know if that can be classified as loading packages more efficiently.
    – abo-abo
    Commented Mar 3, 2015 at 12:52
  • @AndrewSwann: have now posted a somewhat more detailed answer based on the comment.
    – Dan
    Commented Mar 3, 2015 at 13:33

1 Answer 1

6

Adding to the load-path does not actually load any files. Instead, it only tells Emacs where to look for files when you ask it to load them. As the docstring indicates:

Documentation:

List of directories to search for files to load. Each element is a string (directory name) or nil (try default directory). Initialized based on EMACSLOADPATH environment variable, if any, otherwise to default specified by file epaths.h when Emacs was built.

As the other comments indicate, there are various ways to load elisp libraries and packages once they're on the load-path. You can, for example, use load, autoload, require, and use-package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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