Elisp: provide, require, features
The purpose of emacs “features” is for emacs to know if a package is already loaded.
- A global variable. Its value is a list of elisp symbols, each symbol represent a emacs “feature” that's been loaded. [see Elisp: Lisp Symbol]
- A elisp package usually has
(provide 'symbol_name)at the end. When this code is evaluated, emacs will add the symbol name to the features list.
- When the code
(require 'symbol_name)is called, emacs checks if that symbol name is already in the features list. If not, load it. (emacs will guess a file name based on the symbol name. Or, the
requirefunction may specify a file name in the 2nd argument.)
For example, Alt+x
describe-variable, then type features. You'll see something like this:
Put $5 at https://www.patreon.com/xahlee , or goto paypal.com and pay to Xah@XahLee.org . Message me on XahLee discord, say so, ask me questions.
Or Buy Xah Emacs Tutorial