Function: TeX-delete-dups-by-car

TeX-delete-dups-by-car is a byte-compiled function defined in tex.el.

Signature

(TeX-delete-dups-by-car ALIST &optional KEEP-LIST)

Documentation

Return a list of all elements in ALIST, but each car only once.

Elements of KEEP-LIST are not removed even if duplicate.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-delete-dups-by-car (alist &optional keep-list)
  "Return a list of all elements in ALIST, but each car only once.
Elements of KEEP-LIST are not removed even if duplicate."
  ;; Copy of `reftex-uniquify-by-car' (written by David Kastrup).
  (setq keep-list (TeX-sort-strings keep-list))
  (setq alist (sort (copy-sequence alist)
                    #'TeX-car-string-lessp))
  (let ((new alist) elt)
    (while (cdr new)
      (setq elt (caar new))
      (while (and keep-list (string< (car keep-list) elt))
        (setq keep-list (cdr keep-list)))
      (unless (and keep-list (string= elt (car keep-list)))
        (while (string= elt (car (cadr new)))
          (setcdr new (cddr new))))
      (setq new (cdr new))))
  alist)