Function: map-merge

map-merge is a byte-compiled function defined in map.el.gz.

Signature

(map-merge TYPE &rest MAPS)

Documentation

Merge into a map of TYPE all the key/value pairs in MAPS.

See map-into for all supported values of TYPE. This does not modify any of the MAPS.

Other relevant functions are documented in the map group.

Probably introduced at or before Emacs version 28.1.

Shortdoc

;; map
(map-merge 'alist '(1 2 3 4) #s(hash-table data (5 6 7 8)))
    => ((1 . 2) (3 . 4) (5 . 6) (7 . 8))
  (map-merge 'list '(1 2 3 4) #s(hash-table data (5 6 7 8)))
    => ((1 . 2) (3 . 4) (5 . 6) (7 . 8))
  (map-merge 'plist '(1 2 3 4) #s(hash-table data (5 6 7 8)))
    => (1 2 3 4 5 6 7 8)
  (map-merge 'hash-table '(1 2 3 4) #s(hash-table data (5 6 7 8)))
    => #s(hash-table test equal data (1 2 3 4 5 6 7 8))

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/map.el.gz
(defun map-merge (type &rest maps)
  "Merge into a map of TYPE all the key/value pairs in MAPS.
See `map-into' for all supported values of TYPE.
This does not modify any of the MAPS."
  (apply #'map--merge
         (lambda (result key value)
           (setf (map-elt result key) value)
           result)
         type maps))