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.

  1. features → is a global variable that represent available features. Its value is a list of elisp symbols. [see Elisp: Lisp Symbol]
  2. 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.
  3. 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 Enter features Enter. You'll see something like this:

ibuffer etags ring cc-mode cc-fonts cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs xlsl-mode encoded-kb speck sgml-mode dired info newcomment desktop recentf tree-widget wid-edit advice help-fns …

Elisp, Writing Major Mode

  1. Syntax Coloring
  2. Font Lock Mode
  3. Define Face
  4. Color Comment
  5. Comment Command
  6. Your Own Comment Command
  7. Keyword Completion Command
  8. Create Keymap
  9. Abbrev/Template
  10. Text Properties
  11. Overlay Highlighting
  12. Lookup Doc
  13. Syntax Table

  1. How to Name Your Major Mode
  2. provide, require, features
  3. load, load-file, autoload

Elisp Syntax Table

  1. Character Type
  2. Syntax Table Tutorial
  3. Find Syntax of a Character
  4. Modify Syntax Table Temporarily
  5. is Cursor Inside String/Comment
  6. Regex Patterns and Syntax Table
  7. Find Matching Bracket Char

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc