Function: evil--add-to-alist

evil--add-to-alist is a macro defined in evil-common.el.

Signature

(evil--add-to-alist ALIST [KEY VAL]...)

Documentation

Add the association of KEY and VAL to the value of ALIST.

If the list already contains an entry for KEY, update that entry; otherwise prepend it to the list.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
;;; List functions

(defmacro evil--add-to-alist (alist &rest elements)
  "Add the association of KEY and VAL to the value of ALIST.
If the list already contains an entry for KEY, update that entry;
otherwise prepend it to the list.

\(fn ALIST [KEY VAL]...)"
  `(progn
     ,@(cl-loop
        for (key val) on elements by #'cddr collect
        (if (< emacs-major-version 26)
            (macroexp-let2* nil ((k key) (p `(assoc ,k ,alist)))
              `(if ,p (setcdr ,p ,val)
                 (push (cons ,k ,val) ,alist)))
          `(setf (alist-get ,key ,alist nil nil #'equal) ,val)))
     ,alist))