diff 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
line wrap: on
line diff
--- a/lisp/subr.el	Fri Jan 14 23:23:30 2011 +0000
+++ b/lisp/subr.el	Fri Jan 14 23:35:29 2011 +0000
@@ -148,6 +148,40 @@
      (define-function ,@args)))
 
 
+(defun delete (item sequence)
+  "Delete by side effect any occurrences of ITEM as a member of SEQUENCE.
+
+The modified SEQUENCE is returned.  Comparison is done with `equal'.
+
+If the first member of a list SEQUENCE is ITEM, there is no way to remove it
+by side effect; therefore, write `(setq foo (delete element foo))' to be
+sure of changing the value of `foo'.  Also see: `remove'."
+  (delete* item sequence :test #'equal))
+
+(defun delq (item sequence)
+  "Delete by side effect any occurrences of ITEM as a member of SEQUENCE.
+
+The modified SEQUENCE is returned.  Comparison is done with `eq'.  If
+SEQUENCE is a list and its first member is ITEM, there is no way to remove
+it by side effect; therefore, write `(setq foo (delq element foo))' to be
+sure of changing the value of `foo'."
+  (delete* item sequence :test #'eq))
+
+(defun remove (item sequence)
+  "Remove all occurrences of ITEM in SEQUENCE, testing with `equal'.
+
+This is a non-destructive function; it makes a copy of SEQUENCE if necessary
+to avoid corrupting the original SEQUENCE.
+Also see: `remove*', `delete', `delete*'"
+  (remove* item sequence :test #'equal))
+
+(defun remq (item sequence)
+  "Remove all occurrences of ITEM in SEQUENCE, comparing with `eq'.
+
+This is a non-destructive function; it makes a copy of SEQUENCE to avoid
+corrupting the original SEQUENCE.  See also the more general `remove*'."
+  (remove* item sequence :test #'eq))
+
 (defun assoc-default (key alist &optional test default)
   "Find object KEY in a pseudo-alist ALIST.
 ALIST is a list of conses or objects.  Each element (or the element's car,