2
votes

I'm always curious about the loading process of the package in Emacs. You know, Some packages are builtin packages, and some are third-party packages.
For example, you can install the "auto-complete" package from MELPA or MELPA-STABLE, or you can get the source from github.
If you install the package from MELPA, you will find the package files in "~/.emacs.d/elpa/auto-complete***".

auto-complete-autoloads.el  
auto-complete-config.el  
auto-complete-config.elc  
auto-complete.el  
auto-complete.elc  
auto-complete-pkg.el  
dict;;it's a directory

What does the emacs do for us to install the package? It just downloads all the files from MELPA and puts them in "~/.emacs.d/elpa/auto-complete***"? How does the emacs know the existense of the auto-complete-package and load them when you start emacs next time?
I know I should add something to "~/.emacs.d/init.el" if get the source from github. Maybe like this

(add-to-list 'load-path "path-to-download-folder/auto-complete")
(require 'auto-complete-config)
(ac-config-default)

But I can't see any changes in "init.el" if I install the package from MELPA. Maybe the emacs assign the path of the auto-complete to the variable load-path. But then?
How does the emacs load the package? How does it know my "ALT-x + command"?
And I really don't know the relationship of these files the emacs downloaded from MELPA and their function. Could anyone tell me the whole loading process of a package? What does the emacs do behind us to install the package from MELPA/MELPA-STABLE?

1
While some Emacs questions are a good fit for Stack Overflow, I don't think this one is. It's not a specific programming question, but rather a question about how Emacs works internally, specifically how package.el works. Try submitting it on emacs.stackexchange.com instead.Chris
What @Chris said. And start by consulting the Emacs manual about this (C-h r). If you don't find sufficient information there about it then consider filing a doc bug: M-x report-emacs-bug.Drew
And the title of your question should apparently be "How does package.el affect package loading" since that is what you are really asking about.tripleee

1 Answers

0
votes

Emacs (by default) automatically loads (almost) all the files of the form ~/.emacs.d/elpa/*/*-autoloads.el. The package's <pkg>-autoloads.el will contain more or less the equivalent of your "add-to-list + require + ...".