From: Eshel Yaron Date: Mon, 18 Nov 2024 13:03:50 +0000 (+0100) Subject: New function 'alist-set' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a375c444822048487f2deeba32a16bdbd1375b1b;p=emacs.git New function 'alist-set' --- diff --git a/lisp/subr.el b/lisp/subr.el index e6f947b4eef..f70eaac5b5f 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1006,6 +1006,10 @@ Example: (assoc key alist testfn)))) (if x (cdr x) default))) +(defun alist-set (key alist value &optional testfn) + "Associate VALUE with KEY in ALIST, comparing keys with TESTFN." + (setf (alist-get key alist nil nil testfn) value)) + (defun remove (elt seq) "Return a copy of SEQ with all occurrences of ELT removed. SEQ must be a list, vector, or string. The comparison is done with `equal'.