asoc.el icon indicating copy to clipboard operation
asoc.el copied to clipboard

contrib: alist-append

Open fommil opened this issue 3 years ago • 0 comments

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)))

fommil avatar Oct 25 '22 12:10 fommil