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

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

Re: Concat var names ?


From: Barry Margolin
Subject: Re: Concat var names ?
Date: Mon, 28 May 2012 00:26:37 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.1785.1338177648.855.help-gnu-emacs@gnu.org>,
 XeCycle <XeCycle@Gmail.com> wrote:

> Philippe M. Coatmeur <philippe.coatmeur@gmail.com> writes:
> 
> > Hi ; I have those two functions and I want to make them one :
> >
> > (defun mail-bug-desktop-notify-one ()
> >   (mapcar
> >    (lambda (x)
> >      (if (not (member x mail-bug-advertised-mails-one))
> >      (progn
> >        (mail-bug-desktop-notification
> >         (format "%s" (first x))
> >         (format "%s \n%s" (second x)
> >                 (third x))
> >         "5000" mail-bug-new-mail-icon-one)
> >        (add-to-list 'mail-bug-advertised-mails-one x))))
> >    mail-bug-unseen-mails-one))
> >
> > But I have to create distinct lists, so I'd really like to be able to
> > say
> >
> > (setq suffix "plop")
> > (setq myvar-plop "value")
> > (message "%s" (concat "myvar-" suffix))
> >
> > And get "myvar-value" instead of myvar-plop... 
> 
> Check what `intern' does.

You also need to use symbol-value to get the value of the variable 
instead of just its name:

(message "%s" (symbol-value (intern (concat "myvar-" suffix"))))

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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