comparison lisp/cl-extra.el @ 5312:f6471e4ae703

Avoid some dynamic scope stupidity in interpreted code, #'notany, #'notevery. 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-extra.el (notany, notevery): Avoid some dynamic scope stupidity with local variable names in these functions, when they weren't prefixed with cl-; go into some more detail in the doc strings.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 29 Dec 2010 23:38:38 +0000
parents 09fed7053634
children ba62563ec7c7 6506fcb40fcf
comparison
equal deleted inserted replaced
5311:07d24b1f27a7 5312:f6471e4ae703
126 (defun complement (function &optional documentation) 126 (defun complement (function &optional documentation)
127 "Return a function which gives the logical inverse of what FUNCTION would." 127 "Return a function which gives the logical inverse of what FUNCTION would."
128 `(lambda (&rest arguments) ,@(if documentation (list documentation)) 128 `(lambda (&rest arguments) ,@(if documentation (list documentation))
129 (not (apply ',function arguments)))) 129 (not (apply ',function arguments))))
130 130
131 (defun notany (cl-pred cl-seq &rest cl-rest) 131 (defun notany (cl-predicate cl-seq &rest cl-rest)
132 "Return true if PREDICATE is false of every element of SEQ or SEQs." 132 "Return true if PREDICATE is false of every element of SEQUENCE.
133 (not (apply 'some cl-pred cl-seq cl-rest))) 133
134 134 With optional SEQUENCES, call PREDICATE each time with as many arguments as
135 (defun notevery (cl-pred cl-seq &rest cl-rest) 135 there are SEQUENCES (plus one for the element from SEQUENCE).
136 "Return true if PREDICATE is false of some element of SEQ or SEQs." 136
137 (not (apply 'every cl-pred cl-seq cl-rest))) 137 arguments: (PREDICATE SEQUENCES &rest SEQUENCES)"
138 (not (apply 'some cl-predicate cl-seq cl-rest)))
139
140 (defun notevery (cl-predicate cl-seq &rest cl-rest)
141 "Return true if PREDICATE is false of some element of SEQUENCE.
142
143 With optional SEQUENCES, call PREDICATE each time with as many arguments as
144 there are SEQUENCES (plus one for the element from SEQUENCE).
145
146 arguments: (PREDICATE SEQUENCES &rest SEQUENCES)"
147 (not (apply 'every cl-predicate cl-seq cl-rest)))
138 148
139 ;;; Support for `loop'. 149 ;;; Support for `loop'.
140 (defalias 'cl-map-keymap 'map-keymap) 150 (defalias 'cl-map-keymap 'map-keymap)
141 151
142 (defun cl-map-keymap-recursively (cl-func-rec cl-map &optional cl-base) 152 (defun cl-map-keymap-recursively (cl-func-rec cl-map &optional cl-base)