]> git.eshelyaron.com Git - emacs.git/commitdiff
New function 'alist-set'
authorEshel Yaron <me@eshelyaron.com>
Mon, 18 Nov 2024 13:03:50 +0000 (14:03 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 18 Nov 2024 13:03:50 +0000 (14:03 +0100)
lisp/subr.el

index e6f947b4eef1c21063bd92805d567dbc234a3c11..f70eaac5b5f8a468304d2909a42c7839e73ff636 100644 (file)
@@ -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'.