* Re: Concat var names ?
2012-05-28 4:37 Concat var names ? Philippe M. Coatmeur
@ 2012-05-28 3:59 ` XeCycle
[not found] ` <mailman.1785.1338177648.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 4+ messages in thread
From: XeCycle @ 2012-05-28 3:59 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]
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.
> Or even better, to use the same mechanism, a mapcar, but what about
> the creation of mail-bug-advertised-mails-SUFFIX ? How do I instruct
> my function to tell one list from the other ?
>
> Phil
>
--
Carl Lei (XeCycle)
Department of Physics, Shanghai Jiao Tong University
OpenPGP public key: 7795E591
Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591
[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Concat var names ?
[not found] ` <mailman.1785.1338177648.855.help-gnu-emacs@gnu.org>
@ 2012-05-28 4:26 ` Barry Margolin
2012-05-28 7:39 ` Philippe M. Coatmeur
0 siblings, 1 reply; 4+ messages in thread
From: Barry Margolin @ 2012-05-28 4:26 UTC (permalink / raw)
To: help-gnu-emacs
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 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* Concat var names ?
@ 2012-05-28 4:37 Philippe M. Coatmeur
2012-05-28 3:59 ` XeCycle
[not found] ` <mailman.1785.1338177648.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 4+ messages in thread
From: Philippe M. Coatmeur @ 2012-05-28 4:37 UTC (permalink / raw)
To: help-gnu-emacs
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...
Or even better, to use the same mechanism, a mapcar, but what about
the creation of mail-bug-advertised-mails-SUFFIX ? How do I instruct
my function to tell one list from the other ?
Phil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Concat var names ?
2012-05-28 4:26 ` Barry Margolin
@ 2012-05-28 7:39 ` Philippe M. Coatmeur
0 siblings, 0 replies; 4+ messages in thread
From: Philippe M. Coatmeur @ 2012-05-28 7:39 UTC (permalink / raw)
To: help-gnu-emacs
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 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-05-28 7:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-28 4:37 Concat var names ? Philippe M. Coatmeur
2012-05-28 3:59 ` XeCycle
[not found] ` <mailman.1785.1338177648.855.help-gnu-emacs@gnu.org>
2012-05-28 4:26 ` Barry Margolin
2012-05-28 7:39 ` Philippe M. Coatmeur
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.