diff lisp/cl-seq.el @ 2153:393039450288

[xemacs-hg @ 2004-06-26 21:25:23 by james] Synch with Emacs 21.3.
author james
date Sat, 26 Jun 2004 21:25:24 +0000
parents 023b83f4e54b
children 6772ce4d982b
line wrap: on
line diff
--- a/lisp/cl-seq.el	Fri Jun 25 21:50:24 2004 +0000
+++ b/lisp/cl-seq.el	Sat Jun 26 21:25:24 2004 +0000
@@ -24,7 +24,7 @@
 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ;; 02111-1307, USA.
 
-;;; Synched up with: FSF 19.34.
+;;; Synched up with: FSF 21.3.
 
 ;;; Commentary:
 
@@ -53,14 +53,6 @@
     (error "Tried to load `cl-seq' before `cl'!"))
 
 
-;;; We define these here so that this file can compile without having
-;;; loaded the cl.el file already.
-
-(defmacro cl-push (x place) (list 'setq place (list 'cons x place)))
-(defmacro cl-pop (place)
-  (list 'car (list 'prog1 place (list 'setq place (list 'cdr place)))))
-
-
 ;;; Keyword parsing.  This is special-cased here so that we can compile
 ;;; this file independent from cl-macs.
 
@@ -90,9 +82,9 @@
 	     (let* ((var (if (consp x) (car x) x))
 		    (mem (list 'car (list 'cdr (list 'memq (list 'quote var)
 						     'cl-keys)))))
-	       (if (eq var ':test-not)
+	       (if (eq var :test-not)
 		   (setq mem (list 'and mem (list 'setq 'cl-test mem) t)))
-	       (if (eq var ':if-not)
+	       (if (eq var :if-not)
 		   (setq mem (list 'and mem (list 'setq 'cl-if mem) t)))
 	       (list (intern
 		      (format "cl-%s" (substring (symbol-name var) 1)))
@@ -161,16 +153,16 @@
     (or (listp cl-seq) (setq cl-seq (append cl-seq nil)))
     (setq cl-seq (subseq cl-seq cl-start cl-end))
     (if cl-from-end (setq cl-seq (nreverse cl-seq)))
-    (let ((cl-accum (cond ((memq ':initial-value cl-keys) cl-initial-value)
-			  (cl-seq (cl-check-key (cl-pop cl-seq)))
+    (let ((cl-accum (cond ((memq :initial-value cl-keys) cl-initial-value)
+			  (cl-seq (cl-check-key (pop cl-seq)))
 			  (t (funcall cl-func)))))
       (if cl-from-end
 	  (while cl-seq
-	    (setq cl-accum (funcall cl-func (cl-check-key (cl-pop cl-seq))
+	    (setq cl-accum (funcall cl-func (cl-check-key (pop cl-seq))
 				    cl-accum)))
 	(while cl-seq
 	  (setq cl-accum (funcall cl-func cl-accum
-				  (cl-check-key (cl-pop cl-seq))))))
+				  (cl-check-key (pop cl-seq))))))
       cl-accum)))
 
 (defun fill (seq item &rest cl-keys)
@@ -247,8 +239,8 @@
 	    (if cl-i
 		(let ((cl-res (apply 'delete* cl-item (append cl-seq nil)
 				     (append (if cl-from-end
-						 (list ':end (1+ cl-i))
-					       (list ':start cl-i))
+						 (list :end (1+ cl-i))
+					       (list :start cl-i))
 					     cl-keys))))
 		  (if (listp cl-seq) cl-res
 		    (if (stringp cl-seq) (concat cl-res) (vconcat cl-res))))
@@ -271,8 +263,8 @@
 			   (and (cdr cl-p)
 				(apply 'delete* cl-item
 				       (copy-sequence (cdr cl-p))
-				       ':start 0 ':end (1- cl-end)
-				       ':count (1- cl-count) cl-keys))))
+				       :start 0 :end (1- cl-end)
+				       :count (1- cl-count) cl-keys))))
 		cl-seq))
 	  cl-seq)))))
 
@@ -281,14 +273,14 @@
 This is a non-destructive function; it makes a copy of SEQ if necessary
 to avoid corrupting the original SEQ.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'remove* nil cl-list ':if cl-pred cl-keys))
+  (apply 'remove* nil cl-list :if cl-pred cl-keys))
 
 (defun remove-if-not (cl-pred cl-list &rest cl-keys)
   "Remove all items not satisfying PREDICATE in SEQ.
 This is a non-destructive function; it makes a copy of SEQ if necessary
 to avoid corrupting the original SEQ.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'remove* nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'remove* nil cl-list :if-not cl-pred cl-keys))
 
 (defun delete* (cl-item cl-seq &rest cl-keys)
   "Remove all occurrences of ITEM in SEQ.
@@ -336,17 +328,15 @@
   "Remove all items satisfying PREDICATE in SEQ.
 This is a destructive function; it reuses the storage of SEQ whenever possible.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'delete* nil cl-list ':if cl-pred cl-keys))
+  (apply 'delete* nil cl-list :if cl-pred cl-keys))
 
 (defun delete-if-not (cl-pred cl-list &rest cl-keys)
   "Remove all items not satisfying PREDICATE in SEQ.
 This is a destructive function; it reuses the storage of SEQ whenever possible.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'delete* nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'delete* nil cl-list :if-not cl-pred cl-keys))
 
-(or (and (fboundp 'delete) (subrp (symbol-function 'delete)))
-    (defalias 'delete (function (lambda (x y) (delete* x y ':test 'equal)))))
-
+;; XEmacs change: this is in subr.el in Emacs
 (defun remove (cl-item cl-seq)
   "Remove all occurrences of ITEM in SEQ, testing with `equal'
 This is a non-destructive function; it makes a copy of SEQ if necessary
@@ -354,6 +344,7 @@
 Also see: `remove*', `delete', `delete*'"
   (remove* cl-item cl-seq ':test 'equal))
 
+;; XEmacs change: this is in subr.el in Emacs
 (defun remq (cl-elt cl-list)
   "Remove all occurrences of ELT in LIST, comparing with `eq'.
 This is a non-destructive function; it makes a copy of LIST to avoid
@@ -430,22 +421,22 @@
 	  (or cl-from-end
 	      (progn (cl-set-elt cl-seq cl-i cl-new)
 		     (setq cl-i (1+ cl-i) cl-count (1- cl-count))))
-	  (apply 'nsubstitute cl-new cl-old cl-seq ':count cl-count
-		 ':start cl-i cl-keys))))))
+	  (apply 'nsubstitute cl-new cl-old cl-seq :count cl-count
+		 :start cl-i cl-keys))))))
 
 (defun substitute-if (cl-new cl-pred cl-list &rest cl-keys)
   "Substitute NEW for all items satisfying PREDICATE in SEQ.
 This is a non-destructive function; it makes a copy of SEQ if necessary
 to avoid corrupting the original SEQ.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'substitute cl-new nil cl-list ':if cl-pred cl-keys))
+  (apply 'substitute cl-new nil cl-list :if cl-pred cl-keys))
 
 (defun substitute-if-not (cl-new cl-pred cl-list &rest cl-keys)
   "Substitute NEW for all items not satisfying PREDICATE in SEQ.
 This is a non-destructive function; it makes a copy of SEQ if necessary
 to avoid corrupting the original SEQ.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'substitute cl-new nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'substitute cl-new nil cl-list :if-not cl-pred cl-keys))
 
 (defun nsubstitute (cl-new cl-old cl-seq &rest cl-keys)
   "Substitute NEW for OLD in SEQ.
@@ -483,13 +474,13 @@
   "Substitute NEW for all items satisfying PREDICATE in SEQ.
 This is a destructive function; it reuses the storage of SEQ whenever possible.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'nsubstitute cl-new nil cl-list ':if cl-pred cl-keys))
+  (apply 'nsubstitute cl-new nil cl-list :if cl-pred cl-keys))
 
 (defun nsubstitute-if-not (cl-new cl-pred cl-list &rest cl-keys)
   "Substitute NEW for all items not satisfying PREDICATE in SEQ.
 This is a destructive function; it reuses the storage of SEQ whenever possible.
 Keywords supported:  :key :count :start :end :from-end"
-  (apply 'nsubstitute cl-new nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'nsubstitute cl-new nil cl-list :if-not cl-pred cl-keys))
 
 (defun find (cl-item cl-seq &rest cl-keys)
   "Find the first occurrence of ITEM in LIST.
@@ -502,13 +493,13 @@
   "Find the first item satisfying PREDICATE in LIST.
 Return the matching ITEM, or nil if not found.
 Keywords supported:  :key :start :end :from-end"
-  (apply 'find nil cl-list ':if cl-pred cl-keys))
+  (apply 'find nil cl-list :if cl-pred cl-keys))
 
 (defun find-if-not (cl-pred cl-list &rest cl-keys)
   "Find the first item not satisfying PREDICATE in LIST.
 Return the matching ITEM, or nil if not found.
 Keywords supported:  :key :start :end :from-end"
-  (apply 'find nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'find nil cl-list :if-not cl-pred cl-keys))
 
 (defun position (cl-item cl-seq &rest cl-keys)
   "Find the first occurrence of ITEM in LIST.
@@ -543,13 +534,13 @@
   "Find the first item satisfying PREDICATE in LIST.
 Return the index of the matching item, or nil if not found.
 Keywords supported:  :key :start :end :from-end"
-  (apply 'position nil cl-list ':if cl-pred cl-keys))
+  (apply 'position nil cl-list :if cl-pred cl-keys))
 
 (defun position-if-not (cl-pred cl-list &rest cl-keys)
   "Find the first item not satisfying PREDICATE in LIST.
 Return the index of the matching item, or nil if not found.
 Keywords supported:  :key :start :end :from-end"
-  (apply 'position nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'position nil cl-list :if-not cl-pred cl-keys))
 
 (defun count (cl-item cl-seq &rest cl-keys)
   "Count the number of occurrences of ITEM in LIST.
@@ -559,7 +550,7 @@
       (or cl-end (setq cl-end (length cl-seq)))
       (if (consp cl-seq) (setq cl-seq (nthcdr cl-start cl-seq)))
       (while (< cl-start cl-end)
-	(setq cl-x (if (consp cl-seq) (cl-pop cl-seq) (aref cl-seq cl-start)))
+	(setq cl-x (if (consp cl-seq) (pop cl-seq) (aref cl-seq cl-start)))
 	(if (cl-check-test cl-item cl-x) (setq cl-count (1+ cl-count)))
 	(setq cl-start (1+ cl-start)))
       cl-count)))
@@ -567,17 +558,17 @@
 (defun count-if (cl-pred cl-list &rest cl-keys)
   "Count the number of items satisfying PREDICATE in LIST.
 Keywords supported:  :key :start :end"
-  (apply 'count nil cl-list ':if cl-pred cl-keys))
+  (apply 'count nil cl-list :if cl-pred cl-keys))
 
 (defun count-if-not (cl-pred cl-list &rest cl-keys)
   "Count the number of items not satisfying PREDICATE in LIST.
 Keywords supported:  :key :start :end"
-  (apply 'count nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'count nil cl-list :if-not cl-pred cl-keys))
 
 (defun mismatch (cl-seq1 cl-seq2 &rest cl-keys)
   "Compare SEQ1 with SEQ2, return index of first mismatching element.
 Return nil if the sequences match.  If one sequence is a prefix of the
-other, the return value indicates the end of the shorted sequence.
+other, the return value indicates the end of the shorter sequence.
 Keywords supported:  :test :test-not :key :start1 :end1 :start2 :end2 :from-end"
   (cl-parsing-keywords (:test :test-not :key :from-end
 			(:start1 0) :end1 (:start2 0) :end2) ()
@@ -622,9 +613,9 @@
 		    (setq cl-pos (cl-position cl-first cl-seq2
 					      cl-start2 cl-end2 cl-from-end))
 		    (apply 'mismatch cl-seq1 cl-seq2
-			   ':start1 (1+ cl-start1) ':end1 cl-end1
-			   ':start2 (1+ cl-pos) ':end2 (+ cl-pos cl-len)
-			   ':from-end nil cl-keys))
+			   :start1 (1+ cl-start1) :end1 cl-end1
+			   :start2 (1+ cl-pos) :end2 (+ cl-pos cl-len)
+			   :from-end nil cl-keys))
 	  (if cl-from-end (setq cl-end2 cl-pos) (setq cl-start2 (1+ cl-pos))))
 	(and (< cl-start2 cl-end2) cl-pos)))))
 
@@ -659,8 +650,8 @@
       (while (and cl-seq1 cl-seq2)
 	(if (funcall cl-pred (cl-check-key (car cl-seq2))
 		     (cl-check-key (car cl-seq1)))
-	    (cl-push (cl-pop cl-seq2) cl-res)
-	  (cl-push (cl-pop cl-seq1) cl-res)))
+	    (push (pop cl-seq2) cl-res)
+	  (push (pop cl-seq1) cl-res)))
       (coerce (nconc (nreverse cl-res) cl-seq1 cl-seq2) cl-type))))
 
 ;;; See compiler macro in cl-macs.el
@@ -681,13 +672,13 @@
   "Find the first item satisfying PREDICATE in LIST.
 Return the sublist of LIST whose car matches.
 Keywords supported:  :key"
-  (apply 'member* nil cl-list ':if cl-pred cl-keys))
+  (apply 'member* nil cl-list :if cl-pred cl-keys))
 
 (defun member-if-not (cl-pred cl-list &rest cl-keys)
   "Find the first item not satisfying PREDICATE in LIST.
 Return the sublist of LIST whose car matches.
 Keywords supported:  :key"
-  (apply 'member* nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'member* nil cl-list :if-not cl-pred cl-keys))
 
 (defun cl-adjoin (cl-item cl-list &rest cl-keys)
   (if (cl-parsing-keywords (:key) t
@@ -713,12 +704,12 @@
 (defun assoc-if (cl-pred cl-list &rest cl-keys)
   "Find the first item whose car satisfies PREDICATE in LIST.
 Keywords supported:  :key"
-  (apply 'assoc* nil cl-list ':if cl-pred cl-keys))
+  (apply 'assoc* nil cl-list :if cl-pred cl-keys))
 
 (defun assoc-if-not (cl-pred cl-list &rest cl-keys)
   "Find the first item whose car does not satisfy PREDICATE in LIST.
 Keywords supported:  :key"
-  (apply 'assoc* nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'assoc* nil cl-list :if-not cl-pred cl-keys))
 
 (defun rassoc* (cl-item cl-alist &rest cl-keys)
   "Find the first item whose cdr matches ITEM in LIST.
@@ -735,12 +726,12 @@
 (defun rassoc-if (cl-pred cl-list &rest cl-keys)
   "Find the first item whose cdr satisfies PREDICATE in LIST.
 Keywords supported:  :key"
-  (apply 'rassoc* nil cl-list ':if cl-pred cl-keys))
+  (apply 'rassoc* nil cl-list :if cl-pred cl-keys))
 
 (defun rassoc-if-not (cl-pred cl-list &rest cl-keys)
   "Find the first item whose cdr does not satisfy PREDICATE in LIST.
 Keywords supported:  :key"
-  (apply 'rassoc* nil cl-list ':if-not cl-pred cl-keys))
+  (apply 'rassoc* nil cl-list :if-not cl-pred cl-keys))
 
 (defun union (cl-list1 cl-list2 &rest cl-keys)
   "Combine LIST1 and LIST2 using a set-union operation.
@@ -757,8 +748,8 @@
 	   (if (or cl-keys (numberp (car cl-list2)))
 	       (setq cl-list1 (apply 'adjoin (car cl-list2) cl-list1 cl-keys))
 	     (or (memq (car cl-list2) cl-list1)
-		 (cl-push (car cl-list2) cl-list1)))
-	   (cl-pop cl-list2))
+		 (push (car cl-list2) cl-list1)))
+	   (pop cl-list2))
 	 cl-list1)))
 
 (defun nunion (cl-list1 cl-list2 &rest cl-keys)
@@ -787,8 +778,8 @@
 		       (apply 'member* (cl-check-key (car cl-list2))
 			      cl-list1 cl-keys)
 		     (memq (car cl-list2) cl-list1))
-		   (cl-push (car cl-list2) cl-res))
-	       (cl-pop cl-list2))
+		   (push (car cl-list2) cl-res))
+	       (pop cl-list2))
 	     cl-res)))))
 
 (defun nintersection (cl-list1 cl-list2 &rest cl-keys)
@@ -813,8 +804,8 @@
 		  (apply 'member* (cl-check-key (car cl-list1))
 			 cl-list2 cl-keys)
 		(memq (car cl-list1) cl-list2))
-	      (cl-push (car cl-list1) cl-res))
-	  (cl-pop cl-list1))
+	      (push (car cl-list1) cl-res))
+	  (pop cl-list1))
 	cl-res))))
 
 (defun nset-difference (cl-list1 cl-list2 &rest cl-keys)
@@ -858,20 +849,20 @@
 	     (while (and cl-list1
 			 (apply 'member* (cl-check-key (car cl-list1))
 				cl-list2 cl-keys))
-	       (cl-pop cl-list1))
+	       (pop cl-list1))
 	     (null cl-list1)))))
 
 (defun subst-if (cl-new cl-pred cl-tree &rest cl-keys)
   "Substitute NEW for elements matching PREDICATE in TREE (non-destructively).
 Return a copy of TREE with all matching elements replaced by NEW.
 Keywords supported:  :key"
-  (apply 'sublis (list (cons nil cl-new)) cl-tree ':if cl-pred cl-keys))
+  (apply 'sublis (list (cons nil cl-new)) cl-tree :if cl-pred cl-keys))
 
 (defun subst-if-not (cl-new cl-pred cl-tree &rest cl-keys)
   "Substitute NEW for elts not matching PREDICATE in TREE (non-destructively).
 Return a copy of TREE with all non-matching elements replaced by NEW.
 Keywords supported:  :key"
-  (apply 'sublis (list (cons nil cl-new)) cl-tree ':if-not cl-pred cl-keys))
+  (apply 'sublis (list (cons nil cl-new)) cl-tree :if-not cl-pred cl-keys))
 
 (defun nsubst (cl-new cl-old cl-tree &rest cl-keys)
   "Substitute NEW for OLD everywhere in TREE (destructively).
@@ -884,13 +875,13 @@
   "Substitute NEW for elements matching PREDICATE in TREE (destructively).
 Any element of TREE which matches is changed to NEW (via a call to `setcar').
 Keywords supported:  :key"
-  (apply 'nsublis (list (cons nil cl-new)) cl-tree ':if cl-pred cl-keys))
+  (apply 'nsublis (list (cons nil cl-new)) cl-tree :if cl-pred cl-keys))
 
 (defun nsubst-if-not (cl-new cl-pred cl-tree &rest cl-keys)
   "Substitute NEW for elements not matching PREDICATE in TREE (destructively).
 Any element of TREE which matches is changed to NEW (via a call to `setcar').
 Keywords supported:  :key"
-  (apply 'nsublis (list (cons nil cl-new)) cl-tree ':if-not cl-pred cl-keys))
+  (apply 'nsublis (list (cons nil cl-new)) cl-tree :if-not cl-pred cl-keys))
 
 (defun sublis (cl-alist cl-tree &rest cl-keys)
   "Perform substitutions indicated by ALIST in TREE (non-destructively).
@@ -952,4 +943,5 @@
 
 (run-hooks 'cl-seq-load-hook)
 
+;;; arch-tag: ec1cc072-9006-4225-b6ba-d6b07ed1710c
 ;;; cl-seq.el ends here