Function: nrepl--merge

nrepl--merge is a byte-compiled function defined in nrepl-dict.el.

Signature

(nrepl--merge DICT1 DICT2 &optional NO-JOIN)

Documentation

Join nREPL dicts DICT1 and DICT2 in a meaningful way.

String values for non "id" and "session" keys are concatenated. Lists are appended. nREPL dicts merged recursively. All other objects are accumulated into a list. DICT1 is modified destructively and then returned. If NO-JOIN is given, return the first non nil dict.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/nrepl-dict.el
(defun nrepl--merge (dict1 dict2 &optional no-join)
  "Join nREPL dicts DICT1 and DICT2 in a meaningful way.
String values for non \"id\" and \"session\" keys are concatenated. Lists
are appended. nREPL dicts merged recursively. All other objects are
accumulated into a list. DICT1 is modified destructively and
then returned.
If NO-JOIN is given, return the first non nil dict."
  (if no-join
      (or dict1 dict2)
    (cond ((null dict1) dict2)
          ((null dict2) dict1)
          ((stringp dict1) (concat dict1 dict2))
          ((nrepl-dict-p dict1)
           (nrepl-dict-map
            (lambda (k2 v2)
              (nrepl-dict-put dict1 k2
                              (nrepl--merge (nrepl-dict-get dict1 k2) v2
                                            (member k2 '("id" "session")))))
            dict2)
           dict1)
          ((and (listp dict2) (listp dict1)) (append dict1 dict2))
          ((listp dict1) (append dict1 (list dict2)))
          (t `(,dict1 ,dict2)))))