asoc.el
asoc.el copied to clipboard
contrib: alist-append
Something I wrote lately, it might find a home in this library.
(defun alist-append (key value alist)
"Return an ALIST with KEY mapped to VALUE `append'ed to the existing value.
If VALUE (or the existing value) is not a list, it will be
converted into a single element list before being appended."
(let* ((existing (cdr (assoc key alist)))
(existing_ (if (listp existing) existing (list existing)))
(value_ (if (listp value) value (list value)))
(update (append value_ existing_)))
(cons (cons key update) alist)))