Skip to content

Dev notes on package install and initialization procedures

Noam Postavsky edited this page Jul 9, 2015 · 2 revisions

Installing a package

el-get calls el-get-init-and-install which calls el-get-do-install on non-installed package and then el-get-do-init on installed ones.

el-get-do-install calls the :install method for a package like this: (funcall install package url 'el-get-post-install). Taking :git as an example, el-get-git-pull then runs git clone asynchronously using el-get-start-process-list and el-get-post-install becomes the sentinel function, so it gets called after the installation really finishes.

At this point the package has been downloaded and unpacked in ~/.emacs.d/el-get/<package>.

el-get-post-install runs any method specific :install-hooks, and then calls (el-get-build package commands nil sync 'el-get-post-install-build) (except for :type builtin, which calls el-get-post-install-build directly).

el-get-build passes the build commands to el-get-start-process, with a complicated lambda expression as the final-func. So in all, at this stage we build (according to el-get-build-commands), do byte-compilation, optionally do info installation (via el-get-install-or-init-info which calls el-get-build again, recursively). And finally we should end up at el-get-post-install-build.

(defun el-get-post-install-build (package)
  "Function to call after building the package while installing it."
  (el-get-save-package-status package "installed")
  (el-get-invalidate-autoloads package) ; that will also update them
  (el-get-do-init package)
  (run-hook-with-args 'el-get-post-install-hooks package))

el-get-post-install-hooks is only (el-get-post-install-notification) (unless the user has added more hooks).

Initializing a package

el-get -> el-get-init-and-install -> el-get-do-init is the main starting point (we can also get there via el-get-reload -> el-get-init -> el-get-do-init.

el-get-do-init first adds the package directory to load-path, then loads :autoloads listed files, if any (NOTE: it's not the extracted ;;;###autoload cookies; this is more like pre-load than auto-load, though it's intended to be used with package supplied autoload files).

Then run the :prepare and :before blocks.

  • For lazy packages, eval-after-load the :post-init and :after blocks.
  • For non-lazy packages, load any files listed in :load, require any features listed in :features (NOTE: :features skipped for :type elpa, maybe wrongly, see #969), and then run the :post-init and :after blocks.

Finally, run el-get-post-init-hooks, which will usually be just el-get-post-init-message, except for when this hook is used to daisy chain asynchronous installs and updates.

Dependencies

Calculated by el-get-dependencies.

Use by:

  • el-get-init: init all dependencies before the package itself.
  • el-get-install: install dependencies before the package itself.
  • el-get-update: installs any new dependencie before updating.
  • el-get-cleanup: decide what to keep.
  • el-get-init-and-install: like el-get-init and el-get-install.