diff lisp/subr.el @ 72784:3f19250c6e68

(add-to-list): New argument COMPARE-FN.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Sep 2006 17:45:42 +0000
parents 0d8b226a4a76
children b70548506872
line wrap: on
line diff
--- a/lisp/subr.el	Sun Sep 10 16:26:31 2006 +0000
+++ b/lisp/subr.el	Sun Sep 10 17:45:42 2006 +0000
@@ -1085,9 +1085,10 @@
 	    (kill-local-variable hook)
 	  (set hook hook-value))))))
 
-(defun add-to-list (list-var element &optional append)
+(defun add-to-list (list-var element &optional append compare-fn)
   "Add ELEMENT to the value of LIST-VAR if it isn't there yet.
-The test for presence of ELEMENT is done with `equal'.
+The test for presence of ELEMENT is done with `equal',
+or with COMPARE-FN if that's non-nil.
 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.
@@ -1099,7 +1100,13 @@
 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 compare-fn
+	  (let (present)
+	    (dolist (elt (symbol-value list-var))
+	      (if (funcall compare-fn element elt)
+		  (setq present t)))
+	    present)
+	(member element (symbol-value list-var)))
       (symbol-value list-var)
     (set list-var
 	 (if append
@@ -1730,16 +1737,20 @@
 floating point support.
 
 \(fn SECONDS &optional NODISP)"
-  (when (or obsolete (numberp nodisp))
-    (setq seconds (+ seconds (* 1e-3 nodisp)))
-    (setq nodisp obsolete))
-  (if noninteractive
-      (progn (sleep-for seconds) t)
-    (unless nodisp (redisplay))
-    (or (<= seconds 0)
-	(let ((read (read-event nil nil seconds)))
-	  (or (null read)
-	      (progn (push read unread-command-events) nil))))))
+  (unless (or unread-command-events
+	      unread-post-input-method-events
+	      unread-input-method-events
+	      (>= unread-command-char 0))
+    (when (or obsolete (numberp nodisp))
+      (setq seconds (+ seconds (* 1e-3 nodisp)))
+      (setq nodisp obsolete))
+    (if noninteractive
+	(progn (sleep-for seconds) t)
+      (unless nodisp (redisplay))
+      (or (<= seconds 0)
+	  (let ((read (read-event nil nil seconds)))
+	    (or (null read)
+		(progn (push read unread-command-events) nil)))))))
 
 ;;; Atomic change groups.