* Checking whether a list contains a particular element
@ 2006-07-16 18:53 Peter Dyballa
0 siblings, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2006-07-16 18:53 UTC (permalink / raw)
Hello!
How can I check whether load-path contains a particular path (so that
I could add it if necessary)?
--
Greetings
Pete
Real Time, adj.:
Here and now, as opposed to fake time, which only occurs there and then.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Checking whether a list contains a particular element
[not found] <mailman.4145.1153076026.9609.help-gnu-emacs@gnu.org>
@ 2006-07-16 19:22 ` Barry Margolin
2006-07-17 9:17 ` Peter Dyballa
[not found] ` <mailman.4170.1153127856.9609.help-gnu-emacs@gnu.org>
2006-07-16 20:19 ` B. T. Raven
2006-07-17 7:57 ` Tim X
2 siblings, 2 replies; 6+ messages in thread
From: Barry Margolin @ 2006-07-16 19:22 UTC (permalink / raw)
In article <mailman.4145.1153076026.9609.help-gnu-emacs@gnu.org>,
Peter Dyballa <Peter_Dyballa@Web.DE> wrote:
> Hello!
>
> How can I check whether load-path contains a particular path (so that
> I could add it if necessary)?
The built-in 'add-to-list' function already performs this check, so you
shouldn't need to do it yourself. But if you do, you can use the
function 'member'.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Checking whether a list contains a particular element
[not found] <mailman.4145.1153076026.9609.help-gnu-emacs@gnu.org>
2006-07-16 19:22 ` Barry Margolin
@ 2006-07-16 20:19 ` B. T. Raven
2006-07-17 7:57 ` Tim X
2 siblings, 0 replies; 6+ messages in thread
From: B. T. Raven @ 2006-07-16 20:19 UTC (permalink / raw)
"Peter Dyballa" <Peter_Dyballa@Web.DE> wrote in message
news:mailman.4145.1153076026.9609.help-gnu-emacs@gnu.org...
> Hello!
>
> How can I check whether load-path contains a particular path (so that
> I could add it if necessary)?
>
> --
> Greetings
>
> Pete
Since load-path variable is a list of strings, you could try:
(setq my-path "x:/my/subdir")
(setq found (car (member-ignore-case my-path load-path))
(if (not found) ;; do whatever )
Ed.
>
> Real Time, adj.:
> Here and now, as opposed to fake time, which only occurs there and then.
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Checking whether a list contains a particular element
[not found] <mailman.4145.1153076026.9609.help-gnu-emacs@gnu.org>
2006-07-16 19:22 ` Barry Margolin
2006-07-16 20:19 ` B. T. Raven
@ 2006-07-17 7:57 ` Tim X
2 siblings, 0 replies; 6+ messages in thread
From: Tim X @ 2006-07-17 7:57 UTC (permalink / raw)
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Hello!
>
> How can I check whether load-path contains a particular path (so that
> I could add it if necessary)?
>
> --
> Greetings
>
there is already a function to achieve what you want
,----[ C-h f add-to-list RET ]
| add-to-list is a compiled Lisp function in `subr.el'.
| (add-to-list LIST-VAR ELEMENT &optional APPEND)
|
| Add ELEMENT to the value of LIST-VAR if it isn't there yet.
| The test for presence of ELEMENT is done with `equal'.
| If ELEMENT is added, it is added at the beginning of the list,
| unless the optional argument APPEND is non-nil, in which case
| ELEMENT is added at the end.
|
| The return value is the new value of LIST-VAR.
|
| If you want to use `add-to-list' on a variable that is not defined
| until a certain package is loaded, you should put the call to `add-to-list'
| into a hook function that will be run only after loading the package.
| `eval-after-load' provides one way to do this. In some cases
| other hooks, such as major mode hooks, can do the job.
`----
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Checking whether a list contains a particular element
2006-07-16 19:22 ` Barry Margolin
@ 2006-07-17 9:17 ` Peter Dyballa
[not found] ` <mailman.4170.1153127856.9609.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2006-07-17 9:17 UTC (permalink / raw)
Am 16.07.2006 um 21:22 schrieb Barry Margolin:
> The built-in 'add-to-list' function already performs this check
Ahh! From reading the function's name it's hard to guess that it does
such a good work. And since the name is so clear I never would have
checked the description ...
Thank you all for the answers! It's now just a waste of time if I add
what's already there.
--
Greetings
~ O
Pete ~~_\\_/%
~ O o
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Checking whether a list contains a particular element
[not found] ` <mailman.4170.1153127856.9609.help-gnu-emacs@gnu.org>
@ 2006-07-17 9:22 ` David Kastrup
0 siblings, 0 replies; 6+ messages in thread
From: David Kastrup @ 2006-07-17 9:22 UTC (permalink / raw)
Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> Am 16.07.2006 um 21:22 schrieb Barry Margolin:
>
>> The built-in 'add-to-list' function already performs this check
>
> Ahh! From reading the function's name it's hard to guess that it does
> such a good work. And since the name is so clear I never would have
> checked the description ...
But it would be pointless if it did the same thing as `push'.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-07-17 9:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-16 18:53 Checking whether a list contains a particular element Peter Dyballa
[not found] <mailman.4145.1153076026.9609.help-gnu-emacs@gnu.org>
2006-07-16 19:22 ` Barry Margolin
2006-07-17 9:17 ` Peter Dyballa
[not found] ` <mailman.4170.1153127856.9609.help-gnu-emacs@gnu.org>
2006-07-17 9:22 ` David Kastrup
2006-07-16 20:19 ` B. T. Raven
2006-07-17 7:57 ` Tim X
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).