aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen2011-07-11 15:33:05 +0200
committerLars Magne Ingebrigtsen2011-07-11 15:33:05 +0200
commitdcc88d8a924038fde2d6e883e5777cf57ee2f0c5 (patch)
treed51c644870b18f48714abb387a78957281d9889e
parent4d45a8b7a237e1d33d0ae71d95a0ed7165ea6cda (diff)
downloademacs-dcc88d8a924038fde2d6e883e5777cf57ee2f0c5.tar.gz
emacs-dcc88d8a924038fde2d6e883e5777cf57ee2f0c5.zip
Add a new, simple definition of `remove-duplicates'
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/subr.el11
2 files changed, 14 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a3faab15c35..fb2f1a7a6e9 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12011-07-11 Lars Magne Ingebrigtsen <larsi@gnus.org>
2
3 * subr.el (remove-duplicates): New conveniency function.
4
12011-07-10 Lars Magne Ingebrigtsen <larsi@gnus.org> 52011-07-10 Lars Magne Ingebrigtsen <larsi@gnus.org>
2 6
3 * tool-bar.el (tool-bar-mode): Clarify positive/negative arguments 7 * tool-bar.el (tool-bar-mode): Clarify positive/negative arguments
diff --git a/lisp/subr.el b/lisp/subr.el
index 5c9d6c8d724..2b7ba17e10c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -173,7 +173,7 @@ value of last one, or nil if there are none.
173 (progn 173 (progn
174 ;; If we reload subr.el after having loaded CL, be careful not to 174 ;; If we reload subr.el after having loaded CL, be careful not to
175 ;; overwrite CL's extended definition of `dolist', `dotimes', 175 ;; overwrite CL's extended definition of `dolist', `dotimes',
176 ;; `declare', `push' and `pop'. 176 ;; `declare', `push', `pop' and `remove-duplicates'.
177 177
178(defmacro dolist (spec &rest body) 178(defmacro dolist (spec &rest body)
179 "Loop over a list. 179 "Loop over a list.
@@ -250,6 +250,15 @@ the return value (nil if RESULT is omitted).
250Treated as a declaration when used at the right place in a 250Treated as a declaration when used at the right place in a
251`defmacro' form. \(See Info anchor `(elisp)Definition of declare'.)" 251`defmacro' form. \(See Info anchor `(elisp)Definition of declare'.)"
252 nil) 252 nil)
253
254(defun remove-duplicates (list)
255 "Return a copy of LIST with all duplicate elements removed."
256 (let ((result nil))
257 (while list
258 (unless (member (car list) result)
259 (push (car list) result))
260 (pop list))
261 (nreverse result)))
253)) 262))
254 263
255(defmacro ignore-errors (&rest body) 264(defmacro ignore-errors (&rest body)