Function: object-add-to-list

object-add-to-list is a byte-compiled function defined in eieio.el.gz.

Signature

(object-add-to-list OBJECT SLOT ITEM &optional APPEND)

Documentation

In OBJECT's SLOT, add ITEM to the list of elements.

Optional argument APPEND indicates we need to append to the list. If ITEM already exists in the list in SLOT, then it is not added. Comparison is done with equal through the member function call. If SLOT is unbound, bind it to the list containing ITEM.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/eieio.el.gz
(defun object-add-to-list (object slot item &optional append)
  "In OBJECT's SLOT, add ITEM to the list of elements.
Optional argument APPEND indicates we need to append to the list.
If ITEM already exists in the list in SLOT, then it is not added.
Comparison is done with `equal' through the `member' function call.
If SLOT is unbound, bind it to the list containing ITEM."
  (let (ov)
    ;; Find the originating list.
    (if (not (slot-boundp object slot))
	(setq ov (list item))
      (setq ov (eieio-oref object slot))
      ;; turn it into a list.
      (unless (listp ov)
	(setq ov (list ov)))
      ;; Do the combination
      (if (not (member item ov))
	  (setq ov
		(if append
		    (append ov (list item))
		  (cons item ov)))))
    ;; Set back into the slot.
    (eieio-oset object slot ov)))