[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Concat var names ?
From: |
Philippe M . Coatmeur |
Subject: |
Re: Concat var names ? |
Date: |
Mon, 28 May 2012 07:39:14 +0000 |
User-agent: |
Wanderlust/2.15.9 (Almost Unreal) Emacs/24.1 Mule/6.0 (HANACHIRUSATO) |
At Mon, 28 May 2012 00:26:37 -0400,
Barry Margolin wrote:
>
> 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 :
(...)
> > >
> > > 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"))))
Guys, thank you very much, it works like a charm, and with
"symbol-value" I can do pretty much whatever I want with the object
returned.
Phil
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***