add-to-ordered-list

add-to-ordered-list is a compiled Lisp function in `subr.el'.

(add-to-ordered-list LIST-VAR ELEMENT &optional ORDER)

Add ELEMENT to the value of LIST-VAR if it isn't there yet.
The test for presence of ELEMENT is done with `eq'.

The resulting list is reordered so that the elements are in the
order given by each element's numeric list order. Elements
without a numeric list order are placed at the end of the list.

If the third optional argument ORDER is a number (integer or
float), set the element's list order to the given value. If
ORDER is nil or omitted, do not change the numeric order of
ELEMENT. If ORDER has any other value, remove the numeric order
of ELEMENT if it has one.

The list order for each element is stored in LIST-VAR's
`list-order' property.

The return value is the new value of LIST-VAR.