Function: eca-chat--cached-overlay
eca-chat--cached-overlay is a macro defined in eca-chat.el.
Signature
(eca-chat--cached-overlay CACHE-VAR PROP)
Documentation
Return the singleton overlay tagged with PROP, memoized in CACHE-VAR.
Falls back to a single linear scan of overlays in the current
buffer when the cache is empty, holds a deleted overlay, or
points to an overlay in a different buffer. CACHE-VAR must be a
buffer-local variable (defined with defvar-local).
The returned overlay is the same one a plain
(-first (-lambda (ov) (eq t (overlay-get ov PROP)))
(overlays-in (point-min) (point-max)))
would produce, but cached so that subsequent calls skip the scan.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defmacro eca-chat--cached-overlay (cache-var prop)
"Return the singleton overlay tagged with PROP, memoized in CACHE-VAR.
Falls back to a single linear scan of overlays in the current
buffer when the cache is empty, holds a deleted overlay, or
points to an overlay in a different buffer. CACHE-VAR must be a
buffer-local variable (defined with `defvar-local').
The returned overlay is the same one a plain
`(-first (-lambda (ov) (eq t (overlay-get ov PROP)))
(overlays-in (point-min) (point-max)))'
would produce, but cached so that subsequent calls skip the scan."
(declare (debug (symbolp form)))
`(or (let ((ov ,cache-var))
(when (and (overlayp ov)
(overlay-buffer ov)
(eq (overlay-buffer ov) (current-buffer))
(eq t (overlay-get ov ,prop)))
ov))
(setq ,cache-var
(-first (-lambda (ov) (eq t (overlay-get ov ,prop)))
(overlays-in (point-min) (point-max))))))