Function: cider-macrostep--refresh-gensyms

cider-macrostep--refresh-gensyms is a byte-compiled function defined in cider-macrostep.el.

Signature

(cider-macrostep--refresh-gensyms)

Documentation

Color each distinct gensym in the active expansions.

All occurrences of a gensym share one face; different gensyms get different faces from cider-macrostep-gensym-faces. A no-op when disabled.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260822.1520/cider-macrostep.el
(defun cider-macrostep--refresh-gensyms ()
  "Color each distinct gensym in the active expansions.
All occurrences of a gensym share one face; different gensyms get different
faces from `cider-macrostep-gensym-faces'.  A no-op when disabled."
  (cider-macrostep--clear-gensym-overlays)
  (when (and cider-macrostep-color-gensyms cider-macrostep-gensym-faces)
    (let ((faces (vconcat cider-macrostep-gensym-faces))
          (assigned (make-hash-table :test 'equal))
          (next 0)
          ;; Nested expansions overlap (the outer overlay still spans the inner
          ;; text), so the same token is found once per containing overlay;
          ;; `seq-uniq' collapses those identical (NAME BEG END) hits.
          (matches (seq-uniq (seq-mapcat #'cider-macrostep--gensyms-in
                                         cider-macrostep--overlays))))
      (dolist (match matches)
        (pcase-let ((`(,name ,beg ,end) match))
          (let ((face (or (gethash name assigned)
                          (let ((f (aref faces (mod next (length faces)))))
                            (puthash name f assigned)
                            (setq next (1+ next))
                            f)))
                (gov (make-overlay beg end)))
            (overlay-put gov 'face face)
            (overlay-put gov 'priority 90)
            (push gov cider-macrostep--gensym-overlays)))))))