barankin
barankin

Reputation: 1943

Why no error about undefined variable is raised in LISP while setq()?

In my Emacs config I have such a string:

(setq ibuffer-saved-filter-groups
  (quote (("default"
           ("dired"
            (mode . dired-mode))
           ("System"
            (or (name . "\*scratch\*")
                (name . "\*Messages\*")))
           ("SVN"
            (name . "^\\*vc-.*\\*$"))))))

The variables name and mode are undefined but the code is evaluated correctly. When I try to make a such on my own:

(some-var . "some-value")

I receive an error about the undefined variable some-var.

Upvotes: 2

Views: 294

Answers (3)

aartist
aartist

Reputation: 3236

Look at C-h v ibuffer-saved-filter-groups. It explains about this variables further. It is an alist variable. According to documents, it should look like (("STRING" QUALIFIERS) ("STRING" QUALIFIERS) ...) Now QUALIFIERS is a LIST of the same form as `ibuffer-filtering-qualifiers'. It is a LIST like (SYMBOL . QUALIFIER).

Upvotes: 0

C. K. Young
C. K. Young

Reputation: 223023

When a datum is quoted, nothing within is evaluated. For example:

foo

evaluates to the value bound to the identifier foo, whereas

'foo

or

(quote foo)

evaluates to the symbol foo.

Likewise,

(+ 1 2 3)

evaluates to 6, whereas

'(+ 1 2 3)

or

(quote (+ 1 2 3))

evaluate to a list with four elements: the symbol +, and the numbers 1, 2, and 3. In particular, the + is not evaluated.

Similarly, your name and mode, both being within the quoted datum, are not treated as identifiers, but as symbols. They are not evaluated.

Upvotes: 7

zeitue
zeitue

Reputation: 1683

Looks to me like it's because name and mode are in (quote )

Upvotes: 1

Related Questions