Function: map-insert
map-insert is a byte-compiled function defined in map.el.gz.
Signature
(map-insert MAP KEY VALUE)
Documentation
Return a new map like MAP except that it associates KEY with VALUE.
This does not modify MAP.
If you want to insert an element in place, use map-put!.
The default implementation defaults to map-copy and map-put!.
Other relevant functions are documented in the map group.
Probably introduced at or before Emacs version 27.1.
Shortdoc
;; map
(map-insert (list 'bar 1 'baz 3 'foo 7) 'foo 2)
=> (foo 2 bar 1 baz 3 foo 7)
(map-insert (list '(bar . 1) '(baz . 3) '(foo . 7)) 'foo 2)
=> ((foo . 2) (bar . 1) (baz . 3) (foo . 7))
(map-insert [bar bot baz] 1 'foo)
=> [bar foo baz]
(map-insert #s(hash-table data (bar 1 baz 3 foo 7)) 'foo 2)
=> #s(hash-table data (bar 1 baz 3 foo 2))
Implementations
(map-insert (MAP list) KEY VALUE) in `map.el'.
Cons KEY and VALUE to the front of MAP.
(map-insert MAP KEY VALUE) in `map.el'.
Undocumented
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/map.el.gz
(cl-defgeneric map-insert (map key value)
"Return a new map like MAP except that it associates KEY with VALUE.
This does not modify MAP.
If you want to insert an element in place, use `map-put!'.
The default implementation defaults to `map-copy' and `map-put!'."
(let ((copy (map-copy map)))
(map-put! copy key value)
copy))