Function: majutsu-selection--render-overlay

majutsu-selection--render-overlay is a natively compiled function defined in majutsu-selection.el.

Signature

(majutsu-selection--render-overlay SESSION ID LABELS LOCATE-FN)

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-selection.el
(defun majutsu-selection--render-overlay (session id labels locate-fn)
  (majutsu-selection--with-session-buffer session
    (let* ((overlays (majutsu-selection-session-overlays session))
           (range (when labels
                    (when-let* ((located (funcall locate-fn id)))
                      (cond
                       ((and (consp located) (car located) (cdr located))
                        located)
                       ((eieio-object-p located)
                        (let ((start (oref located start))
                              (end (or (oref located content) (oref located end))))
                          (and start end (cons start end)))))))))
      (if range
          (let* ((existing (gethash id overlays))
                 (start (car range))
                 (end (cdr range)))
            (unless (and existing
                         (overlay-buffer existing)
                         (= (overlay-start existing) start)
                         (= (overlay-end existing) end))
              (when existing (delete-overlay existing))
              (setq existing (make-overlay start end nil t))
              (overlay-put existing 'evaporate t)
              (overlay-put existing 'priority '(nil . 50))
              (overlay-put existing 'majutsu-selection t)
              (puthash id existing overlays))
            (overlay-put existing 'before-string
                         (concat (mapconcat #'identity (nreverse labels) " ") " ")))
        (when-let* ((existing (gethash id overlays)))
          (delete-overlay existing)
          (remhash id overlays))))))