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

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

Re: Add-to-list or setq append...


From: David Kastrup
Subject: Re: Add-to-list or setq append...
Date: Wed, 08 Dec 2010 15:22:59 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Richard Riley <rileyrg@gmail.com> writes:

> Andrea Crotti <andrea.crotti.0@gmail.com> writes:
>
>> Just a curiosity, I was wondering why in so many README and doc they
>> suggest to add elements to lists with something like:
>>
>>
>>
>> (setq list (append list element))
>>
>>
>>
>> instead of doing simply
>>
>>
>> (add-to-list list-va element)
>>
>>
>>
>> Is there any good reason or is just historical heritage?
>> I think add-to-list is even more smart adding only if not there already,
>> then what's the point in using that ugly form?
>
> With append you can append a list. e.g
>
> (setq load-path (append load-path '("/usr/local/emacs/site-lisp" 
> "/usr/share/emacs/site-lisp")))
>
> I don't know if add-to-list can do that?

It would have taken you less time to ask Emacs than it takes a hundred
readers to read your unnecessary message.

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 COMPARE-FN)

[...]

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.

[...]

-- 
David Kastrup


reply via email to

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