summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2006-09-10 17:47:39 +0000
committerRichard M. Stallman <rms@gnu.org>2006-09-10 17:47:39 +0000
commit6b34950fadc011554873fb9f2f421b261235916f (patch)
treedd6bb94beebc6346f65f887abccd73612c31df18 /lisp/emacs-lisp
parent62e197b19443de3cf3c7eb4c150dc343d6175d2f (diff)
downloademacs-6b34950fadc011554873fb9f2f421b261235916f.tar.gz
emacs-6b34950fadc011554873fb9f2f421b261235916f.tar.bz2
emacs-6b34950fadc011554873fb9f2f421b261235916f.zip
(pushnew): Use add-to-list when convenient.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl.el9
1 files changed, 8 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el
index 222407f86f2..9db3fc027d6 100644
--- a/lisp/emacs-lisp/cl.el
+++ b/lisp/emacs-lisp/cl.el
@@ -149,13 +149,20 @@ be a symbol, or any generalized variable allowed by `setf'."
(if (symbolp place) (list 'setq place (list 'cons x place))
(list 'callf2 'cons x place)))
+(defvar pushnew-internal)
+
(defmacro pushnew (x place &rest keys)
"(pushnew X PLACE): insert X at the head of the list if not already there.
Like (push X PLACE), except that the list is unmodified if X is `eql' to
an element already on the list.
\nKeywords supported: :test :test-not :key
\n(fn X PLACE [KEYWORD VALUE]...)"
- (if (symbolp place) (list 'setq place (list* 'adjoin x place keys))
+ (if (symbolp place)
+ (if (null keys)
+ `(let ((pushnew-internal ,place))
+ (add-to-list 'pushnew-internal x nil 'eql)
+ (setq ,place pushnew-internal))
+ (list 'setq place (list* 'adjoin x place keys)))
(list* 'callf2 'adjoin x place keys)))
(defun cl-set-elt (seq n val)