help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: What is the :eval form ?


From: Drew Adams
Subject: RE: What is the :eval form ?
Date: Fri, 8 Jun 2012 11:10:03 -0700

> what I'm trying to do is to use a variable to pass the 
> ("2" in the example) argument to the function, to use
> it in a loop, like this :
> 
>   (loop for i from 1 to 3 do
>       (add-to-list 'global-mode-string
>                    '(:eval (mail-bug-mode-line-all
>                          (format "%s" i)))))
> 
> but i's value is always stuck at 1 :(

That's because you want to evaluate (format "%s" i) when the `loop' is executed,
but you have put it inside '(...).  So your iterator puts this into
`global-mode-string' at each iteration:

(:eval (mail-bug-mode-line-all (format "%s" i)))

What you really want is this (or equivalent):

(loop for i from 1 to 3 do
  (add-to-list
    'global-mode-string
    `(:eval (mail-bug-mode-line-all ,(format "%s" i)))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]