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?

Madhavan
  • 1,957
  • 12
  • 28
  • 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 Mar 03 '15 at 11:40
  • @Dan - That looks like answer to me – Andrew Swann Mar 03 '15 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. – Kaushal Modi Mar 03 '15 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 Mar 03 '15 at 12:52
  • @AndrewSwann: have now posted a somewhat more detailed answer based on the comment. – Dan Mar 03 '15 at 13:33
  • @abo-abo Yes, that's correct. Thanks! – Kaushal Modi Mar 03 '15 at 13:40

1 Answers1

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.

Dan
  • 32,584
  • 6
  • 98
  • 168