use-package is a declarative way to load packages in your init.el.
use-package aims to decrease Emacs startup time by loading packages on use rather than on startup
use-package is included as of Emacs 29.1
M-x define-function use-package
.A simple use-package
declaration may look like:
(use-package dired-x) (use-package dired :bind (("C-c d" . dired-jump) :map dired-mode-map ("/" . dired-omit-mode) ("h" . dired-hide-details-mode) ("-" . dired-up-directory)) :hook '((dired-hide-details-mode) (dired-omit-mode)) :config (setq dired-x-hands-off-my-keys nil ls-lisp-dirs-first t ls-lisp-use-insert-directory-program nil))
It customizes Dired. With this configuration, dired
and its configuration are not loaded until dired
is called.
The syntax used in this example is explained below:
(use-package package-name :bind -- A list of global keybindings :map -- A list of local keybindings :hook -- A list of hooks :config -- Variables to set after the package is loaded