Function: cl-delete
cl-delete is an autoloaded and byte-compiled function defined in
cl-seq.el.gz.
Signature
(cl-delete ITEM SEQ [KEYWORD VALUE]...)
Documentation
Remove all occurrences of ITEM in SEQ.
This is a destructive function; it reuses the storage of SEQ whenever possible.
Keywords supported: :test :test-not :key :count :start :end :from-end
Aliases
delete* (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-seq.el.gz
;;;###autoload
(defun cl-delete (cl-item cl-seq &rest cl-keys)
"Remove all occurrences of ITEM in SEQ.
This is a destructive function; it reuses the storage of SEQ whenever possible.
\nKeywords supported: :test :test-not :key :count :start :end :from-end
\n(fn ITEM SEQ [KEYWORD VALUE]...)"
(cl--parsing-keywords (:test :test-not :key :if :if-not :count :from-end
(:start 0) :end) ()
(let ((len (length cl-seq)))
(if (<= (or cl-count (setq cl-count len)) 0)
cl-seq
(if (listp cl-seq)
(if (and cl-from-end (< cl-count (/ len 2)))
(let (cl-i)
(while (and (>= (setq cl-count (1- cl-count)) 0)
(setq cl-i (cl--position cl-item cl-seq cl-start
cl-end cl-from-end)))
(if (= cl-i 0) (setq cl-seq (cdr cl-seq))
(let ((cl-tail (nthcdr (1- cl-i) cl-seq)))
(setcdr cl-tail (cdr (cdr cl-tail)))))
(setq cl-end cl-i))
cl-seq)
(setq cl-end (- (or cl-end len) cl-start))
(if (= cl-start 0)
(progn
(while (and cl-seq
(> cl-end 0)
(cl--check-test cl-item (car cl-seq))
(setq cl-end (1- cl-end) cl-seq (cdr cl-seq))
(> (setq cl-count (1- cl-count)) 0)))
(setq cl-end (1- cl-end)))
(setq cl-start (1- cl-start)))
(if (and (> cl-count 0) (> cl-end 0))
(let ((cl-p (nthcdr cl-start cl-seq)))
(while (and (cdr cl-p) (> cl-end 0))
(if (cl--check-test cl-item (car (cdr cl-p)))
(progn
(setcdr cl-p (cdr (cdr cl-p)))
(if (= (setq cl-count (1- cl-count)) 0)
(setq cl-end 1)))
(setq cl-p (cdr cl-p)))
(setq cl-end (1- cl-end)))))
cl-seq)
(apply 'cl-remove cl-item cl-seq cl-keys))))))