+2011-07-11 Lars Magne Ingebrigtsen <larsi@gnus.org>
+
+ * subr.el (remove-duplicates): New conveniency function.
+
2011-07-10 Lars Magne Ingebrigtsen <larsi@gnus.org>
* tool-bar.el (tool-bar-mode): Clarify positive/negative arguments
(progn
;; If we reload subr.el after having loaded CL, be careful not to
;; overwrite CL's extended definition of `dolist', `dotimes',
- ;; `declare', `push' and `pop'.
+ ;; `declare', `push', `pop' and `remove-duplicates'.
(defmacro dolist (spec &rest body)
"Loop over a list.
Treated as a declaration when used at the right place in a
`defmacro' form. \(See Info anchor `(elisp)Definition of declare'.)"
nil)
+
+(defun remove-duplicates (list)
+ "Return a copy of LIST with all duplicate elements removed."
+ (let ((result nil))
+ (while list
+ (unless (member (car list) result)
+ (push (car list) result))
+ (pop list))
+ (nreverse result)))
))
(defmacro ignore-errors (&rest body)