Elisp: provide, require, features

By Xah Lee. Date: . Last updated: .

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 elisp symbols, each symbol represent a emacs “feature” that's been loaded. [see Elisp: Lisp Symbol]
provide
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.
require
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 require function may specify a file name in the 2nd argument.)

For example, Alt+x describe-variable, then type features. You'll see something like this:

emacs features 2020-12-07 gXj4f
emacs features 2020-12-07

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

Emacs Tutorial

Emacs Init

Emacs Keys

ELisp

ELisp Examples

ELisp Write Major Mode


ELisp Write Major Mode

Basics

Package Name/Load

Syntax Table