Elisp: provide, require, features
The purpose of emacs “features” is for emacs to know if a package is already loaded.
- features
-
A global variable. Its value is a list of Symbols, each symbol represent a emacs “feature” that's been loaded.
provide
-
(provide symbol)
Add symbol to the features list. require
-
(require symbol &optional FILENAME NOERROR)
- Checks if symbol is in variable features.
- If not, call
load
to load it. - File name is guessed from symbol, or specified in the optional argument.
This function are used in elisp libraries or scripts, similar to other language's “import”.
featurep
-
(featurep FEATURE &optional SUBFEATURE)
Return t if FEATURE is loaded.
;; check if a feature has been loaded (featurep 'dired)
here's sample value of features:
Emacs Lisp, Package System
Emacs Lisp, writing a major mode. Essentials
- Elisp: Write a Major Mode for Syntax Coloring
- Elisp: Font Lock Mode
- Elisp: Syntax Color Comments
- Elisp: Write Comment/Uncomment Command
- Elisp: Keyword Completion
- Elisp: Create Keymap (keybinding)
- Elisp: Create Function Templates
- Emacs: Command to Search Web 🚀
- Elisp: Create a Hook
- Elisp: Major Mode Names
- Elisp: provide, require, features
- Elisp: load, load-file, autoload
- Elisp: Syntax Table