comparison lisp/subr.el @ 5338:8608eadee6ba

Move #'delq, #'delete to Lisp, adding support for sequences. src/ChangeLog addition: 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * device-msw.c (Fmswindows_printer_list): Remove a Fdelete () call here, remove the necessity for it. * fns.c (Fdelete, Fdelq): * lisp.h: Move #'delete, #'delq to Lisp, implemented in terms of #'delete* * select.c (Fown_selection_internal): * select.c (handle_selection_clear): Use delq_no_quit() in these functions, don't reimplement it or use Fdelq(), which is now gone. lisp/ChangeLog addition: 2011-01-11 Aidan Kehoe <kehoea@parhasard.net> * subr.el (delete, delq, remove, remq): Move #'remove, #'remq here, they don't belong in cl-seq.el; move #'delete, #'delq here from fns.c, implement them in terms of #'delete*, allowing support for sequences generally. * update-elc.el (do-autoload-commands): Use #'delete*, not #'delq here, now the latter's no longer dumped. * cl-macs.el (delete, delq): Add compiler macros transforming #'delete and #'delq to #'delete* calls.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 14 Jan 2011 23:35:29 +0000
parents d1b17a33450b
children f00192e1cd49 a9094f28f9a9
comparison
equal deleted inserted replaced
5337:906ccc7dcd70 5338:8608eadee6ba
146 `(if (fboundp ,(car args)) 146 `(if (fboundp ,(car args))
147 nil 147 nil
148 (define-function ,@args))) 148 (define-function ,@args)))
149 149
150 150
151 (defun delete (item sequence)
152 "Delete by side effect any occurrences of ITEM as a member of SEQUENCE.
153
154 The modified SEQUENCE is returned. Comparison is done with `equal'.
155
156 If the first member of a list SEQUENCE is ITEM, there is no way to remove it
157 by side effect; therefore, write `(setq foo (delete element foo))' to be
158 sure of changing the value of `foo'. Also see: `remove'."
159 (delete* item sequence :test #'equal))
160
161 (defun delq (item sequence)
162 "Delete by side effect any occurrences of ITEM as a member of SEQUENCE.
163
164 The modified SEQUENCE is returned. Comparison is done with `eq'. If
165 SEQUENCE is a list and its first member is ITEM, there is no way to remove
166 it by side effect; therefore, write `(setq foo (delq element foo))' to be
167 sure of changing the value of `foo'."
168 (delete* item sequence :test #'eq))
169
170 (defun remove (item sequence)
171 "Remove all occurrences of ITEM in SEQUENCE, testing with `equal'.
172
173 This is a non-destructive function; it makes a copy of SEQUENCE if necessary
174 to avoid corrupting the original SEQUENCE.
175 Also see: `remove*', `delete', `delete*'"
176 (remove* item sequence :test #'equal))
177
178 (defun remq (item sequence)
179 "Remove all occurrences of ITEM in SEQUENCE, comparing with `eq'.
180
181 This is a non-destructive function; it makes a copy of SEQUENCE to avoid
182 corrupting the original SEQUENCE. See also the more general `remove*'."
183 (remove* item sequence :test #'eq))
184
151 (defun assoc-default (key alist &optional test default) 185 (defun assoc-default (key alist &optional test default)
152 "Find object KEY in a pseudo-alist ALIST. 186 "Find object KEY in a pseudo-alist ALIST.
153 ALIST is a list of conses or objects. Each element (or the element's car, 187 ALIST is a list of conses or objects. Each element (or the element's car,
154 if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY). 188 if it is a cons) is compared with KEY by evaluating (TEST (car elt) KEY).
155 If that is non-nil, the element matches; 189 If that is non-nil, the element matches;