diff lisp/frame.el @ 5367:8b70d37ab80e

Use Common Lisp-derived builtins in a few more places in core Lisp. 2011-03-08 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el: * cl-macs.el (loop): * cl-macs.el (cl-expand-do-loop): * cl-macs.el (shiftf): * cl-macs.el (rotatef): * cl-macs.el (assert): * cl-macs.el (cl-defsubst-expand): * etags.el (buffer-tag-table-list): * frame.el: * frame.el (frame-notice-user-settings): * frame.el (minibuffer-frame-list): * frame.el (get-frame-for-buffer-noselect): Use Common Lisp-derived builtins in a few more places, none of them performance-critical, but the style is better.
author Aidan Kehoe <kehoea@parhasard.net>
date Tue, 08 Mar 2011 23:57:21 +0000
parents 0d43872986b6
children ac37a5f7e5be
line wrap: on
line diff
--- a/lisp/frame.el	Tue Mar 08 23:41:52 2011 +0000
+++ b/lisp/frame.el	Tue Mar 08 23:57:21 2011 +0000
@@ -475,12 +475,13 @@
 	      ;; onto a new frame.  The default-minibuffer-frame
 	      ;; variable must be handled similarly.
 	      (let ((users-of-initial
-		     (filtered-frame-list
+		     (remove-if-not
 		      #'(lambda (frame)
 				  (and (not (eq frame frame-initial-frame))
 				       (eq (window-frame
 					    (minibuffer-window frame))
-					   frame-initial-frame))))))
+					   frame-initial-frame)))
+                      (frame-list))))
 		(if (or users-of-initial
 			(eq default-minibuffer-frame frame-initial-frame))
 
@@ -488,10 +489,11 @@
 		    ;; are only minibuffers.
 		    (let* ((new-surrogate
 			    (car
-			     (or (filtered-frame-list
+			     (or (remove-if-not
 				  #'(lambda (frame)
 				      (eq 'only
-					  (frame-property frame 'minibuffer))))
+					  (frame-property frame 'minibuffer)))
+                                  (frame-list))
 				 (minibuffer-frame-list))))
 			   (new-minibuffer (minibuffer-window new-surrogate)))
 
@@ -674,29 +676,22 @@
 ;; XEmacs change: Emacs has make-frame here.  We have it in C, so no need for
 ;; frame-creation-function.
 
-;; XEmacs addition: support optional DEVICE argument.
+;; XEmacs addition: support optional DEVICE argument, use delete-if-not.
 (defun filtered-frame-list (predicate &optional device)
   "Return a list of all live frames which satisfy PREDICATE.
 If optional second arg DEVICE is non-nil, restrict the frames
  returned to that device."
-  (let ((frames (if device (device-frame-list device)
-		  (frame-list)))
-	good-frames)
-    (while (consp frames)
-      (if (funcall predicate (car frames))
-	  (setq good-frames (cons (car frames) good-frames)))
-      (setq frames (cdr frames)))
-    good-frames))
+  (delete-if-not predicate
+                 (if device (device-frame-list device) (frame-list))))
 
 ;; XEmacs addition: support optional DEVICE argument.
 (defun minibuffer-frame-list (&optional device)
   "Return a list of all frames with their own minibuffers.
 If optional second arg DEVICE is non-nil, restrict the frames
  returned to that device."
-  (filtered-frame-list
-   #'(lambda (frame)
-	       (eq frame (window-frame (minibuffer-window frame))))
-   device))
+  (delete-if-not 
+   #'(lambda (frame) (eq frame (window-frame (minibuffer-window frame))))
+   (if device (device-frame-list device) (frame-list))))
 
 ;; XEmacs omission: Emacs has frames-on-display-list here, but that is
 ;; essentially equivalent to supplying the optional DEVICE argument to
@@ -1745,9 +1740,10 @@
 	       (or (plist-get default-frame-plist 'name)
 		   default-frame-name))
 	     (frames
-	      (sort (filtered-frame-list #'(lambda (x)
-					     (or (frame-visible-p x)
-						 (frame-iconified-p x))))
+	      (sort (remove-if-not #'(lambda (x)
+                                       (or (frame-visible-p x)
+                                           (frame-iconified-p x)))
+                                   (frame-list))
 		    #'(lambda (s1 s2)
 			(cond ((and (frame-visible-p s1)
 				    (not (frame-visible-p s2))))