What is the difference between
defvar in Emacs lisp?
I see common lisp version of the same question at https://stackoverflow.com/questions/3855862. Are they same in Elisp?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
You should ask Emacs this question:
C-h i, choose the Elisp manual (
m Elisp), and search the index for "defvar" (
i defvar). That takes you to node Defining Variables.
Emacs tells you that
defvar allows attaching a doc string, and that if the variable already has a value then it does nothing.
It also tells you about the use of
defvar with no value to be assigned:
(defvar foo). It tells you that that declares the variable to be dynamically scoped.
setq has none of those properties.
setq are similar, but not quite the same, in Emacs Lisp and Common Lisp.