简体   繁体   中英

How does the emacs load the package?

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?

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 + ...".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM