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

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

Re: Checking whether a list contains a particular element


From: Tim X
Subject: Re: Checking whether a list contains a particular element
Date: Mon, 17 Jul 2006 17:57:14 +1000
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

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


reply via email to

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