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: Drew Adams
Subject: RE: Add-to-list or setq append...
Date: Tue, 3 Aug 2010 17:35:41 -0700

> (setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) auto-mode-alist))
> is equivalent to
> (add-to-list 'auto-mode-alist '("\\.ml\\w?" . tuareg-mode))

No, it is not.  The former unconditionally adds the entry at the beginning of
the alist.  The latter adds the entry to the alist only if an `equal' entry is
not already present. 

The former ensures that the entry is at the start of the list.  The latter does
not.  

In the former case the alist can end up with multiple entries with the given
key, the first such entry shadowing all others with the same key.  If you then
pop off that first entry, the previously first of all entries with that key is
still present and now becomes the one that matters (shadows any others with that
key).




reply via email to

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