Emacs Lisp: Check If a function/variable is Defined

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.

Check If Function is Defined

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

(fboundp 'xyz)                          ; nil

Technically, fboundp check a Symbol's function cell.

Check If 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

Technically, boundp checks a Symbol's value cell.

Check Feature

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

[see Emacs Lisp: load, load-file, autoload, require]

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

Lisp Symbol

ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial

Lisp Basics

Basics

Lisp Data Structure

Function

Lisp Symbol

Lisp Misc

Working with Elisp