Elisp: Check If a {function, variable, feature} is Defined/Loaded

By Xah Lee. Date: . Last updated: .

This page shows you how to check if a {function, variable} is defined, or if a “feature” is loaded, and find out what Operating System your emacs is running on.

Check Function

Check if a function is defined.

;; check if a function is defined
(fboundp 'info)                         ; t
(fboundp 'setq)                         ; t

(fboundp 'xyz)                          ; nil

Check Variable

Check if a variable is defined.

;; check if a variable is defined
(boundp 'auto-mode-alist)               ; t
(boundp 'default-input-method)          ; t
(boundp 'nil)                           ; t

(boundp 'xyz)                           ; nil

The fboundp actually check a symbol's function cell. Similarly, the boundp checks a symbol's value cell. [see Emacs Lisp Symbol]

Check Feature

Check if a “feature” is loaded.

;; check if a “feature” (package) has been loaded
(featurep 'ibuffer)

[see Elisp: require, load, load-file, autoload, feature]

See also: Elisp: Find/Determine OS and Emacs Version.

Emacs Customization

  1. Emacs init file
  2. Install Packages
  3. Install Package Manually
  4. Define Keys
  5. M-x customize
  6. What's Major Mode?
  7. What's Minor Mode?
  8. Set File to Open in a Major Mode
  9. Organize Init File
  10. Byte Compile Elisp
  11. What's Hook?
  12. Environment Variables in Emacs
  13. Set Default Window Size
  14. Font Setup
  15. Set Color Theme
  16. Turn Off Auto Backup; Set Backups into a Directory; How to Delete Backup Files
  17. Elisp: Determine OS, Emacs Version, Machine Host Name
  18. Elisp: Check If a {function, variable, feature} is Defined/Loaded
Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs

If you have a question, put $5 at patreon and message me.