* two ways of adding a path to the list variable load-path. equivalent?
@ 2009-05-19 17:33 Nobuko Three
2009-05-19 18:17 ` Peter Dyballa
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nobuko Three @ 2009-05-19 17:33 UTC (permalink / raw)
To: Help-gnu-emacs
1.
(setq load-path (cons "~/elisp/" load-path))
2.
(add-to-list 'load-path "~/elisp/")
Are there any situation where one would prefer one over another?
--
View this message in context: http://www.nabble.com/two-ways-of-adding-a-path-to-the-list-variable-load-path.-equivalent--tp23620963p23620963.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: two ways of adding a path to the list variable load-path. equivalent?
2009-05-19 17:33 two ways of adding a path to the list variable load-path. equivalent? Nobuko Three
@ 2009-05-19 18:17 ` Peter Dyballa
2009-05-22 3:45 ` Kevin Rodgers
2009-05-20 8:48 ` Ralf Mattes
2009-05-20 12:50 ` Nikolaj Schumacher
2 siblings, 1 reply; 5+ messages in thread
From: Peter Dyballa @ 2009-05-19 18:17 UTC (permalink / raw)
To: Nobuko Three; +Cc: Help-gnu-emacs
Am 19.05.2009 um 19:33 schrieb Nobuko Three:
> (setq load-path (cons "~/elisp/" load-path))
>
> 2.
> (add-to-list 'load-path "~/elisp/")
The latter does *not* add the new element on top when this element
already exists somewhere in the list. So the latter form is preferable.
--
Greetings
Pete
Hard Disk, n.:
A device that allows users to delete vast quantities
of data with simple mnemonic commands.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: two ways of adding a path to the list variable load-path. equivalent?
2009-05-19 18:17 ` Peter Dyballa
@ 2009-05-22 3:45 ` Kevin Rodgers
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2009-05-22 3:45 UTC (permalink / raw)
To: help-gnu-emacs
Peter Dyballa wrote:
>
> Am 19.05.2009 um 19:33 schrieb Nobuko Three:
>
>> (setq load-path (cons "~/elisp/" load-path))
>>
>> 2.
>> (add-to-list 'load-path "~/elisp/")
>
>
> The latter does *not* add the new element on top when this element
> already exists somewhere in the list. So the latter form is preferable.
Unless the intent is to make sure the element is first in the list.
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: two ways of adding a path to the list variable load-path. equivalent?
2009-05-19 17:33 two ways of adding a path to the list variable load-path. equivalent? Nobuko Three
2009-05-19 18:17 ` Peter Dyballa
@ 2009-05-20 8:48 ` Ralf Mattes
2009-05-20 12:50 ` Nikolaj Schumacher
2 siblings, 0 replies; 5+ messages in thread
From: Ralf Mattes @ 2009-05-20 8:48 UTC (permalink / raw)
To: help-gnu-emacs
On Tue, 19 May 2009 10:33:09 -0700, Nobuko Three wrote:
> 1.
> (setq load-path (cons "~/elisp/" load-path))
>
> 2.
> (add-to-list 'load-path "~/elisp/")
>
> Are there any situation where one would prefer one over another?
The setq way will always add a new value to the list while add-to-list
will only add a value iff it's not already present in the list.
Usually one wants to have have a path only once in the load-path.
HTH Ralf Mattes
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: two ways of adding a path to the list variable load-path. equivalent?
2009-05-19 17:33 two ways of adding a path to the list variable load-path. equivalent? Nobuko Three
2009-05-19 18:17 ` Peter Dyballa
2009-05-20 8:48 ` Ralf Mattes
@ 2009-05-20 12:50 ` Nikolaj Schumacher
2 siblings, 0 replies; 5+ messages in thread
From: Nikolaj Schumacher @ 2009-05-20 12:50 UTC (permalink / raw)
To: Nobuko Three; +Cc: Help-gnu-emacs
Nobuko Three <nbko3@yahoo.com> wrote:
> 1.
> (setq load-path (cons "~/elisp/" load-path))
>
> 2.
> (add-to-list 'load-path "~/elisp/")
>
> Are there any situation where one would prefer one over another?
As you probably know from the documentation of add-to-list, it will test
whether the directory is already included before adding it another time.
The downside of add-to-list is, adding the path will be slightly slower (and
increasingly slower with the size of the list). The downside of consing
is that duplicates might slow down loading a bit.
I'd suggest add-to-list, but the difference is negligible.
regards,
Nikolaj Schumacher
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-05-22 3:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-19 17:33 two ways of adding a path to the list variable load-path. equivalent? Nobuko Three
2009-05-19 18:17 ` Peter Dyballa
2009-05-22 3:45 ` Kevin Rodgers
2009-05-20 8:48 ` Ralf Mattes
2009-05-20 12:50 ` Nikolaj Schumacher
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.