changeset 73465:03050ee24abc

(add-to-list): Optimize if compare-fn is `eq' or `eql'. (sit-for): If last command was a prefix arg, add the read-ahead event to unread-command-events as (t . EVENT) so it will be added to this-command-keys by read-key-sequence.
author Kim F. Storm <storm@cua.dk>
date Sun, 22 Oct 2006 22:32:53 +0000
parents e3fbddada23e
children c470e5e21c36
files lisp/subr.el
diffstat 1 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/subr.el	Sun Oct 22 22:32:43 2006 +0000
+++ b/lisp/subr.el	Sun Oct 22 22:32:53 2006 +0000
@@ -1100,13 +1100,19 @@
 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 (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)))
+  (if (cond
+       ((eq compare-fn 'eq)
+	(memq element (symbol-value list-var)))
+       ((eq compare-fn 'eql)
+	(memql element (symbol-value list-var)))
+       (compare-fn
+	(let (present)
+	  (dolist (elt (symbol-value list-var))
+	    (if (funcall compare-fn element elt)
+		(setq present t)))
+	  present))
+       (t
+	(member element (symbol-value list-var))))
       (symbol-value list-var)
     (set list-var
 	 (if append
@@ -1752,8 +1758,14 @@
     (or nodisp (redisplay))
     (let ((read (read-event nil nil seconds)))
       (or (null read)
-	  (progn (push read unread-command-events)
-		 nil))))))
+	  (progn
+	    ;; If last command was a prefix arg, e.g. C-u, push this event onto
+	    ;; unread-command-events as (t . EVENT) so it will be added to
+	    ;; this-command-keys by read-key-sequence.
+	    (if (eq overriding-terminal-local-map universal-argument-map)
+		(setq read (cons t read)))
+	    (push read unread-command-events)
+	    nil))))))
 
 ;;; Atomic change groups.