Function: parseedn--build-prefixed-map

parseedn--build-prefixed-map is a byte-compiled function defined in parseedn.el.

Signature

(parseedn--build-prefixed-map PREFIX-TOKEN KVS)

Documentation

Build a map that has a prefix for non-qualified keywords.

PREFIX-TOKEN is the AST token for the map prefix. KVS is a list of key, value pairs.

Source Code

;; Defined in ~/.emacs.d/elpa/parseedn-20231203.1909/parseedn.el
(defun parseedn--build-prefixed-map (prefix-token kvs)
  "Build a map that has a prefix for non-qualified keywords.
PREFIX-TOKEN is the AST token for the map prefix.
KVS is a list of key, value pairs."
  (let* ((hash-map (make-hash-table :test 'equal :size (length kvs)))
         ;; map-prefix forms are always "#:...."
         (map-prefix (substring (parseclj-lex-token-form prefix-token) 2)))
    (seq-do (lambda (pair)
              (let* ((key-name (substring (symbol-name (car pair)) 1))
                     (k (if (string-match-p "/" key-name)
                            ;; keyword is already qualified, we must not add the prefix.
                            (car pair)
                          (intern (concat ":" map-prefix "/" key-name))))
                     (v (cadr pair)))
                (puthash k v hash-map)))
            kvs)
    hash-map))