changeset 5270:3acaa0fc09be

Use #'some, #'every, etc. for composing boolean operations on lists. 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * info.el (Info-insert-dir): * format.el (format-deannotate-region): * files.el (cd, save-buffers-kill-emacs): Use #'some, #'every and related functions for applying boolean operations to lists, instead of rolling our own ones that cons and don't short-circuit.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 16 Sep 2010 15:58:10 +0100
parents 90a0084b3541
children 2def0d83a5e3
files lisp/ChangeLog lisp/files.el lisp/format.el lisp/info.el
diffstat 4 files changed, 26 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Sep 16 15:34:35 2010 +0100
+++ b/lisp/ChangeLog	Thu Sep 16 15:58:10 2010 +0100
@@ -1,3 +1,12 @@
+2010-09-16  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* info.el (Info-insert-dir):
+	* format.el (format-deannotate-region):
+	* files.el (cd, save-buffers-kill-emacs):
+	Use #'some, #'every and related functions for applying boolean
+	operations to lists, instead of rolling our own ones that cons and
+	don't short-circuit.
+
 2010-09-16  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* bytecomp.el (byte-compile-initial-macro-environment):
--- a/lisp/files.el	Thu Sep 16 15:34:35 2010 +0100
+++ b/lisp/files.el	Thu Sep 16 15:58:10 2010 +0100
@@ -606,15 +606,10 @@
 	(setq cd-path (or (and trypath
 			       (mapcar #'file-name-as-directory trypath))
 			  (list (file-name-as-directory "")))))
-      (or (catch 'found
-	    (mapc #'(lambda (x)
-                      (let ((f (expand-file-name (concat x dir))))
-                        (if (file-directory-p f)
-                            (progn
-                              (cd-absolute f)
-                              (throw 'found t)))))
-                  cd-path)
-	    nil)
+      (or (some #'(lambda (x)
+                    (let ((f (expand-file-name (concat x dir))))
+                      (when (file-directory-p f) (cd-absolute f))))
+                cd-path)
 	  ;; jwz: give a better error message to those of us with the
 	  ;; good taste not to use a kludge like $CDPATH.
 	  (if (equal cd-path '("./"))
@@ -4454,9 +4449,10 @@
 With prefix arg, silently save all file-visiting buffers, then kill."
   (interactive "P")
   (save-some-buffers arg t)
-  (and (or (not (memq t (mapcar #'(lambda (buf) (and (buffer-file-name buf)
-						     (buffer-modified-p buf)))
-				(buffer-list))))
+  (and (or (not (some #'(lambda (buf)
+                          (and (buffer-file-name buf)
+			       (buffer-modified-p buf)))
+                      (buffer-list)))
 	   (yes-or-no-p "Modified buffers exist; exit anyway? "))
        (or (not (fboundp 'process-list))
 	   ;; process-list is not defined on VMS.
--- a/lisp/format.el	Thu Sep 16 15:34:35 2010 +0100
+++ b/lisp/format.el	Thu Sep 16 15:58:10 2010 +0100
@@ -604,9 +604,8 @@
 			  (if (member top-name ans)
 			      ;; This annotation is listed, but still have to
 			      ;; check if multiple annotations are satisfied
-			      (if (member nil (mapcar (lambda (r)
-							(assoc r open-ans))
-						      ans))
+			      (if (notevery (lambda (r) (assoc r open-ans))
+					    ans)
 				  nil	; multiple ans not satisfied
 				;; If there are multiple annotations going
 				;; into one text property, split up the other
--- a/lisp/info.el	Thu Sep 16 15:34:35 2010 +0100
+++ b/lisp/info.el	Thu Sep 16 15:58:10 2010 +0100
@@ -864,14 +864,13 @@
   (if (and Info-dir-contents Info-dir-file-attributes
 	   ;; Verify that none of the files we used has changed
 	   ;; since we used it.
-	   (eval (cons 'and
-		       (mapcar #'(lambda (elt)
-				   (let ((curr (file-attributes (car elt))))
-				     ;; Don't compare the access time.
-				     (if curr (setcar (nthcdr 4 curr) 0))
-				     (setcar (nthcdr 4 (cdr elt)) 0)
-				     (equal (cdr elt) curr)))
-			       Info-dir-file-attributes))))
+	   (every #'(lambda (elt)
+                      (let ((curr (file-attributes (car elt))))
+                        ;; Don't compare the access time.
+                        (if curr (setcar (nthcdr 4 curr) 0))
+                        (setcar (nthcdr 4 (cdr elt)) 0)
+                        (equal (cdr elt) curr)))
+                  Info-dir-file-attributes))
       (insert Info-dir-contents)
     (let ((dirs (reverse Info-directory-list))
 	  buffers lbuffers buffer others nodes dirs-done)