Elisp: Check If a {function, variable, feature} is Defined/Loaded
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: load, load-file, autoload]
See also: Elisp: Find/Determine OS and Emacs Version.
If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial