Function: cl-adjoin

cl-adjoin is a byte-compiled function defined in cl-lib.el.gz.

Signature

(cl-adjoin ITEM LIST [KEYWORD VALUE]...)

Documentation

Return ITEM consed onto the front of LIST only if it's not already there.

Otherwise, return LIST unmodified.

Keywords supported: :test :test-not :key

View in manual

Aliases

adjoin (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-lib.el.gz
(defun cl-adjoin (item list &rest keys)
  "Return ITEM consed onto the front of LIST only if it's not already there.
Otherwise, return LIST unmodified.
\nKeywords supported:  :test :test-not :key
\n(fn ITEM LIST [KEYWORD VALUE]...)"
  (declare (important-return-value t)
           (compiler-macro cl--compiler-macro-adjoin))
  (cond ((or (equal keys '(:test eq))
             (and (null keys) (not (numberp item))))
         (if (memq item list) list (cons item list)))
        ((or (equal keys '(:test equal)) (null keys))
         (if (member item list) list (cons item list)))
        (t (apply 'cl--adjoin item list keys))))