changeset: 4487:42fad34efb3f4dcf7cc389b6dffcba286f67503d
user: Aidan Kehoe <kehoea(a)parhasard.net>
date: Wed May 14 23:47:58 2008 +0200
files: lisp/ChangeLog lisp/subr.el
description:
Support COMPARE-FN in add-to-list; thank you Brian Palmer.
2008-02-25 bpalmer <bpalmer(a)gmail.com>
* subr.el(add-to-list): add support for `compare-fn' to sync with
emacs.
diff -r 04ec3340612e4e1b351e381fdfd75d0813fb1dec -r
42fad34efb3f4dcf7cc389b6dffcba286f67503d lisp/ChangeLog
--- a/lisp/ChangeLog Wed May 14 23:43:12 2008 +0200
+++ b/lisp/ChangeLog Wed May 14 23:47:58 2008 +0200
@@ -1,3 +1,8 @@ 2008-05-14 Aidan Kehoe <kehoea@parhasa
+2008-02-25 bpalmer <bpalmer(a)gmail.com>
+
+ * subr.el(add-to-list): add support for `compare-fn' to sync with
+ emacs.
+
2008-05-14 Aidan Kehoe <kehoea(a)parhasard.net>
* mule/mule-coding.el (make-8-bit-choose-category):=20
diff -r 04ec3340612e4e1b351e381fdfd75d0813fb1dec -r
42fad34efb3f4dcf7cc389b6dffcba286f67503d lisp/subr.el
--- a/lisp/subr.el Wed May 14 23:43:12 2008 +0200
+++ b/lisp/subr.el Wed May 14 23:47:58 2008 +0200
@@ -390,19 +390,21 @@ argument to `add-one-shot-hook'."
argument to `add-one-shot-hook'."
(add-one-shot-hook hook function append t))
-(defun add-to-list (list-var element &optional append)
+(defun add-to-list (list-var element &optional append compare-fn)
"Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
-The test for presence of ELEMENT is done with `equal'.
-If ELEMENT is added, it is added at the beginning of the list,
-unless the optional argument APPEND is non-nil, in which case
-ELEMENT is added at the end.
+The test for presence of ELEMENT is done with COMPARE-FN; if
+COMPARE-FN is nil, then it defaults to `equal'. If ELEMENT is added,
+it is added at the beginning of the list, unless the optional argument
+APPEND is non-nil, in which case ELEMENT is added at the end.
If you want to use `add-to-list' on a variable that is not defined
until a certain package is loaded, you should put the call to `add-to-list'
into a hook function that will be run only after loading the package.
`eval-after-load' provides one way to do this. In some cases
other hooks, such as major mode hooks, can do the job."
- (if (member element (symbol-value list-var))
+ (if (if (not compare-fn)
+ (member element (symbol-value list-var))
+ (member* element (symbol-value list-var) :test compare-fn))
(symbol-value list-var)
(set list-var
(if append
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches